Do I use an IN OUT parameter procedure or what?
Hi,
I believe my logic is fine but my syntax and knowing when to use what smacks me.
I have 2 tables CLASSIFICATION and EMPLOYEE in a 1:M relationship.
Now I have to use a value in CLASSIFICATION called CLASSIFICATION.YEARLY_PAY to update my EMPLOYEE.PRO_RATA column in my EMPLOYEE table and I got stuck
See below:
CREATE TABLE CLASSIFICATION(
CLASS_ID VARCHAR2(6) NOT NULL,
CLASS_TYPE VARCHAR2(10),
DESCRIPTION VARCHAR2(30) NOT NULL,
YEARLY_PAY NUMBER(8),
HOURLY_RATE NUMBER,
WEEKDAY_OVER_TIME NUMBER,
WEEKEND_OVER_TIME NUMBER,
CONSTRAINT PK_CLASS_ID PRIMARY KEY (CLASS_ID));
INSERT INTO CLASSIFICATION VALUES('PR1','PERMANENT','MANAGER',45000,'','',NULL);
INSERT INTO CLASSIFICATION VALUES('PR2','PERMANENT','ADMIN ASSISTANT',22000,'',1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('PR3','PERMANENT','CONTROLLER',32000,'',1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('PR4','PERMANENT','CASH OFFICER',22000,'',1.5,NULL;
INSERT INTO CLASSIFICATION VALUES('PR5','PERMANENT','CLEANERS',16000,'',1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('PR6','PERMANENT','ADMIN OFFICER',22000,'',1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('PR7','PERMANENT','WAREHOUSE ATTENDANT',20000,''1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('PR8','PERMANENT','WINDOWS DRESSER',22000,'',1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('PR9','PERMANENT','DIRECTOR',60000,'','',NULL);
INSERT INTO CLASSIFICATION VALUES('PR10','PERMANENT','DEPUTY DIRECTOR',52000,'','',NULL);
INSERT INTO CLASSIFICATION VALUES('PR11','PERMANENT','SALES ASSISTANT',21000,'',1.5,NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP2','TEMP STAFF','ADMIN ASSISTANT','',16.50,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP3','TEMP STAFF','CONTROLLER','',29.00,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP4','TEMP STAFF','CASH OFFICER','',19.00,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP5','TEMP STAFF','CLEANERS','',10.00,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP6','TEMP STAFF','ADMIN OFFICER','',20.00,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP7','TEMP STAFF','WAREHOUSE ATTENDANT','',18.00,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP8','TEMP STAFF','WINDOWS DRESSER','',18.50,'',NULL);
INSERT INTO CLASSIFICATION VALUES('TEMP11','TEMP STAFF','SALES ASSISTANT','',16.00,'',NULL);
CREATE TABLE EMPLOYEE(
EMPID NUMBER(5) NOT NULL,
SURNAME VARCHAR2(30) NOT NULL,
FNAME VARCHAR2(30) NOT NULL,
GENDER CHAR(1) NOT NULL,
DOB DATE NOT NULL,
EMP_TYPE VARCHAR2(20) NOT NULL,
PRO_RATA_WAGES NUMBER(7,2),
ANNUAL_WEEKS_REQD NUMBER(2),
HOLIDAY_ENTLMENT NUMBER(2),
SICK_LEAVE_ENTLMENT NUMBER(2),
HIRE_DATE DATE NOT NULL,
END_DATE DATE,
ACCNO NUMBER(8) NOT NULL,
BANKNAME VARCHAR2(20) NOT NULL,
BRANCH VARCHAR2(20) NOT NULL,
ACCOUNTNAME VARCHAR2(20),
CLASS_ID VARCHAR2(6),
CONSTRAINT CK_HIRE_END CHECK (HIRE_DATE < END_DATE),
CONSTRAINT CK_HIRE_DOB CHECK (HIRE_DATE >= ADD_MONTHS(DOB, 12 * 18)),
CONSTRAINT CK_EMP_TYPE CHECK (EMP_TYPE IN ('FT','PT1','PT2','PT3','HOURLY')),
CONSTRAINT CK_EMP_GENDER CHECK (GENDER IN ('M','F')),
CONSTRAINT FK_EMP_CLASS FOREIGN KEY (CLASS_ID) REFERENCES CLASSIFICATION(CLASS_ID),
CONSTRAINT PK_EMP PRIMARY KEY (EMPID));
INSERT INTO EMPLOYEE VALUES(
SEQ_EMPID.NEXTVAL,'RICHARD','BRANDON','M','25-DEC-1966','FT',22000.00,52,28,14,'10-JAN-2005',NULL,90823227,'NATWEST','BROMLEY','DEPOSIT','PR2');
--record that needs updating to
INSERT INTO EMPLOYEE VALUES(
SEQ_EMPID.NEXTVAL,'BOYCE','CODD','M','15-JAN-1972','PT1','',39,'','','12-JAN-2005',NULL,72444091,'LLOYDS','KENT','CURRENT','PR8');
CREATE SEQUENCE SEQ_EMPID START WITH 1;
==========================================================
SQL> BEGIN
2 v_EMPID NUMBER(5);
3 V_CLASS_ID VARCHAR2(6);
4 V_YEARLY_PAY NUMBER(8);
5 SELECT SEQ_EMPID.CURRVAL INTO V_EMPID FROM DUAL;
6 SELECT b.CLASS_ID, b.YEARLY_PAY INTO V_CLASS_ID, V_YEARLY_PAY FROM CLASSIFICATION b WHERE b.CLA
SS_ID = V_CLASS_ID;
7 IF a.EMP_TYPE ='FT' THEN
8 UPDATE EMPLOYEE a SET a.ANNUAL_WEEKS_REQD = 52, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*52), a.HO
LIDAY_ENTLMENT=28, a.SICK_LEAVE_ENTLMENT = 14 WHERE a.EMPID
9 = V_EMPID;
10 ENDIF;
11 IF EMP_TYPE ='PT1' THEN
12 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 39, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*39), a.HOLIDA
Y_ENTLMENT=21, a.SICK_LEAVE_ENTLMENT = 10.5 WHERE a.EMPID =
13 V_EMPID;
14 ENDIF;
15 IF EMP_TYPE ='PT2' THEN
16 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 26, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*26), a.HOLIDA
Y_ENTLMENT=14, a.SICK_LEAVE_ENTLMENT = 7 WHERE a.EMPID =
17 V_EMPID;
18 ENDIF;
19 IF EMP_TYPE ='PT3' THEN
20 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 13, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*13), a.HOLIDA
Y_ENTLMENT=7, a.SICK_LEAVE_ENTLMENT = 3.5 WHERE a.EMPID =
21 V_EMPID;
22 IF EMP_TYPE ='HOURLY' THEN
23 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = NULL a.PRO_RATA_WAGES = NULL, a.HOLIDAY_ENTLMENT=NULL,
a.SICK_LEAVE_ENTLMENT = NULL WHERE a.EMPID = V_EMPID;
24 ELSE
25 RAISE_APPLICATION_ERROR(12101,'NO MATCHING RECORD EXIST YET');
26 ENDIF;
27 end;
28 /
v_EMPID NUMBER(5);
ERROR at line 2:
ORA-06550: line 2, column 9:
PLS-00103: Encountered the symbol "NUMBER" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "NUMBER" to continue.
ORA-06550: line 3, column 12:
PLS-00103: Encountered the symbol "VARCHAR2" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "VARCHAR2" to continue.
ORA-06550: line 4, column 14:
PLS-00103: Encountered the symbol "NUMBER" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "NUMBER" to continue.
ORA-06550: line 23, column 46:
PLS-00103: Encountered the symbol "A" when expecting one of the following:
, * & - + ; / at mod rem return returning <an exponent (**)>
where ||
The symbol "," was substituted for "A" to continue.
ORA-06550: line 27, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
if
I tried an anonymous block first but did not work.
And how do i eventually execute this procedure anyway if not using it to update through a data entry form.
Much appreciation in advance
cube60
Hi,
I have a longer code which I cut off at the top.
Anyway after execute your tip, here is the result. It looks alot better
SQL> declare
2 v_EMPID NUMBER(5);
3 V_CLASS_ID VARCHAR2(6);
4 V_YEARLY_PAY NUMBER(8);
5 begin
6 SELECT SEQ_EMPID.CURRVAL INTO V_EMPID FROM DUAL;
7 SELECT b.CLASS_ID, b.YEARLY_PAY INTO V_CLASS_ID, V_YEARLY_PAY FROM CLASSIFICATION b WHERE b.CLA
SS_ID = V_CLASS_ID;
8 IF a.EMP_TYPE ='FT' THEN
9 UPDATE EMPLOYEE a SET a.ANNUAL_WEEKS_REQD = 52, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*52), a.HO
LIDAY_ENTLMENT=28, a.SICK_LEAVE_ENTLMENT = 14 WHERE a.EMPID
10 = V_EMPID;
11 ENDIF;
12 IF EMP_TYPE ='PT1' THEN
13 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 39, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*39), a.HOLIDA
Y_ENTLMENT=21, a.SICK_LEAVE_ENTLMENT = 10.5 WHERE a.EMPID =
14 V_EMPID;
15 ENDIF;
16 IF EMP_TYPE ='PT2' THEN
17 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 26, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*26), a.HOLIDA
Y_ENTLMENT=14, a.SICK_LEAVE_ENTLMENT = 7 WHERE a.EMPID =
18 V_EMPID;
19 ENDIF;
20 IF EMP_TYPE ='PT3' THEN
21 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 13, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*13), a.HOLIDA
Y_ENTLMENT=7, a.SICK_LEAVE_ENTLMENT = 3.5 WHERE a.EMPID =
22 V_EMPID;
23 IF EMP_TYPE ='HOURLY' THEN
24 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = NULL a.PRO_RATA_WAGES = NULL, a.HOLIDAY_ENTLMENT=NULL,
a.SICK_LEAVE_ENTLMENT = NULL WHERE a.EMPID = V_EMPID;
25 ELSE
26 RAISE_APPLICATION_ERROR(12101,'NO MATCHING RECORD EXIST YET');
27 ENDIF;
28 end;
29 /
SELECT b.CLASS_ID, b.YEARLY_PAY INTO V_CLASS_ID, V_YEARLY_PAY FROM CLASSIFICATION b WHERE b.CLASS_ID
ERROR at line 7:
ORA-06550: line 24, column 46:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 24, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 28, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
if
This was my original IN OUT parameter procedure
see result below:
SQL> CREATE OR REPLACE PROCEDURE UPDATE_EMPLOYEE(
2 EMPID IN NUMBER,
3 --SURNAME IN VARCHAR2,
4 --FNAME IN VARCHAR2,
5 --GENDER IN CHAR(1),
6 --DOB DATE NOT NULL,
7 EMP_TYPE IN VARCHAR2,
8 PRO_RATA_WAGES OUT NUMBER,
9 ANNUAL_WEEKS_REQD IN NUMBER,
10 HOLIDAY_ENTLMENT IN NUMBER,
11 SICK_LEAVE_ENTLMENT IN NUMBER,
12 HIRE_DATE IN DATE,
13 END_DATE IN DATE,
14 ACCNO IN NUMBER,
15 BANKNAME IN VARCHAR2,
16 BRANCH IN VARCHAR2,
17 ACCOUNTNAME IN VARCHAR2,
18 CLASS_ID IN VARCHAR2)
19 declare
20 v_EMPID NUMBER(5);
21 V_CLASS_ID VARCHAR2(6);
22 V_YEARLY_PAY NUMBER(8);
23 begin
24 SELECT SEQ_EMPID.CURRVAL INTO V_EMPID FROM DUAL;
25 SELECT b.CLASS_ID, b.YEARLY_PAY INTO V_CLASS_ID, V_YEARLY_PAY FROM CLASSIFICATION b WHERE b.CLA
SS_ID = V_CLASS_ID;
26 IF a.EMP_TYPE ='FT' THEN
27 UPDATE EMPLOYEE a SET a.ANNUAL_WEEKS_REQD = 52, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*52), a.HO
LIDAY_ENTLMENT=28, a.SICK_LEAVE_ENTLMENT = 14 WHERE a.EMPID
28 = V_EMPID;
29 ENDIF;
30 IF EMP_TYPE ='PT1' THEN
31 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 39, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*39), a.HOLIDA
Y_ENTLMENT=21, a.SICK_LEAVE_ENTLMENT = 10.5 WHERE a.EMPID =
32 V_EMPID;
33 ENDIF;
34 IF EMP_TYPE ='PT2' THEN
35 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 26, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*26), a.HOLIDA
Y_ENTLMENT=14, a.SICK_LEAVE_ENTLMENT = 7 WHERE a.EMPID =
36 V_EMPID;
37 ENDIF;
38 IF EMP_TYPE ='PT3' THEN
39 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = 13, a.PRO_RATA_WAGES = ((b.YEARLY_PAY/52)*13), a.HOLIDA
Y_ENTLMENT=7, a.SICK_LEAVE_ENTLMENT = 3.5 WHERE a.EMPID =
40 V_EMPID;
41 IF EMP_TYPE ='HOURLY' THEN
42 UPDATE EMPLOYEE SET ANNUAL_WEEKS_REQD = NULL a.PRO_RATA_WAGES = NULL, a.HOLIDAY_ENTLMENT=NULL,
a.SICK_LEAVE_ENTLMENT = NULL WHERE a.EMPID = V_EMPID;
43 ELSE
44 RAISE_APPLICATION_ERROR(12101,'NO MATCHING RECORD EXIST YET');
45 ENDIF;
46 end;
47 /
Warning: Procedure created with compilation errors.
SQL> show err;
Errors for PROCEDURE UPDATE_EMPLOYEE:
LINE/COL ERROR
19/1 PLS-00103: Encountered the symbol "DECLARE" when expecting one of
the following:
; is with authid as cluster order using external
deterministic parallel_enable pipelined
42/46 PLS-00103: Encountered the symbol "A" when expecting one of the
following:
, * & - + ; / at mod rem return returning <an exponent (**)>
where ||
The symbol "," was substituted for "A" to continue.
LINE/COL ERROR
46/4 PLS-00103: Encountered the symbol ";" when expecting one of the
following:
if
Much appreciation in advance
cube60
Similar Messages
-
One thing that I don't like about Java is "no comprehensive" documentation of its methods - prove me wrong by send some link that explains most of the methods in details. Anyway, I've a native method.
<code>
void JNI_MethodX(jenv, jobj, jlongArray jlarr)
// i want to put N values in jlarr
jenv->SetLongArrayRegion(N,...)
for(i:1->N)
jenv->SetLongArrayElement(i, somevalue)
</code>
Suppose calling java code had initialized jlongArray for "zero" elements.
Is it a possible way of using java arrays as OUT Parameters?1. You cannot alter the array size in the JNI code.
2. This has nothing to do with JNI; it is an aspect of java that arrays are objects, and the size is determined when the object is constructed.
3. To solve your problem, I would suggest you - in java - create an object that HOLDS a java array, and has a setter. Then pass that object as a parameter to your JNI code. In your JNI code, you can construct a new - appropriately sized - array, fill it in, and call the setter.
4. Better yet - more java-like - would be to skip the parameter passing, and just return the newly constructed/filled array as the return value of the method.
I find a lot of java documentation proetty good. On the other hand, I've never found any of the JNI documentation very good. The best - my opinion:
essential JNI, by Rob Gordon -
Oracle Instant Client and OUT Parameter of custom type in Stored Procedures
Hi @ all!
I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
The stored procedure and assiciated types looks like this:
TYPE MYVALUE AS OBJECT
Id INTEGER,
value FLOAT
TYPE MYVALUELIST AS TABLE OF MYVALUE;
PROCEDURE ReadValues( ID IN INTEGER,
RESULTSET OUT MYVALUELIST)
IS
...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
Is it possible to pass a parameter with a custom type from C# in some way?
I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
Any suggestions?
Thanks in advance!Hi Greg!
Sorry, I misunderstood the forum topic then. =(
Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
OracleCommand cmd = new OracleCommand();
cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
OracleDataAdapter odr = new OracleDataAdapter(cmd);
DataTable result = new DataTable();
odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
PROCEDURE ReadValues( ID IN INTEGER,
RESULTSET OUT sys_refcursor)
IS
currentlist MYVALUELIST;
... [Adding elements to that list] ...
OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
Regards -
Return Nested Table Using Out Parameter
Hi Friends,
I wrote a function in which i'm using a return type as NUMBER and OUT parameter as TABLE but i'm not able to call the function in PL/SQL because of TABLE ,Can anyone plz tell me how to call the function in PL/sql using TABLE as OUT parameter. The calling function is mentioned below..
FUNCTION get_label_to_folder (
i_folder_id IN NUMBER,
i_label_id IN NUMBER,
i_new_path IN VARCHAR2,
i_src_path IN VARCHAR2 DEFAULT NULL,
--i_output_loc_type IN VARCHAR2,
o_vdoc_table OUT vdocs_table
RETURN NUMBER;
I tried to call that function in this manner but it won't work--
DECLARE
TYPE vdocs_table IS TABLE OF VARCHAR2 (50);
vdoc vdocs_array := vdocs_array ();
vret VARCHAR2 (20);
BEGIN
vret :=
sce_label_util.get_label_to_folder (32272,
324073,
'/test-aaaa/a1/',
NULL,
vdoc
FOR i IN vdoc.FIRST .. vdoc.LAST
LOOP
DBMS_OUTPUT.put_line (vret || ' ,' || vdoc (i));
END LOOP;
END;
Kindly check it and plz resolve the problem.
Regards,
AnandIt is not the correct approach to do this (passing a collection using an OUT parameter) using a function.
Does not matter whether you dislike it. It is still wrong.
It should be a procedure. It should likely define the OUT parameter as being passed by reference and not value in order to decrease the call overheads and increase performance.
Also note that is it not called a table. The correct terminology is a collection or an associative array. A table is something you get inside the database engine. The structure you define in the PL engine is nothing like a database table and everything like an array.
PS. And how do you expect us to determine the error? How do you expect us to test anything if we do not know what Oracle version you are using? Please.. FULL details, including Oracle version number and the full Oracle error message! -
Scheduled Job Call Package with OUT-Parameter
Hi,
I'd like to create a job using the scheduler. The procedure to be called is declared in a package and needs an out-parameter.
procedure transfer_pds2ddata(message out nocopy varchar2);Here the code I use to declare the job.
begin
dbms_scheduler.create_job(
job_name => 'AUTOIMPORT',
job_type => 'stored_procedure',
job_action => 'ACCESSWRAP.transfer_pds2ddata',
number_of_arguments => 1,
start_date => to_date('26-10-2010 10:45','DD-MM-YYYY HH24:MI'),
repeat_interval => 'FREQ=DAILY',
end_date => null,
job_class => 'DEFAULT_JOB_CLASS',
enabled => false,
auto_drop => true,
comments => null
dbms_scheduler.set_job_argument_value(
job_name => 'AUTOIMPORT',
argument_position => 1,
argument_value => ''
dbms_scheduler.enable('AUTOIMPORT');
end;After the time specified I query user_scheduler_job_log. The Status column of the table says that the job failed. I think it has to do with the out parameter but I'm not sure.
Can anybody help with this?Hi
can anyone revert to this query pls? -
Calling a stored procedure with VARRAY as out parameter using JDBC
Hi,
I want to use the data type VARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
my java program using JDBC.
I'm using Oracle 8.1.5 for Windows NT.
Please help me.
Thanks
Sumanta
nullOriginally posted by JDBC Development Team:
It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
cstmt.execute ();
ARRAY array = (ARRAY) cstmt.getObject (idx);
Thanks for your reply.
I have to use:-
OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
( "{call proj_array(?)}" ) ;
for retrieving a collection as an OUT parameter.
This gives me the errors:-
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
How do I get rid of these errors?
null -
Reg: Need help to call a Stored Procedure - Out Parameter using DBAdapter
HI
I have created a procedure with Out Parameter, using DBAdapater i have invoked it. I have assigned the out parameter also. But while running i am getting this error.
My Procedure is shown below. It executes successfully when its run in database.
create or replace
PROCEDURE SP_QUERY(s_string in varchar2, retCodeString out varchar2)
AS
l_sql_stmt varchar2(1000);
BEGIN
l_sql_stmt := s_string;
EXECute immediate l_sql_stmt;
commit;
if SQLCODE = 0 then
retCodeString := 'OK';
end if;
END;
java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException:
Client received SOAP Fault from server : Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ExecuteScript' failed due to:
Stored procedure invocation error. Error while trying to prepare and execute the SOADEMO.SP_QUERY API.
An error occurred while preparing and executing the SOADEMO.SP_QUERY API.
Cause: java.sql.SQLException: ORA-06550: line 1, column 15:
PLS-00904: insufficient privilege to access object SOADEMO.SP_QUERY ORA-06550: line 1, column 7:
PL/SQL: Statement ignored Check to ensure that the API is defined in the database and that the parameters match the signature of the API.
This exception is considered not retriable, likely due to a modelling mistake.
To classify it as retriable instead add property nonRetriableErrorCodes with value "-6550" to your deployment descriptor (i.e. weblogic-ra.xml).
To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff.
All properties are integers. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:808) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:384)
Please help me in this issue.Hi
Right now i geeting the below error
java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : oracle.fabric.common.FabricException:
oracle.fabric.common.FabricInvocationException: java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist :
java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:808) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:384)
at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:301) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.
invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source) at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.
invoke(MethodExpressionMethodBinding.java:53) at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)
at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.
run(ContextSwitchingComponent.java:92) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96) at oracle.adf.view.rich.component.fragment.
UIXInclude.broadcast(UIXInclude.java:102) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361) at oracle.adf.view.rich.component.
fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96) at oracle.adf.view.rich.component.fragment.UIXInclude.
broadcast(UIXInclude.java:96) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475) at javax.faces.component.UIViewRoot.
processApplication(UIViewRoot.java:756) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:889) at
oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:379) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.
execute(LifecycleImpl.java:194) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.
StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.
invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.sysman.emSDK.license.LicenseFilter.doFilter(LicenseFilter.java:101) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446) at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emas.fwk.MASConnectionFilter.doFilter(MASConnectionFilter.java:41) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.AuditServletFilter.doFilter(AuditServletFilter.java:179) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.EMRepLoginFilter.doFilter(EMRepLoginFilter.java:203) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.core.model.targetauth.EMLangPrefFilter.doFilter(EMLangPrefFilter.java:158) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.core.app.perf.PerfFilter.doFilter(PerfFilter.java:141) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.ContextInitFilter.doFilter(ContextInitFilter.java:542) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442) at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103) at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171) at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:178) Caused by: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : oracle.fabric.common.FabricException: oracle.fabric.common.FabricInvocationException: java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist : java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:362) at oracle.sysman.emSDK.webservices.wsdlparser.OperationInfoImpl.invokeWithDispatch(OperationInfoImpl.java:1004) at oracle.sysman.emas.model.wsmgt.PortName.invokeOperation(PortName.java:750) at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:802) ... 79 more Caused by: oracle.j2ee.ws.client.jaxws.JRFSOAPFaultException: Client received SOAP Fault from server : oracle.fabric.common.FabricException: oracle.fabric.common.FabricInvocationException: java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist : java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist at oracle.j2ee.ws.client.jaxws.DispatchImpl.throwJAXWSSoapFaultException(DispatchImpl.java:1040) at oracle.j2ee.ws.client.jaxws.DispatchImpl.invoke(DispatchImpl.java:826) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.synchronousInvocationWithRetry(OracleDispatchImpl.java:235) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.invoke(OracleDispatchImpl.java:106) at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:358) ... 82 more -
Hi i want to use boolean type in a procedure as out parameter !!
Hi
I need to use Boolean type as out parameter in my procedure which return true if the SELECT query in procedure returns any row otherwise it should return false
please HELP !!I need to use Boolean type as out parameter in my procedure which return true if the SELECT query in procedure returns any row otherwise it should return false
Sounds like basic PL/SQL stuff.
What problem are you experiencing?
Are you looking for something like this?
create or replace procedure check_emp (p_empno in number, p_result out boolean) is
dummy pls_integer;
begin
select 1
into dummy
from scott.emp
where empno = p_empno;
p_result := true;
exception
when no_data_found then
p_result := false;
end;
SQL> declare
2 emp_exists boolean;
3 begin
4 check_emp(7839, emp_exists);
5 if emp_exists then
6 dbms_output.put_line('Employee exists');
7 else
8 dbms_output.put_line('Employee does not exist');
9 end if;
10 end;
11 /
Employee exists
PL/SQL procedure successfully completed -
How to declare procedure without using IN OUT parameter?
Hi:
I want to declare procedure without using IN OUT parameter.
My Script is:
DECLARE
procedure pro_bank_master() As
Declare
kr_bankid integer;
last_bank_id number(10,0);
CURSOR comp_cur IS select bank_id,date_created,created_by,modified_by,name_en from COM_BANK_MASTER ;
comp_rec comp_cur%ROWTYPE;
BEGIN
OPEN comp_cur;
FETCH comp_cur INTO comp_rec;
WHILE comp_cur%FOUND
LOOP
kr_bankid:= comp_rec.bank_id;
insert into crayom_db.C_Bank(ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, name, routingno, c_location_id, swiftcode, isownbank, description) values(11,11,'Y',sysdate,100,sysdate,11,comp_rec.name_en,'A',1000009,'A','Y','A');
select crayom_db.C_Bank.c_bank_id into last_bank_id from crayom_db.C_Bank where rownum=1 ORDER BY crayom_db.c_bank.c_bank_id DESC;
insert into crayom_db.CR_IdBackup values(kr_bankid, last_bank_id);
FETCH comp_cur INTO comp_rec;
End LOOP;
close comp_cur;
END;
BEGIN
pro_bank_master();
END;
The Error i am receiving is:
Error starting at line 1 in command:
DECLARE
procedure pro_bank_master() As
Declare
kr_bankid integer;
last_bank_id number(10,0);
CURSOR comp_cur IS select bank_id,date_created,created_by,modified_by,name_en from COM_BANK_MASTER ;
comp_rec comp_cur%ROWTYPE;
BEGIN
OPEN comp_cur;
FETCH comp_cur INTO comp_rec;
WHILE comp_cur%FOUND
LOOP
kr_bankid:= comp_rec.bank_id;
insert into crayom_db.C_Bank(ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, name, routingno, c_location_id, swiftcode, isownbank, description) values(11,11,'Y',sysdate,100,sysdate,11,comp_rec.name_en,'A',1000009,'A','Y','A');
select crayom_db.C_Bank.c_bank_id into last_bank_id from crayom_db.C_Bank where rownum=1 ORDER BY crayom_db.c_bank.c_bank_id DESC;
insert into crayom_db.CR_IdBackup values(kr_bankid, last_bank_id);
FETCH comp_cur INTO comp_rec;
End LOOP;
close comp_cur;
END;
BEGIN
pro_bank_master();
END;
Error report:
ORA-06550: line 8, column 27:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
<an identifier> <a double-quoted delimited-identifier>
current
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Can any Body Help Me?
Thank YouDECLARE
procedure pro_bank_master As --also you should remove brackets when you are not using any parameters
----Declare-- *( declare should not be present in procedure declaration )*
kr_bankid integer;
last_bank_id number(10,0);
CURSOR comp_cur IS select bank_id,date_created,created_by,modified_by,name_en from COM_BANK_MASTER ;
comp_rec comp_cur%ROWTYPE;
BEGIN
OPEN comp_cur;
FETCH comp_cur INTO comp_rec;
WHILE comp_cur%FOUND
LOOP
kr_bankid:= comp_rec.bank_id;
insert into crayom_db.C_Bank(ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, name, routingno, c_location_id, swiftcode, isownbank, description) values(11,11,'Y',sysdate,100,sysdate,11,comp_rec.name_en,'A',1000009,'A','Y','A');
select crayom_db.C_Bank.c_bank_id into last_bank_id from crayom_db.C_Bank where rownum=1 ORDER BY crayom_db.c_bank.c_bank_id DESC;
insert into crayom_db.CR_IdBackup values(kr_bankid, last_bank_id);
FETCH comp_cur INTO comp_rec;
End LOOP;
close comp_cur;
END;
BEGIN
pro_bank_master();
END;
Edited by: user11183973 on Sep 22, 2009 5:49 PM -
Using IN OUT parameter in procedures
Hello Experts ;
Good morning all;
i am trying to execute a program using procedure ( IN and IN OUT ) parameter.
i have a emp table i want to update perk column details.
>> Here is coding >>
1 create or replace procedure emp_salary
2 (id IN emp.eid%type , salary IN OUT emp.esalary%type) IS
3 tmp_sal number;
4 BEGIN
5 select esalary into tmp_sal from emp where eid=id;
6 if tmp_sal between 10000 and 20000 THEN
7 salary_inout := tmp_sal*1.2;
8 else if tmp_sal between 20001 and 29999 THEN
9 salary_inout := tmp_sal*1.8;
10 ELS IF tmp_sal > 30000 then
11 salary_inout := tmp_sal*2.0;
12* END;
SQL> /
Warning: Procedure created with compilation errors.
SQL> show errors;
Errors for PROCEDURE EMP_SALARY:
LINE/COL ERROR
10/5 PLS-00103: Encountered the symbol "IF" when expecting one of the
following: := . ( @ % ; The symbol ";" was substituted for "IF" to continue.
12/4 PLS-00103: Encountered the symbol ";" when expecting one of the
following: if
MY DB version is : 10.2.0.1
emp details :
SQL> select * from emp;
|EID | ENAME | EQUAL | ESALARY | ECITY | EPERK |
1 sona | mba | 10000 | ******** | |
2 maya | mca | 15000 | **********| |
3 sony | msc | 20000 | **** | |
4 King | m.s | 22000 | **********| |
5 ford | m.s | 40000 | **********| |
Thanks in advance ;Hello all ;
Thanks for all replies. I slightly modified my code because to understand without any doubt.
nothing , just removed salary_inout.
>> My table details >>
SQL> desc emp;
Name Null? Type
EID NUMBER
ENAME VARCHAR2(15)
EQUAL VARCHAR2(10)
ESALARY VARCHAR2(15)
ECITY VARCHAR2(15)
EPERK NUMBER
ECONTACT_NO NUMBER
>> Dummy Records >>
SQL> select * From emp;
EID ENAME EQUAL ESALARY ECITY EPERK
1 sona mba 10000 XXXXXX
2 maya mca 15000 XXXXXX
so , i want to create procedure to increment salary as per conditions.
SQL> create or replace procedure emp_salary
2 (id IN emp.eid%type ,
3 salary IN OUT emp.esalary%type ) IS
4 tmp_sal number;
5 BEGIN
6 select esalary into tmp_sal from emp where eid=id;
7 if tmp_sal between 10000 and 20000 THEN
8 salary := tmp_sal*1.2;
9 else if tmp_sal between 20001 and 29999 THEN
10 salary := tmp_sal*1.8;
11 ELSE IF tmp_sal > 30000 then
12 salary := tmp_sal*2.0;
13 END IF;
14 END IF;
15 END IF;
16 END;
17 /
Procedure created.
>> Here , i am getting error >>
SQL> execute emp_salary;
BEGIN emp_salary; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'EMP_SALARY'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
My DB version is : 10.2.0.1.0 on OEL 4.4 ( Personal database - for self studies).
I have some doubts please , please ......... clear my doubt !
1. when creating procedure for some columns from original table ,
- i always use following method .
local_vaibale_name <table_name>.<org_column_name>%type ; that is ,
id emp.eid%type; - then why i am getting error ?
Please find my error and help me to resolve it.
Thanks. -
Get more the one records in procedure by using out parameter
Hi good evening every body,
how to get more the one records in procedure by using out parameter ,
give me one example of it.
regards
subbaLike this ?
SQL> set serverout on
SQL> declare
2 v_empno dbms_sql.Number_Table;
3 v_ename dbms_sql.Varchar2_Table;
4 PROCEDURE P1(p_in_deptno IN emp.deptno%TYPE,
5 p1_out OUT dbms_sql.Number_Table,
6 p2_out OUT dbms_sql.Varchar2_Table) IS
7 BEGIN
8 SELECT empno, ename BULK COLLECT
9 INTO p1_out, p2_out
10 FROM emp
11 WHERE deptno = p_in_deptno;
12 END;
13 BEGIN
14 P1(20, v_empno, v_ename);
15 FOR i in 1 .. v_ename.COUNT LOOP
16 dbms_output.put_line(v_empno(i) || '--' || v_ename(i));
17 END LOOP;
18 END;
19 /
7369--SMITH
7566--JONES
7788--SCOTT
7876--ADAMS
7902--FORD
7941--ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAAA
7942--MY#@ ' "ABC
PL/SQL procedure successfully completed.
{code} -
Error while calling a stored procedure with OUT parameter.
Hi,
I am trying to call a Stored Procedure(SP) with an OUT parameter(Ref Cursor) from a third party tool. It is called using OLE-DB Data provider. In one database the procedure works fine but when I change the database the procedure call is giving following error.
Distribution Object: COM Error. COM Source: OraOLEDB. COM Error message: IDispatch error #3092. COM Description: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TEST1'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored.
I am not able to find as to why is this happening. Please let me know any clues /help to solve this problem.
Thanks in advance.If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.
-
With JDBC, calling a stored procedure with ARRAY as out parameter
Hi,
I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
my java program using JDBC.
The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
With this configuration I can get back a Cursor but not an Array.
Does it's possible ?
Thanks for your help !
MichaklOriginally posted by JDBC Development Team:
It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
cstmt.execute ();
ARRAY array = (ARRAY) cstmt.getObject (idx);
Thanks for your reply.
I have to use:-
OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
( "{call proj_array(?)}" ) ;
for retrieving a collection as an OUT parameter.
This gives me the errors:-
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
How do I get rid of these errors?
null -
Can we use OUT or IN OUT parameter mode in function?
Can we use OUT or IN OUT parameter mode in function & if YES then what's limitations?
hi,
Yes we can have OUT and IN OUT parameters for a function.
As per my knowledge there are no limitations , but as per the convention we will use OUT ,IN OUT Parameter modes for only procedures .
Thanks,
P Prakash -
Cannot get OUT parameter from stored procedure
Hi,
I am new to stored procedure programming. I wrote a simple java stored procedure as follows:
package fvt;
import java.sql.*;
import java.io.*;
public class FVTProcedures
extends COM.ibm.db2.app.StoredProc {
public void addRecord(int id, String name, int status)
throws SQLException {
java.sql.Statement stmt = null;
java.sql.Connection con = null;
PrintWriter pw = null;
try {
status =3;
pw = new PrintWriter(new FileWriter("c:/temp/fvtproc.txt"));
pw.println("starting...");
// get connection
con =getConnection();
pw.println("Got connection");
stmt = con.createStatement();
stmt.execute("INSERT INTO cmtest (id, name) values (" + id + ",'"+name+"')");
pw.println("Inserted the record");
if (!con.getAutoCommit()) {
con.commit();
pw.println("Committed the connection");
catch (SQLException sqle) {
pw.println(sqle.getMessage());
catch (Exception e) {
pw.println(e.getMessage());
finally {
status =2;
pw.close();
try {
if (stmt != null) {
stmt.close();
catch (SQLException sqle) {}
try {
if (con != null) {
con.close();
catch (SQLException sqle) {}
Then I use the following sql command to create this stored procedure, especially register status as OUT parameter.
CREATE PROCEDURE addRecord (IN id INT, IN name VARCHAR(20), OUT status INTEGER)
FENCED LANGUAGE JAVA EXTERNAL NAME 'fvt.FVTProcedures!addRecord' PARAMETER
STYLE DB2GENERAL
My java program calling this stored proc is as follows:
import java.sql.*;
import javax.sql.*;
public class CallableStmtTest {
COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource ds = null;
public static void main(String args[]) {
CallableStmtTest dt = new CallableStmtTest();
try {
dt.test();
} catch (Exception e) {
e.printStackTrace(System.out);
public CallableStmtTest() {
ds = new COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource();
ds.setUser("username");
ds.setPassword("password");
ds.setDatabaseName("database");
public void test() {
java.sql.Connection conn = null;
CallableStatement cs = null;
String sql = "CALL ADDRECORD(?, ?, ?)" ;
try {
conn = ds.getPooledConnection().getConnection();
conn.setAutoCommit(false);
System.out.println("Got the connection");
cs = conn.prepareCall( sql ) ; /* con is the connection */
System.out.println("Callable statement is prepared");
cs.registerOutParameter(3, java.sql.Types.INTEGER);
cs.setInt(1, 1001 );
cs.setString(2, "1001");
cs.execute() ;
System.out.println("Callable statement is executed, return status: "+cs.getInt(3));
conn.commit();
catch(SQLException sqle) {
sqle.printStackTrace();
finally {
try {
if (cs!=null) {cs.close();}
catch (SQLException sqle1) {
try {
if (conn!=null) {conn.close();}
catch (SQLException sqle1) {
However, the out put is always
Callable statement is executed, return status: 0
while i expect to be
Callable statement is executed, return status: 2
Can anyone tell me what's wrong with that?
thansk,
JSTpublic void addRecord(int id, String name, int status)
throws SQLException {
status =3;In regular java you are never going to see this value (3) outside of that method. Java doesn't work that way.
So unless java inside the DB works really differently from regular java, you are going to have to pass something else.
Maybe you are looking for
-
Dad's Macbook Pro (10.6.3, from 2010) had perfect wifi, he accidentally uninstalled(?) it somehow, has no idea how he did it. It said "no airport card installed" when I'd click the little wifi icon on the bar, or go into network settings. I have wipe
-
Can you transfer my purchases from itunes without having them on my ipod?
I lost my ipod, and had to get a new computer. So my itunes library was lost. I've made purchases through my itunes account and can't figure out how to get them on my new computer.....help!!
-
How do I scan for viruses on my iPad?
My iPad keeps turning off.
-
Can different Versions of LV coexist on a PC
I have LV6.1 Can I install LV8.0 on the same PC but still support all my legacy work on 6.1?
-
I have an old photoshop 6.0 it's ok with my old computer windows XP but, it's impossible to install on my new computer with Windows 7 64 bits. could you help me please.