PL/SQL Procedure Parameters PROBLEM
Here's my problem:
When we describe the successfully compiled PL/SQL packaged procedures in SQL*Plus, the parameter order seems reversed. For instance, my PL/SQL source looks like this:
Create Package pkg1...
Procedure func1 (param1 in varchar2,
param2 in number) is
...function body...
end func1;
end pkg1;
After it is successfully compiled in SQL*Plus, when I describe it using the desc command, it shows:
PROCEDURE FUNC1
Argument Name Type ......
PARAM2 VARCHAR2
PARAM1 VARCHAF2
This problem occurs occasionally, if we recompile the source, it goes away. We couldn't quite tell when and how this happens. When the problem occurs, we checked the ALL_SOURCE view and verified that the parameters are in the right order.
We use the Merant Drivers for our client side interfaces and whenever we have this problem on the db server, we get the "wrong number of types or parameters" error.
Any clues, hints, solutions are greatly appreciated.
Thank you for your time.
On a different note, I couldn't find the appropriate forum to post this PL/SQL specific message, wondering why there isn't a PL/SQL forum.
Murthy.
Hi Yegneshwar
Can U tell me how to invoke the procedure ? If all it can be invoked the post it or mail me and then I might help U out.
Thank U.
edwin
Similar Messages
-
Hi experts
I have a procedure in SQL that I want to run in Query of SAP b1. I am using exec [procedure name] [parameters] . It is executing properly. but I want to add choose list with parameter. Like parameter is empcode then Query should show empcode list like in normal query. In sql procedure how I can do ?
Thanks
Best Regards
JitenderThanks Neetu for reply
My SQL procedure is running fine. It has no problem. I want Choose list with SQL procedure parameters.
-- exec leave_status '27515/43'
ALTER proc [dbo].[Leave_status]
@empCode Varchar(30)
--@empname varchar(50)
as
begin
create table #temp
empcode varchar(40),
empName varchar(50),
Branch varchar(40),
DateOfLeave Datetime,
LeaveType varchar(2),
CL_Balance numeric(10,2),
EL_Balance Numeric(10,2)
insert into #temp (empcode, empname, Branch ,dateofleave)
select T0.[U_empCode],T3.[firstName]+ T3.[lastName],T4.[Name] , T0.[U_AtnDate]
FROM [dbo].[@BIZ_ATREG] T0 ,
OHEM T3 INNER JOIN OUBR T4 ON T3.branch = T4.Code
Where T3.[U_empCode]= T0.[U_empCode]
and T0.[U_sttsCd] = 'L'
and T0.[U_empCode]= @empCode
update T0
set leaveType = T2.[U_LcCode]
from #temp T0,
[dbo].[@BIZ_OLVR] T1 ,
[dbo].[@BIZ_LVR1] T2
where T1.[Code] = T2.[Code]
and T0.dateofleave between U_Dtfrm and U_DtTo
declare @maxDateCL datetime, @MaxDateEL Datetime ,@CL_Avail numeric(10,2),@EL_Avail numeric(10,2)
select @maxdateCL = max(U_dtto) from [dbo].[@BIZ_OLVR] T1 ,[dbo].[@BIZ_LVR1] T2
where T1.[Code] = T2.[Code] and T2.U_LcCode = 'CL' and T1.[U_empCode]= @empCode
select @maxdateEL = max(U_dtto) from [dbo].[@BIZ_OLVR] T1 ,[dbo].[@BIZ_LVR1] T2
where T1.[Code] = T2.[Code] and T2.U_LcCode = 'EL' and T1.[U_empCode]= @empCode
update T0
set CL_Balance = (select U_balance
from
[dbo].[@BIZ_OLVR] T1 ,
[dbo].[@BIZ_LVR1] T2
where T1.[Code] = T2.[Code]
and T2.U_LcCode = 'CL'
and T1.U_dtto= @maxdateCL
and T1.[U_empCode]= @empCode
from #temp T0
update T0
set EL_Balance = (select U_balance
from
[dbo].[@BIZ_OLVR] T1 ,
[dbo].[@BIZ_LVR1] T2
where T1.[Code] = T2.[Code]
and T2.U_LcCode = 'EL'
and T1.U_dtto= @maxdateEL
and T1.[U_empCode]= @empCode
from #temp T0
select @CL_Avail = count(*) from #temp where leaveType = 'CL'
select @EL_Avail = count(*) from #temp where leaveType = 'EL'
select *, @CL_Avail as 'CL Avail', @EL_Avail as 'EL Avail' from #temp order by dateofleave
end
To Execute in Query I use this statement exec exec [dbo].[Leave_status] '27515/27' -
FND_REQUEST PL/SQL procedure with parameters
Hi guys
I have created a concurrent program, using PL/SQL procedure which has 2 in parameters. I am trying to call the concurrent program using
v_req_id :=FND_REQUEST.SUBMIT_REQUEST('INV','OMS_POP_INVVALUES_P',
NULL,SYSDATE,FALSE,l_on_date, l_org_id,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
COMMIT;
However, the concurrent program always failing with
**Starts**26-AUG-2013 14:02:31 ORACLE error 6550 in FDPSTP Cause: FDPSTP failed due to ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'OMS_POP_INVVALUES_P' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
and I doubt it is because the database procedure call is not proper.
I have set four parameters with the concurrent program, as they were with the procedure itself, which are
p_on_date IN DATE, p_org_id IN NUMBER, errbuff OUT VARCHAR2,retcode OUT VARCHAR2
Please help
regards,
rajOkay I fixed the problem by
1. Changing the order of parameters with Procedure like following
CREATE OR REPLACE PROCEDURE OMS_POP_INVVALUES_P (
errbuff OUT VARCHAR2,retcode OUT NUMBER, p_on_date IN DATE, p_org_id IN NUMBER)
IS
and then changing the concurrent program call like following
l_req_id :=
fnd_request.submit_request('INV','OMS_POP_INVVALUES_P',
NULL,SYSDATE,FALSE,l_in_date, l_org_id,CHR(0));
:SYSTEM.Message_Level := '25';
COMMIT;
after removing all the parameters from the program parameter list. No need to pass any value for errbuff and retcode, just pass other parameters and end the parameter list with CHR(0). Hope this is useful for somebody else out there.
Regards,
raj -
Registering PL/SQL procedure in APPS with optional parameters
I want to register a PL/SQL procedure as follows in Oracle APPS.
Problem:
The procedure is to pick up employee details from a table.I need to pass empno as the parameter(or as an input) to the procedure.I want this parameter registered as an optional parameter. This means if I input a value to this parameter, then the procedure will pick up employee details for that empno. If I do not pass any value to this parameter, then procedure will pick employee details for all employees.
Also how can pass two optional parameters to pick employee details for a range of employee numbers?
ThanksHow are you calling your PL/SQL procedure and how are you planning on returning your results?
You don't actually need to have an optional parameter - you could simply pass a NULL value for the EmpNo parameter. If you do want to not reference the parameter at all you can provide a default in the parameter definition.
Assuming that you want to return your results as a cursor, you could do something like:
FUNCTION GetEmpDetails ( EmpNo_i IN VARCHAR2 DEFAULT NULL ) RETURN SYS_REFCURSOR; -
How to pass multiple parameters while calling a pl/sql procedure based serv
Hi,
I have a pl/sql procedure based service that needs to be invoked from the bpel console for testing purpose. This procedure accepts multiple input values which are of varchar2,boolean and datetime data types. How can I get the bpel console to throw a UI where I can enter these values --in other words where(which file and where) can I specify that these are the input parameters that need to be entered along with their types.
Thanks for yr help!Change the payload of the request 'Process WSDL' message type. Change the element of the payload for the RequestMessage to be 'InputParameters' from the XSD generated by the DB Adapter wizard.
Edit the payload (Element) - Choose 'Project Schema Files'. Select 'InputParameters' from the XSD.
You can also change the ResponseMessage by doing the same thing, except that you select 'OutputParameters' from the XSD. -
Parameters to pl/sql procedure on item?
OK, it seems like this should be obvious, but I'm not getting it...
I've created a custom Item type with a PL/SQL procedure. I've defined the procedure to accept the item id and site id as parameters. When the user clicks on the procedure link, the request URL looks like this:
http://je2975/pls/portalj/HMSY_PORTAL.VIEW_CRYSTAL_REPORT?caid=135&id=3818
What should the 'VIEW_CRYSTAL_REPORT' procedure look like in order to read those parameters?
Are they parameters to the procedure in the typical PL/SQL sense? Do I need to get them from wwpro_api_parameters? If so, where do I find the reference path?
Thanks!
nullI've even tried this now without any parameters, and there seems to be something even more basic that I'm missing.
I have the procedure published, with no paramters, I added the missing schema prefix, so the URL now looks like:
http://je2975/pls/portalj/PORTALJ.HMSY_PORTAL.VIEW_CRYSTAL_REPORT
But I'm still getting a 404 file not found.
What am I missing?
Thanks again...
null -
PL/SQL Procedure Calling Java Host Command Problem
This is my first post to this forum so I hope I have chosen the correct one for my problem. I have copied a java procedure to call Unix OS commands from within a PL/SQL procedure. This java works well for some OS commands (Eg ls -la) however it fails when I call others (eg env). Can anyone please give me some help or pointers?
The java is owned by sys and it looks like this
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "ExecCmd" AS
//ExecCmd.java
import java.io.*;
import java.util.*;
//import java.util.ArrayList;
public class ExecCmd {
static public String[] runCommand(String cmd)
throws IOException {
// set up list to capture command output lines
ArrayList list = new ArrayList();
// start command running
System.out.println("OS Command is: "+cmd);
Process proc = Runtime.getRuntime().exec(cmd);
// get command's output stream and
// put a buffered reader input stream on it
InputStream istr = proc.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(istr));
// read output lines from command
String str;
while ((str = br.readLine()) != null)
list.add(str);
// wait for command to terminate
try {
proc.waitFor();
catch (InterruptedException e) {
System.err.println("process was interrupted");
// check its exit value
if (proc.exitValue() != 0)
System.err.println("exit value was non-zero: "+proc.exitValue());
// close stream
br.close();
// return list of strings to caller
return (String[])list.toArray(new String[0]);
public static void main(String args[]) throws IOException {
try {
// run a command
String outlist[] = runCommand(args[0]);
for (int i = 0; i < outlist.length; i++)
System.out.println(outlist);
catch (IOException e) {
System.err.println(e);
The PL/SQL looks like so:
CREATE or REPLACE PROCEDURE RunExecCmd(Command IN STRING) AS
LANGUAGE JAVA NAME 'ExecCmd.main(java.lang.String[])';
I have granted the following permissions to a user who wishes to run the code:
drop public synonym RunExecCmd
create public synonym RunExecCmd for RunExecCmd
grant execute on RunExecCmd to FRED
grant javasyspriv to FRED;
Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/bin/env','execute');
commit
Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/opt/oracle/live/9.0.1/dbs/*','read, write, execute');
commit
The following test harness has been used:
Set Serverout On size 1000000;
call dbms_java.set_output(1000000);
execute RunExecCmd('/bin/ls -la');
execute RunExecCmd('/bin/env');
The output is as follows:
SQL> Set Serverout On size 1000000;
SQL> call dbms_java.set_output(1000000);
Call completed.
SQL> execute RunExecCmd('/bin/ls -la');
OS Command is: /bin/ls -la
total 16522
drwxrwxr-x 2 ora9sys dba 1024 Oct 18 09:46 .
drwxrwxr-x 53 ora9sys dba 1024 Aug 13 09:09 ..
-rw-r--r-- 1 ora9sys dba 40 Sep 3 11:35 afiedt.buf
-rw-r--r-- 1 ora9sys dba 51 Sep 3 09:52 bern1.sql
PL/SQL procedure successfully completed.
SQL> execute RunExecCmd('/bin/env');
OS Command is: /bin/env
exit value was non-zero: 127
PL/SQL procedure successfully completed.
Both commands do work when called from the OS command line.
Any help or assistance would be really appreciated.
Regards,
Bernard.Kamal,
Thanks for that. I have tried to use getErrorStream and it does give me more info. It appears that some of the commands cannot be found. I suspected that this was the case but I am not sure about how this can be as they all appear to reside in the same directory with the same permissions.
What is more confusing is output like so:
SQL> Set Serverout On size 1000000;
SQL> call dbms_java.set_output(1000000);
Call completed.
SQL> execute RunExecCmd('/usr/bin/id');
OS Command is: /usr/bin/id
exit value was non-zero: 1
id: invalid user name: ""
PL/SQL procedure successfully completed.
SQL> execute RunExecCmd('/usr/bin/which id');
OS Command is: /usr/bin/which id
/usr/bin/id
PL/SQL procedure successfully completed.
Regards,
Bernard -
I wonder whether a PL/SQL procedure can take an array of varchar parameters
i want to take an array as parameters of a PL/SQL procedure, the type of the array may be varchar. How to implement this idea?
Thanks for any suggestions.create or replace
procedure c1 (p_array DBMS_SQL.VARCHAR2S) is
begin
dbms_output.enable (10000) ;
FOR i_rec in p_array.FIRST..p_array.LAST LOOP
dbms_output.put_line (p_array(i_rec)) ;
END LOOP ;
end ;
set serveroutput on
DECLARE
T_V2 DBMS_SQL.VARCHAR2S;
BEGIN
T_V2(1) := 'Alpha' ;
T_V2(2) := 'Beta' ;
T_V2(3) := 'Gamma' ;
C1 (T_V2) ;
END;
Alpha
Beta
Gamma -
Can some selection conditions as PL/SQL procedure input parameters
Dear All,
I need to write a PL/SQL procedure so as to compute the different query only by changing the input parameters. But those input parameters need to be like a PL/SQL table selection conditions. Like:
one of the query I need two conditions:
customers.zip = 60606
customers.zip = employees.zipMy procedure can compute the query like:
select customers.cno, cname, employees.eno, ename
from customers, orders, employees
where customers.cno = orders.cno and
employees.eno = orders.eno and
C;
where C is the conjunction of the conditions in the input parameter.
Please help and thanks in advance!Well, it's easy enough to do what you want....
SQL> conn scott/tiger
Connected.
SQL> CREATE OR REPLACE FUNCTION flexi_q (pn_deptno IN NUMBER, pv_string IN VARCHAR2 := NULL)
2 RETURN sys_refcursor AS
3 return_value sys_refcursor;
4 BEGIN
5 IF pv_string IS NULL THEN
6 OPEN return_value FOR SELECT * FROM emp WHERE deptno = pn_deptno;
7 ELSE
8 OPEN return_value FOR 'SELECT * FROM emp WHERE deptno = :1 AND '
9 ||pv_string USING pn_deptno;
10 END IF;
11 RETURN return_value;
12 END;
13 /
Function created.
SQL> var rc refcursor
SQL> exec :rc := flexi_q(30)
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30
7900 JAMES CLERK 7698 03-DEC-81 950
30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30
6 rows selected.
SQL> exec :rc := flexi_q(30, 'SAL > 1400')
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30
SQL> The real question is: do you really want to do this? Fundamentally you are handing over control of your app to any nimrod who thinks they know how to write SQL. It's just about allowable for them to add simple restrictions but they could add in anything - correlated sub-queries, extravagant sorts, etc. Even if they don't deliberately exploit this hole you still have a fundamentally untunable part of your app.
It would be much better to have some additional parameters that allows the users to choose from several off-the-peg queries. If you have a user demanding the ability to write "any report I need" I recommend talking to them. The chances are they simply have a pet query, probably embodied in an Excel spreadsheet, they run once every month. Give them a view to meet that need and they'll be happy.
Cheers, APC -
Passing parameters to pl/sql procedure called in portal
Hi all,
I am trying to use a javascript window.open function to create a small popup window that is populated by a pl/sql procedure from inside portal.
I am trying to pass it a parameter to refine a SQL query running in that procedure, unfortunately I'm not sure of the syntax. The url that I'm trying to open in the new window looks like this:
http://my.server.com:7777/portal/pls/portal/myschema.mypackage.myprocedure
If I just run this, it works fine and the popup window opens correctly and displays all results. If I try to pass a parameter, it errors out with a 404 Page Not Found.
The parameter itself comes from a text field that the user can enter a value into. I am able to get the value of that text field and append it to the url I'm generating, but I can't find the proper syntax.
I've tried numerous syntax variants, but none of them seem to work. The procedure does have the parameter defined in both the spec and body and properly handles it. Can anyone point me in the right direction?
Thanks,
-Mike MarkiwYou said you have a text field where a user enters a value, so I am assuming that you have form...
you can try following
<form action="/pls/portal/myschema.mypackage.myprocedure" method="post">
your text field "inVar"
your submit button
</form>
I am sure your myprocedure has inVar as an input...
If you just want to pass a value to a procedure you can always do following:
http://my.server.com:7777/portal/pls/portal/myschema.mypackage.myprocedure?inVar=the value -
Problem calling PL/SQL procedure from Workflow function activity.
Hi,
I am trying to call a PL/SQL procedure from within my workflow activity.
While I am able to execute the procedure through SQLDeveloper, the workflow function does not seem to call it.
It seems that custom PL/SQL procedures have to conform to certain standards to be called within workflow applications. I have written my procedure to conform to those standards (referred to the example workflows).
Could someone please help me with it?
Thanks and regards.Hi,
When I've received enough alpha reviews of the first few chapters of my book, I'll make chapter five available, which deals with writing functions for Workflows.
Matt
Alpha review chapters from my book "Developing With Oracle Workflow" are available on my website:
http://www.workflowfaq.com
http://forum.workflowfaq.com -
Problem with PL/SQL Procedure
Hi,
the following procedure doesn't work:
PROCEDURE "DATEDIMENSION" (start_date in date, end_date in date) is
current_date date;
days_offset number;
days_between number := end_date - start_date;
BEGIN
execute immediate
'create or replace table dwh_dim_date
( FULL_DATE date NOT NULL,
DAY_OF_WEEK number(1) NOT NULL,
DAY_NUMBER_IN_CALENDAR_MONTH number(2) NOT NULL
for days_offset IN 0..days_between
loop
current_date := start_date + days_offset;
execute immediate
insert into dwh_dim_date
( "FULL_DATE",
"DAY_OF_WEEK",
"DAY_NUMBER_IN_CALENDAR_MONTH"
values
select
to_date(current_date, "DD.MM.YYYY"),
to_number(to_char(current_date, "D")),
to_number(to_char(current_date, "DD")),
from
dual
END LOOP;
END;
Can anybody help?
Thanks,
WalterWhat version of oracle are you running?
This works fine 9.2.0.6
1 create or replace PROCEDURE DATEDIMENSION
2 (start_date in date, end_date in date) is
3 curr_date date;
4 days_offset number;
5 days_between number := end_date - start_date;
6 BEGIN
7 for days_offset IN 0..days_between
8 loop
9 curr_date := start_date + days_offset;
10 insert into dwh_dim_date
11 ( "FULL_DATE",
12 "DAY_OF_WEEK",
13 "DAY_NUMBER_IN_CALENDAR_MONTH")
14 values(curr_date,
15 to_number(to_char(curr_date, 'D')),
16 to_number(to_char(curr_date, 'DD')) );
17 END LOOP;
18* END;
SQL> /
Procedure created.
SQL> execute DATEDIMENSION (to_date('01.01.1901', 'DD.MM.YYYY'), to_date('31.12.2099', 'DD.MM.YYYY'))
PL/SQL procedure successfully completed.
SQL> -
Jdbc NullPointerException calling pl/sql procedure from java
Hi.
Getting the following exception calling a plsql procedure from jdbc.
- Jdbc version is 10.2.0.2, but it also happens running several other variants, including 10.1.0.5.0.
- Application is running in Weblogic 8.1.3 (8.1 SP 3).
The procedure call itself has 2 in/out parameters which are tables (actually just 1 dimensional arrays), which I'm suspecting has something to do with the problem. I can successfully call this procedure using a plsql developer tool with the same bind parameters.
Any ideas?
Exception encountered while executing PL/SQL procedure MVT_Web_Inquiry.ShowInquiry:
java.lang.NullPointerException at oracle.jdbc.driver.T4CTTIiov.processRXD([Loracle.jdbc.driver.Accessor;I[B[C[SILoracle.jdbc.driver.DBConversion;[B[B[[Ljava.io.InputStream;[[[B[[Loracle.jdbc.oracore.OracleTypeADT;Loracle.jdbc.driver.OracleStatement;[B[C[S)[Loracle.jdbc.driver.Accessor;(T4CTTIiov.java:139)
at oracle.jdbc.driver.T4C8Oall.receive()V(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(ZZZZ)V(T4CCallableStatement.java:215)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(Z)V(T4CCallableStatement.java:1119)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(OracleStatement.java:1278)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal()I(OraclePreparedStatement.java:3446)
at oracle.jdbc.driver.OraclePreparedStatement.execute()Z(OraclePreparedStatement.java:3552)
at oracle.jdbc.driver.OracleCallableStatement.execute()Z(OracleCallableStatement.java:5261)
at weblogic.jdbc.wrapper.PreparedStatement.execute()Z(PreparedStatement.java:70)
at
[snip]OK... I figured it out.
Apparently, this error happens when you forget to register the output part of an in/out parameter. I would have hoped for better error messaging, but oh well.
-ed- -
MS SQL Procedure Call from Oracle Database
I have Oracle Database 11g connected to MS Sql Server 2008 via dg4msql, and need to execute procedure on MS Sql with parameters from Oracle, and get dataset (table) as a result.
I'm not sure is it possible to call procedure directly from Oracle; One solution would be make function on MS SQL, and put select on procedure from Oracle, but what with parameters?
Is there some possibility to call this procedure from Oracle and get this dataset as a cursor?
Thanks in advance!
Edited by: mihaelradovan on 2012.04.26 14:35Yes, of course I have DB Link in Oracle and procedure in SQL Server.
Btw, I can select data from SQL Server table.
I made one function in SQL Server, and I can not make select on this function, but in SQL Server I made view as select * from function_name, and select on this view from Oracle works. But problem is I have to call this procedure or function with parameters, and with view I can not do this.
So, I must call procedure or function with parameters directly. I made all by the book (Oracle® Database Gateway for SQL Server User’s Guide), but probably I miss something... -
JDBC - Pl/SQL-Procedure or SQL-Statement???
Hi,
we have got the following problem:
Our program is entirely written in Java. It has to communicate with an ORACLE 8i database (Version 8.1.7). The big question is whether to call pl/sql-procedures which include the sql-statement (select/ insert/update) or to write the sql-statements in the Java-code directly.
We messure the time in our test-database. The procedure took twice the time of the direct statement, althoug the sql-statement had to be parsed each time.
What is the better way: pl/sql-procedure or sql-statements? On which conditions depend the choose?
(For your information: our statements aren't difficult. In our testdatabase aren't much datasources.)
Here is a snippet of our code:
1. PL/SQL-Prozedure:
CallableStatement cs = conn.prepareCall("begin dbrb_test_pkg.test(?,?,?); end;");
cs.registerOutParameter(1, OracleTypes.CURSOR);
cs.registerOutParameter(2, OracleTypes.CURSOR);
cs.registerOutParameter(3, OracleTypes.CURSOR);
cs.execute();
ResultSet rs1 = ((OracleCallableStatement)cs).getCursor(1);
ResultSet rs2 = ((OracleCallableStatement)cs).getCursor(2);
ResultSet rs3 = ((OracleCallableStatement)cs).getCursor(3);
2. SQL-Statements directly in Java-Code:
String statement1b = "SELECT bva_id, bva_datva FROM bva";
ResultSet rs1b = stmt.executeQuery(statement1b);
String statement2b = "SELECT brb_id, brb_datein FROM brb";
ResultSet rs2b = stmt.executeQuery(statement2b);
String statement3b = "SELECT bper_id, bper_nz1 FROM bper";
ResultSet rs3b = stmt.executeQuery(statement3b);
Thanks a lot.
Claudia and Nicolethis is a case-to-case basis.
it's ok to use the Statement/PreparedStatement if you're constructing your SQL or DML (insert/update/delete) statements. like when you're WHERE condition is dynamically created. this can be done also in PL/SQL (CallabeStatement) but passing of data is very tedious for you.
the PL/SQL is much better to use if all your SQL or DML statements are fixed. besides, this is easier to maintain. when you need to change a statement, you don't need to check the statement in SQL prompt then make the necessary changes in your java codes, then compile the class. when you're using PLSQL, you just need to change and recompile the PL you made. then presto! it's done. as long as you don't change the parameters the PL receives and sends, it should perfectly work with your java code. =)
Maybe you are looking for
-
Error -50: Unable to Prepare Project for Publishing
Please advise on what to do when this error appears: "The project could not be prepared for publishing because an error occurred. (-50)" I checked and Time Machine is turned off. Any advise appreciated.
-
<!---Control the timeout---> <cfsetting requesttimeout="600"> <cfset thisDate = now()> <cfset today = #DateFormat(thisDate,"mm-dd-yyyy")#> <!--- Open ftp connection ---> <cfftp connection="MyFtp" server="#FTPserver#" username="#username#"
-
Can anyone give me an idea of how to call a cobol program from java. If you can provide me some sample code .It would be great. Thanks in advance
-
Problem loading data in cube 0REFX_C03
Hi all, Has anyone had problem with loading data to 0REFX_C03 cube? I am trying to load, but it just takes too long(predicted time of 10 days!!) and times out after a while.. Please advise if anyone has got any suggestions.. Thank you. Edited by: Sha
-
ADE doesn't start on Windows XP
Hi, I installed ADE 4.0 on several PCs with Windows XP, but it doesn't start. Do I need any prerequisites? Same prblem appears with ADE 3.0 Yes, I know, XP is obsolete, but we're migrating to 7 and still run XP machines. ;-) Thanks a lot and kind reg