Back list Java plsql function
Hi all
I have the java as code: -.
package com.demo.test; import java.util.ArrayList; import java.util.List; public class ListTest { public List<String> getList() { List listA = new ArrayList(); listA.add("element 1"); listA.add("element 2"); listA.add("element 3"); listA.add("element 4"); listA.add("element 5"); listA.add("element 6"); listA.add("element 7"); return listA; } }
I create the function to call java: -.
create or replace FUNCTION get_list return varchar2 as language java name 'com.demo.test.ListTest.getList() return java.lang.String';
I want to call above function in plsql and I out like: -.
Element1
item2
3
Item4
element5
element6
Element7
Please help me.
Thank you
Xandot
create or replace and compile java source named ListTestSrc as package com.demo.test; import java.util.ArrayList; import java.util.List; import java.sql.*; import oracle.sql.*; public class ListTest { public static ARRAY getList() throws SQLException { List listA = new ArrayList(); listA.add("element 1"); listA.add("element 2"); listA.add("element 3"); listA.add("element 4"); listA.add("element 5"); listA.add("element 6"); listA.add("element 7"); Connection conn = DriverManager.getConnection("jdbc:default:connection:"); ArrayDescriptor dsc = ArrayDescriptor.createDescriptor("VARCHAR2_TABLE", conn); return new ARRAY(dsc, conn, listA.toArray()); } }
create or replace type varchar2_table as table of varchar2(4000); / create or replace function get_list return varchar2_table as language java name 'com.demo.test.ListTest.getList() return oracle.sql.ARRAY'; /
SQL> select * from table(get_list); COLUMN_VALUE --------------------------------------- element 1 element 2 element 3 element 4 element 5 element 6 element 7 7 rows selected.
If you want to use the collection in a SQL query (as above) and if the collection is large, you can do in pipeline.
See a similar example here: Re: Re: how to select csv data stored in a BLOB column as if it were an external table?
Otherwise, just use it directly into the PL/SQL code:
SQL> set serverout on SQL> SQL> declare 2 v_list varchar2_table := get_list(); 3 begin 4 for i in 1 .. v_list.count loop 5 dbms_output.put_line(v_list(i)); 6 end loop; 7 end; 8 / element 1 element 2 element 3 element 4 element 5 element 6 element 7 PL/SQL procedure successfully completed.
Tags: Database
Similar Questions
-
PLSQL function to return the result of the query
Dear all,
Oracle Database SE1 11.2.0.1
I need to create a plsql function which should accept SQL as a parameter, execute it and return the result set.
Is this possible?
Madhu.149 wrote:
I need to create a plsql function which should accept SQL as a parameter, execute it and return the result set.
Be careful - results games indicate a set of data stored in memory. This is not what are sliders. This isn't how Oracle should be used.
Imagine that you implement such a result set function - which, on average, requires 1 MB of memory (private server) to store the results of the SQL query. A 100 users mean a 100 MB of memory required server. This is not suitable. Not at all. Never.
The correct back 'thing' is a handle to SQL cursor (called a ref cursor in this case). A SQL cursor is a "program" - that the appellant runs via the fetch command and generates one or more lines accordingly. Appellant repeatedly runs this slider through calls to fetch until this slider found and returns all rows affected (using consistent readings).
If you want an abstraction interface that the client can call via PL/SQL code in the database, so this crafting optimal SQL interface, creates the SQL cursor and returns the handle of the cursor (via the ref cursor data type) to the client.
-
I need to go back to java 6 after installing java 8 because I can't work in photoshop cs5. I tried the steps above, but nothing helped.
Any HEP would be appreciated.
Thank you
Update of Java for Mac OS X 10.6 17 Snow Leopard
-
I no longer get suggested words when composing a message text on my iphone 5. How to get back to get this function works
Make sure that the text is on. You can do this on the keyboard (if you have several) by pressing and holding down the button to change between them.
Alternatively you can go to settings > general > keyboard and make sure predictive is turned on (the switch must be green).
If you see the image below, press the small white bar above the buttons T and Y and slide upward slightly.
-
Hi, I tried to get the current list of all dll functions. Here is my code: tsErrChkMsgPopup (TS_StepGetModule (StepHandle, & errorInfo & cviModule)); error = TS_CVIModuleAsCommonCModule (cviModule, & errorInfo, & commonCModule); sprintf ("c:\\Temp\\%s", sztemp, szdll); error = TS_CommonCModuleSetModulePath (commonCModule, & errorInfo, sztemp); error = TS_CVIModuleSetModuleType (commonCModule, & errorInfo, TSConst_CVIModuleType_DLL); error = TS_EngineGetAdapter (EngineHandle, & errorInfo, County, & commonCAdapter); error = TS_CommonCAdapterGetDllFunctions (commonCAdapter, & errorInfo, sztemp, & dll_func); Problem was found in the last line. Direct connection between commonCModule and commonCAdapter was non-existent, so I ask for EngineHandle of commonCAdapter, because GetDllFunctions is only for commonCAdapter. Can you help me with this? Best regards, branar
You don't need a module for a list of the functions of the DLL. Here's some pseudocode for what you need to do:
Adapter CommonCAdapter = Engine.GetAdapterByKeyName (AdapterKeyNames.FlexCVIAdapterKeyName);
DllFunctions functions = adapter. GetDllFunctions (path);
for (int i = 0; i)< functions.count;="">
{
Function DllFunction = functions [i];
String nomfonction = function. DisplayName;
Do something with functionName.
}
-
This plsql function is considered ok?
This plsql function is considered ok? The reason that I ask is that the results are different when called within a packet vs appeal during a procedure. I don't know if this is a bug or if it is illegal.
CREATE OR REPLACE package body test as function test return varchar2 is begin htp.prn('ABCDEF'); return 'xyz'; end; end;
When this function is called inside a package, the string 'ABCDEF' will appear out of sequence. I think it's because of the in-Lining, 11 g the function at compile time.
Whereas, when the function is called during a procedure the string 'ABCDEF' appears in the browser html properly.
The service is technically do stuff how to output data from htp.prn, then Oracle can judged illegal. I have a very good reason for wanting this feature, so before you take a different approach, I wanted to ask around.
The question is how the statements are executed by the PL/SQL engine.
Consider the statement:
HTP.p (' test1 ' |) FuncTest() ' | 'test2');
To run it, all nested 'objects' must be resolved and executed first. Think of the execution path inside-to-outside.
If FuncTest() is executed first. He puts a string into the buffer of HTP. The result of the function is concatenated and created a unique string literal. This literal is now the parameter in the call to htp.p (). Who then adds, after FuncTest(), a string to the buffer of HTP.
I disagree with your statement that it behaves differently in the procedures as packages. I created 3 test cases for the foregoing. Anonymous block (run immediately the text code execution). Individual objects (separate procedure and function). Single object (procedure and function wrapped in a box).
Each product, as expected, the same result.* how the engine of PL/SQL treats the path of execution of instructions, does not change because the statement is in a packed and not a stand-alone procedure.
* 11.2.0.2 using SST 11 g Server (Apache v2 and v2 mod_plsql).
-
Create the Java script function
Hello
I try to create the following java script function to retrieve a character string:
String.prototype.left = function (findWhat)
{
try
{
var = this.search (findWhat) position;
If (position > - 1).
Return this.substr (0, position);
}
catch (e)
{
/ / alert (e.message);
}
return "";
};
var text = "myText-description";
var separator = "-";
In this example, I try to extract the word on the left before the "-" delimiter (mtText)
But I get the following error message: failed to add a property to an object sealed: left
My question is how can I create a simple js function in the Orchestrator in the following example
Thank you
Hello
You can try the code to retrieve a string from left to right below the delimiter.
searchstr(); function searchstr() { try{ var str = "angela.soni" var pos = str.indexOf("."); // Currently this is hard coded, you can pass delimiter as an input parameter. if(pos>-1) { var substr = str.substring( 0, pos ); System.log(substr); } else { System.error("Delimiter not found"); } } catch (e) { System.error("Search failed: " + e); } }
I hope this would help you.
Thank you!
Angela
-
Call a java script function, the loading of the page while in ebiz
Hi gurus of the OFA.
I have a requirement for a java script to each page renders OFA function call or charges.
That is when any OAF page load or make in Oracle e - biz, I have a java script function that should be called is possible to implement the above mentioned requirements.
Thanks in advance...
SouravOK, I have your condition. It's one of the basis OFA classes then you can try class decompile OAPageBean. I tried yesterday, there are many interesting ways you can add JavaScript and recompile class. do the backup of old, of course. And your JavaScript will work on any page of the OFA
-
error in calculation PLSQL function
Hi friends,
I have the plsql function below that throw error.
The function below is written in Apex, if kindly let me know how to solve this error
The following query checks the existing value and null assigns a value to the select statement. otherwise will assign it to the variable. I don't get how to set dynamically using the select statement
Function:
BEGIN
IF
: P1_VARIABLE_NAME IS NULL THEN: P1_VARIABLE_NAME: = select... from... (which returns a string)
ON THE OTHER
: P1_VARIABLE_NAME
END
END
Error:
Met the "SELECT" symbol when awaits one of the following numbers: (- + case mod new avg not null current County exists prior min max sql stddev sum variance execute forall time timestamp interval date fusion pipe)Hi Pradeep,
Have you used the suggestion in the post above?
(Do not use the PL/SQL only the suggested above query block)
Did you put a semicolon after the query?
And you always use the PL/SQL code?Could you post details of calculation?
Kind regards
Kiran -
List of procs &; functions of loading of a table
Y at - it a simple way to find out who are all procedures and functions are insert or update data in particular insertion of data into a table. As we have in sybase "sp_depends table_name" that lists the procs & functions, like wise we similarly in Oracle to know.
Thank you very much.Yes, in my example the COLUMN instruction is just a SQL * more relieved to change the display format (see http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12013.htm#SQPUG034).
-
ERR-9131 error in the body of PLSQL function for default code point, the point =
Hi all
I am filling a field element of text in two different ways, but on the same page:
1 - the page is called to change the values inside-> value of the element comes from field of database
2 - the page is called to insert new values-> value of the element comes from a calculated function that returns a default value
Point features:
Source->
always replace any existing value in session state
database column
-> Default
-----------------------------------------------------------------------------------------------------------------------------
default value
------------------------------------------------------------------------------------------------------------------------------
DECLARE
NUMBER OF THE LINHA;
gene number;
i_emp varchar2 (32000);
v_sql2 varchar2 (32000);
BEGIN
i_emp: =: P62_EMP_COD;
IF: P62_RDD_LIN IS NULL THEN
LINHA: = 1;
ON THE OTHER
LINHA: =: P62_RDD_LIN;
END IF;
v_sql2: =' select '. i_emp |'. Grh_1_utils. GRHFU_RUB_DEFAULT ('|: P62_ENT_COD |', 'R' ' |: P62_REM_COD |', 1, 1000000, to_date null, "D", ("' |: P62_DAT_INI |")) (', "DD/MM/YYYY"),' | LINHA |') the double ';
EXECUTE IMMEDIATE v_sql2 INTO gene;
COMMIT;
return deciphered;
end;
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
default value - body of the PL/SQL function
The error I get is:
ORA-00936: lack of expression
ERR-9131 error in PLSQL function for default code point body, item = ITEM_TO_POPULATE
Something is wrong with my function or is a different, better way to do this?
Cordially Pedro.Hello
You can do some tests?
(1) try to make this code first (to make sure that the P62_EMP_COD is not null when running):DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT('||:P62_ENT_COD||',''R'','||:P62_REM_COD||', 1 , 1000000,''D'',null,to_date('''||:P62_DAT_INI||''',''DD/MM/YYYY''),'||LINHA||') from dual'; EXECUTE IMMEDIATE v_sql2 INTO defeito; COMMIT; return defeito; end;
(2) then you can try to change your source, by changing 'replacement always of value that exists in the session state' "only when null.
(3) enter your variable dynamic SQL code and check it out:
DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT('||:P62_ENT_COD||',''R'','||:P62_REM_COD||', 1 , 1000000,''D'',null,to_date('''||:P62_DAT_INI||''',''DD/MM/YYYY''),'||LINHA||') from dual'; return v_sql2; EXECUTE IMMEDIATE v_sql2 INTO defeito; COMMIT; return defeito; end;
(4) prevent your run immediate code of SQL Injections using the link:
DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT(:1,''R'',:2, 1 , 1000000,''D'',null,to_date(:3,''DD/MM/YYYY''),:4) from dual'; EXECUTE IMMEDIATE v_sql2 INTO defeito USING :P62_ENT_COD, :P62_REM_COD, :P62_DAT_INI, LINHA; COMMIT; return defeito; end;
Best regards, Kostya Proskudin
-
How to take a SQL query result in the source section of an APEX "agenda of the page" field and allow this request to be formatted using XML in an HTML format for a Java Script file to perform a function on the result?
Currently I have the following text:
To query the DB table and format the result as HTML:
SELECT XMLELEMENT ("UL id ="ticker01"', XMLAGG (XMLFOREST (Scroll_Mess AS LI))") "item UL' OF Web_Ticker where Mess_Id < 10 order by Mess_Id;
That displays the following:
< UL id = "ticker01" > < LI > HELLO < /LI > < LI > HELLO < /LI > < /UL id = "ticker01" >
I need the output of this to be visible to a JScript function that is currently called the "head of page", but there doesn't seem to be its scope? The function works correctly if there is a list in the page field items 'Text element Pre' but does not work correctly when used in conjunction with the query to generate a table form.
If everyone is happy to help I would be grateful .
James.
Solved!
In order for the request to be part of the DOM of the page of the APEX, the Java Script allows to perform its function on the result marked "HTML" to query, you must set page of the apex on which the query resides and then add the inner text of this page to a second variable for which the function of web ticker can run on as follows:
$(function() {})
var x = $("#P9_TICKER_DATA");
var y = x [0] .innerText;
x.Append (y);
$("UL#ticker01").liScroll ();
});
From there, on the Java script is able to properly see the result of the query in HTML format.
-
unexpected problem with the permission of type plsql function scheme
Hello
I created a schema authorization function plsql type returning a Boolean. Authorization scheme is for pages only. p2_user_priviledge is a textbox control on the home page that retrieves privilege (list of the pagenos) to the user of the database connection. Homepage has no required permissions. SCHEMA AUTHORIZATION always returns false. I am not able to trace problem in my code. same code works fine for failure to the 'c' of return area.
-CODE OF AUTHORIZATION SCHEME-
declare
PageID varchar2 (10);
VARCHAR2 (300) of privilege;
c number (3);
Start
PageID: = ": P" | to_char(:app_page_id) |': '; -NUMPAGE stored in format *: P2: *
privilege: = trim(:p2_user_priviledge); ++-List contain privileges like: P2:P13:P67:P23: etc +++ select instr (privilege, pageid) in c to double;
If c > 0 then
Returns true;
on the other
Returns false;
end if;
end;
------------------------------------------------------------------------------------------------------------------------------------------
Another problem is again related to the authorization scheme.
I created an application and schema of an authorization (auth_aug), which worked fine. Then, after a few days, I added more than 10 pages for the same application, but now autho_aug always returned false for new pages. Then I copied the code from the "autho_aug" to the new "autho_sept" regime, and it worked for new pages. I do not understand if code is the same for both system, why had to use two different schemas.
Now, I've added a few pages more enforcement and problem mentioned earlier.
any solution to the two problems...Hello
You can create a component of demand through the shared components in your application, elements of Application option. All you do here is to create a new item and give it a name.
Once this is done, the element can be used as if it were a page element. You can use an Application (also available through shared components) calculation to set the value of this element in the list of page numbers and the value can then be retrieved in a SQL statement or PL/SQL.
You cannot use the popup window Session to change elements from page or application - you will need to create a calculation or process to do.
Andy
-
Is there a list of the functions of the library obsolete?
Recently, I upgraded from 7.0 to 8.5.1 CVI. Library for new routines of navigation functions I realized that certain functions are now deprecated. It is not so complicated to adapt the code to avoid these functions, because the generally better functions have been made available. So I wonder if there is a list of all obsolete library functions that would make it easy to find the code for these functions...
Thank you!
Hello Wolfgang,.
first of all, I don't have a list of all deprecated library functions. But I tried to find a solution for you. One possibility would be to have a look at the online help and search for "obsolete", the results will include obsolete libraries. The second is that I discovered some additional information:
This list does not include material libraries, such as GPIB or DAQmx features.
AllocImageBits
CurrThreadId
CxPolyRoots
DisableBreakOnLibraryErrors
DisableExtendedMouseEvents
DisableInterrupts
DisableTaskSwitching
EnableBreakOnLibraryErrors
EnableExtendedMouseEvents
EnableInterrupts
EnableTaskSwitching
GenWinHelpFileFromFPFile
GetAxisRange
GetExternaleModuleAddr
GetExternaleModuleAddrEx
GetImageBits
GetImageInfo
GetInterruptState
InStandaloneExecutable
LoadExternalModule
LoadExternalModuleEx
MainThreadId
ReFFT
ReleaseExternalModule
RTControllerQuery
RTControllerReboot
RunExternalModule
SetAxisRange
SetDllDebuggingOption
SetImageBits
SetProjectDebugTargetPath
SetProjectTargetPath
TDMS_GetDataValues
UnloadExternalModule -
How to report o create crosstab in plsql function?
Hello
I want to create a function that question of including pivot table. What should be included, I'm using (cursor, folder,...)?
I transformed under code in link below for my project, but I didn't know where to put a block.
Example,
where I put or write the pivot block?
where can I write declare function block?
Thank you for taking the time, have a good day
-----------------------------------------------------------------------------------------
SELECT decode(GROUPING(emea) + GROUPING(lad) + GROUPING(apac) + GROUPING(nas) + GROUPING(japan), 5, 'TOTAL', kn) kn,
SUM(emea) emea,
SUM(lad) lad,
SUM(apac) apac,
SUM(nas) nas,
SUM(japan) japan,
SUM(emea) + SUM(lad) + SUM(apac) + SUM(nas) + SUM(japan) AS total
FROM ((SELECT kz.kz_name AS kn, rl.region AS re, kr.amount AS am
FROM region_lookup rl, kz_name_lookup kz, kz_reg kr
WHERE rl.region_id = kr.region_id
AND kz.kz_name_id = kr.kz_name_id)
pivot(SUM(am) FOR re IN ('EMEA' AS emea, 'LAD' AS lad, 'APAC' AS apac, 'NAS' AS nas, 'JAPAN' AS japan))) t
GROUP BY GROUPING SETS((kn, emea, lad, apac, nas, japan),())ORDER BY GROUPING(t.kn), t.kn;
You can declare a function that returns a ref cursor, then get Java to navigate the cursor until there finishes
sys_refcursor function MyCursorFunc is
vCur sys_refcursor;
Start
Open vCur for
SELECT decode (GROUPING (emea) GROUPING (FDA) + GROUPING (apac) + GROUPING (SIN) + GROUPING (japan), 5, 'TOTAL', kn) kn.
Sum (EMEA) emea,
Sum (FDA) boy,
Sum (APAC) apac,
Sum (SIN) Sin,
Sum (Japan) Japan,
Sum (EMEA) + SUM (FDA) + SUM (apac) + SUM (SIN) + SUM (japan) AS total
OF ((SELECT kz.kz_name AS kn, rl.region LIKE re, kr.amount MOD
Region_lookup rl, kz_name_lookup kz, kz_reg kr
WHERE rl.region_id = kr.region_id
AND kz.kz_name_id = kr.kz_name_id)
Pivot (Sum (AM) FOR re IN ("EMEA" IN emea, 'BOY' AS a boy, "ACPA" AS apac, "SIN" AS nas "JAPAN" JAPAN))) t
GROUP BY GROUPING SETS ((kn, emea, lad, apac, nas, japan), ())
ORDER BY GROUPING (t.kn), t.kn;
return vCur;
end;
How to call here
or
Why not just define a view?
create or replace view V_MyData as
SELECT decode (GROUPING (emea) GROUPING (FDA) + GROUPING (apac) + GROUPING (SIN) + GROUPING (japan), 5, 'TOTAL', kn) kn.
Sum (EMEA) emea,
Sum (FDA) boy,
Sum (APAC) apac,
Sum (SIN) Sin,
Sum (Japan) Japan,
Sum (EMEA) + SUM (FDA) + SUM (apac) + SUM (SIN) + SUM (japan) AS total
OF ((SELECT kz.kz_name AS kn, rl.region LIKE re, kr.amount MOD
Region_lookup rl, kz_name_lookup kz, kz_reg kr
WHERE rl.region_id = kr.region_id
AND kz.kz_name_id = kr.kz_name_id)
Pivot (Sum (AM) FOR re IN ("EMEA" IN emea, 'BOY' AS a boy, "ACPA" AS apac, "SIN" AS nas "JAPAN" JAPAN))) t
GROUP BY GROUPING SETS ((kn, emea, lad, apac, nas, japan), ())
ORDER BY GROUPING (t.kn), t.kn
/
Then in Java just run a query:
Select * from V_MyData
Maybe you are looking for
-
Lack of cRIO 9154 in the add targets and devices dialog box
Hello again all you lovers forum useful! I have an existing LabVIEW project which includes a Hypervisor PXI real-time target. One of the devices that target is a chassis cRIO 9114. I now need to add a cRIO chassis additional 9154 so according to a
-
difficulties to download sercurity downloads... had this problem since June of last year! can u send me a link that will answer my problem & fix this error 646? It's getting really annoying & not helping not to keep my laptop $1 set 600.00 sercurity
-
My labtop keeps showing a red x on the screen battery the charger is plugged in but not charging how do I know if it's the battery or the charger
-
I have a few problems to configure the load balancer, in this case is a load of arm balancer. I think the Setup is simple enough, just trying to balance HTTP traffic, all virtual machines are in the same subnet the edge so load balancer 172.31.1.0/16
-
Keyframing - motions / / postions
Hello I was wondering if anyone else has this problem I received these last days...basically I want to text image key moving on my screen and it slow down in the Middle, so moving from left to right on my screen my keyframes is 1700 / / 700 / / 600 /