How to call a oracle procedure with in/out parameter frm unix shell script?
Hi,
I need to call an oracle stored procedure from unix script. The procedure has 1 input parameter and 2 output parameter. Please send me the syntax for the same. Based on the output values of procedure, I have to execute some more commands in unix script.
Thanks and regards
A
An example :
TEST@db102 SQL> select ename, job from emp
2 where empno = 7902;
ENAME JOB
FORD ANALYST
TEST@db102 SQL> create or replace procedure show_emp (
2 v_empno in number,
3 v_ename out varchar2,
4 v_job out varchar2 )
5 is
6 begin
7 select ename, job into v_ename, v_job
8 from emp
9 where empno = v_empno;
10 end;
TEST@db102 SQL> /
Procedure created.
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ IN=7902
[ora102 work db102]$ set `sqlplus -s test/test@db102 << !
var out1 varchar2(30);
var out2 varchar2(30);
set pages 0
set feed off
exec show_emp($IN,:out1,:out2);
print
exit
`[ora102 work db102]$ echo $1 $2
FORD ANALYST
[ora102 work db102]$
Similar Messages
-
How to call a stored procedure which has out parameter value
my code is
public Connection createConnection() {
Connection conn = null;
try {
Class.forName(DRIVER);
conn = DriverManager.getConnection(URL,USER,PASS);
} catch (ClassNotFoundException cnfe) {
System.err.print("Class not found");
} catch (SQLException sqle) {
System.err.print("SQLException");
return conn;
public static void main(String args[]){
StroedProcedure stp = new StroedProcedure();
Connection con = stp.createConnection();
try {
CallableStatement stproc_stmt = con.prepareCall("{call Account_Summary(?,?,?,?,?,?,?,?)}");
stproc_stmt.setString(1, "123456");
stproc_stmt.setDate(2, null);
stproc_stmt.setString(3, null);
stproc_stmt.setString(4, null);
stproc_stmt.setString(5, null);
stproc_stmt.setString(6, null);
stproc_stmt.setDate(7, null);
stproc_stmt.setDate(8, null);
stproc_stmt.registerOutParameter(1,Types.CHAR);
stproc_stmt.registerOutParameter(2,Types.DATE);
stproc_stmt.registerOutParameter(3,Types.CHAR);
stproc_stmt.registerOutParameter(4,Types.CHAR);
stproc_stmt.registerOutParameter(5,Types.CHAR);
stproc_stmt.registerOutParameter(6,Types.CHAR);
stproc_stmt.registerOutParameter(7,Types.DATE);
stproc_stmt.registerOutParameter(8,Types.DATE);
stproc_stmt.execute();
System.out.println("test "+stproc_stmt.getString(1));
ResultSet rs = stproc_stmt.executeQuery();
while (rs.next()){
System.out.println("result "+rs.getString("ACCPK"));
} catch (SQLException e) {
e.printStackTrace();
}And the stored procedure is
CREATE OR REPLACE
procedure Account_Summary (accpk in out char, incdt out date, bcur out char, bmark out char, tarTE out char, numHold out char, stDt out date, AsDt out date)
is
begin
select account_pk, inception_date, base_currency, benchmark into accpk, incdt, bcur, bmark
from account a
where a.Account_pk=accpk;
select target_te, number_holdings, start_date, as_date into tarTE, numHold, StDt, AsDt
from acc_summary asum
where asum.account_pk=accpk;
end Account_Summary;but it gives a exception ORA-01460: unimplemented or unreasonable conversion requested
ORA-06512: at "REPRO.ACCOUNT_SUMMARY", line 4
ORA-06512: at line 1
i want to execute a stored procedure which has in , inout or out parameter
but it can not work========================
In some contects varchar2 variable limit is 32512 characters... October 16, 2003
Reviewer: Piotr Jarmuz from Poznan, Poland
Interesting to note is the fact that varchar2 variables as parameters to stored
procedures (in in/out out) may be "only" 32512 bytes long.
I've checked this in Java and Perl. 32512 is the last value that works, for any
bigger it throws:
Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or
unreasonable conversion requested
But in PL/SQL as you said 32767
Regards,
Piotr
=================================
This i got it from ask tom, well it make sense.... try checking your input with small numbers and strings
Have fun -
How to execute a stored procedure with an out parameter ?
Guys I am struggling with executing a stored procedure from sql plus.I mean my stored procedure has 2 input parameter and 1 out put parameter (status of the execution).
MY_PROCEDURE(p_name in varchar2,p_age in number,p_status out varchar2)
end my_procedure;
When I say
EXECUTE MY_PROCEDURE('manohar','Shetty');
i get insufficient parameters errors.
please help.EXECUTE isn't a valid PL/SQL construct. It's a SQL*Plus command. You don't want to put any SQL*Plus commands in a PL/SQL block.
You can always execute a stored procedure purely through PL/SQL
begin
my_stored_procedure( x, y, z );
end;SQL*Plus happens to give you the execute command so you can avoid the begin and end statements.
Justin -
How to call a Store Procedure with IN PARAMETER
Hi, im new using Oracle 10G with Oracle SQL Developer, my cuestion is how to call a Store Procedure with IN PARAMETER, I tried the following without results
SELECT * FROM procedure_name(parameter);
PROCEDURE procedure_name(parameter);
EXEC procedure_name(parameter);
CALL procedure_name(parameter);
Please help me....Hi,
As Beijing said,
EXEC procedure_name(parameter);
CALL procedure_name(parameter);work for me.
So does
BEGIN
procedure_name(parameter);
END;Can you be more specific about what you're doing? That is, are you testing it in SQL Developer? Where are you entering the commands? Where are you looking for output? Do you get error messages? Does anything else (like "SELECT SYSDATE FROM dual;") work? -
Calling Oracle procedure with two OUT parameters
Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
proc_Test (p_resultset=> My_cursor)
How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
Thanks in advYes its possible to use multiple parameter as OUT type in procedure.
SQL>set serveroutput on size 1000000;
SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
2 BEGIN
3 OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
4 p_num := 1;
5 END;
6 /
Procedure created.
SQL>VAR cv REFCURSOR;
SQL>VAR num NUMBER;
SQL>EXEC myproc(:cv, :num);
PL/SQL procedure successfully completed.
SQL>PRINT cv;
SAYHELLO
Hello Oracle
SQL>PRINT num;
NUM
1
SQL>
{code} -
How to call an Oracle Procedure and get a return value in Php
Hi Everyone,
Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return value ? I need to use the ora funtions (no oci)because of compatibility and oracle 7.x as the database.
The reason why I post this here is because the ora_exec funtion is returning FALSE but the error code displayes is good. Is this a bug in the ora_exec funtion ?
My code after the connection call is as follows:
$cur = ora_open($this->conn);
ora_commitoff($this->conn);
$requestid = '144937';
echo $requestid;
$rc = ora_parse($cur, "begin p_ins_gsdata2
(:requestid, :returnval); end;");
if ($rc == true) {
echo " Parse was successful ";
$rc2 = ora_bind ($cur, "requestid", ":requestid", 32, 1);
if ($rc2 == true) echo " Requestid Bind Successful ";
$rc3 = ora_bind ($cur, "returnval", ":returnval", 32, 2);
if ($rc3 == true) echo " Returnval Bind Successful ";
$returnval = "0";
$rc4 = ora_exec($cur);
echo " Result = ".$returnval." ";
if ($rc4 == false) {
echo " Exec Returned FALSE ";
echo " Error = ".ora_error($cur);
echo " ";
echo "ErrorCode = ".ora_errorcode($cur);
echo "Error Executing";
ora_close ($cur);
The Oracle procedure has a select count from a table and it returns the number of records in that table. It's defined as:
CREATE OR REPLACE procedure p_ins_gsdata2 (
p_requestid IN varchar2 default null,
p_retcode OUT varchar2)
as
BEGIN
SELECT COUNT (*) INTO p_retcode
FROM S_GSMRY_DATA_SURVEY
WHERE request_id = p_requestid ;
COMMIT;
RETURN;
END;
Nothing much there. I want to do an insert into a table,
from the procedure later, but I figured that I start with a select count since it's simpler.
When I ran the Php code, I get the following:
144937
Parse was successful
Requestid Bind Successful
Returnval Bind Successful
Result = 0
Exec Returned FALSE
Error = ORA-00000: normal, successful completion -- while
processing OCI function OBNDRA
ErrorCode = 0
Error Executing
I listed the messages on separate lines for clarity. I don't understand why it parses and binds o.k. but the exec returns false.
Thanks again in advance for your help. Have a great day.
Regards,
Rudiretcode=`echo $?`is a bit convoluted. Just use:
retcode=$?I see no EOF line terminating your input. Your flavour of Unix might not like that - it might ignore the command, though I'd be surprised (AIX doesn't).
replace the EXEC line with :
select 'hello' from dual;
and see if you get some output - then you know if sqlplus commands are being called from your script. You didn't mentioned whether you see the banner for sqlplus. Copy/paste the output that you get, it will give us much more of an idea. -
How to call a Stored Procedure with a REF CURSOR output parameter
I am looking forward an example that call a stored function/procedure with a REF CURSOR output parameter and get the result.
In other words, I have a stored function/procedure that execute a SELECT statement using the OCI library and then it could get the values of each column and each row.
I put a code snippet, it have only the main thing to call a simple stored procedure and print the name of each column of the cursor, but I couldn´t to print out the values in the table that call the stored procedure.
I understand that the next step, it is to call a OCIStmtFetch.
How to associate the cursor with the OCIStmtFetch?
If you need more information, only tell me.
I am using ANSI C with HP-UX Operative System (C for HP-UX) and Oracle 10g.
Regards.
Antonio Garcia
/* callOracleSP */
#include <stdio.h>
#include <string.h>
#include <oci.h>
#include <stdlib.h>
char* pConnectChar ="server";
char* pUsernameChar = "user";
char* pPasswordChar = "passwd";
char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
int retval;
ub4 parmcnt=0;
ub4 pos2=0;
text *pcoln[20];
ub4 namelen[20];
char state_key[5];
OCIStmt* pOciStatement;
OCIStmt* pOciStatCursor;
OCIError* pOciError;
OCIEnv* pOciEnviron;
OCIServer* pOciServer;
OCISession* pOciSession;
OCISvcCtx* pOciServiceContext;
OCIBind* pOciBind[500];
OCIParam* pOciParam;
int main()
retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
(unsigned char *)pConnectChar,strlen(pConnectChar));
printf("OCILogon retval=%d\n",retval);
retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
OCI_NTV_SYNTAX, OCI_DEFAULT);
printf("StmtPrepare retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
(sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
(sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
strcpy(state_key,"CA");
retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
(OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
printf("StmtExecute retval=%d\n",retval);
/* How to get the values of the cursor? */
/* Get number of parameters of the Cursor */
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
(ub4)OCI_ATTR_PARAM_COUNT, pOciError);
printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
for (int pos = 1; pos <= (int)parmcnt; pos++)
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
(ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,
(ub4) pos );
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &pcoln[pos-1],(ub4 *) &namelen[pos-1],
(ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
for (int i = 1; i <=(int)parmcnt; i++)
printf("Column %i\tNAME = %.*s\n",i,namelen[i-1],pcoln[i-1]);
return 0;
This is the script that create the table, insert records and create the stored procedure
CREATE TABLE CITIES (
STATE_CODE VARCHAR2(2) NULL,
CITY_CODE NUMBER(15,5) NULL,
CITY_NAME VARCHAR2(30) NULL
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 30, 'SAN DIEGO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 40, 'SACRAMENTO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('FL', 10, 'MIAMI')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('FL', 20, 'ORLANDO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('NY', 10, 'NEW YORK')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('NY', 20, 'ALBANY')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 10, 'LOS ANGELES')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 20, 'SAN FRANCISCO')
CREATE OR REPLACE PACKAGE globalPkg AUTHID CURRENT_USER AS
/* The following are T/SQL specific global variables. */
TYPE RCT1 IS REF CURSOR;/*new weak cursor definition*/
END globalPkg;
CREATE OR REPLACE PROCEDURE SP_ADDCITY(
P_STATE_CODE IN VARCHAR,
P_CITY_CODE IN NUMBER,
P_CITY_NAME IN VARCHAR2,
P_RETURN IN OUT NUMBER)
AS
StoO_error INTEGER;
StoO_selcnt INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
BEGIN
StoO_rowcnt := 0;
StoO_error := 0;
StoO_selcnt := 0;
P_RETURN := 0;
INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
VALUES (P_STATE_CODE, P_CITY_CODE, P_CITY_NAME);
StoO_rowcnt := SQL%ROWCOUNT;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
StoO_rowcnt := 2;
WHEN OTHERS THEN
StoO_rowcnt := 0;
StoO_selcnt := 0;
StoO_error := SQLCODE;
StoO_errmsg := SQLERRM;
IF StoO_error != 0 THEN
BEGIN
P_RETURN := 1;
RETURN;
END;
END IF;
END;
CREATE OR REPLACE PROCEDURE SP_GETCITIES(
STATE_KEY IN VARCHAR,
RC1 IN OUT globalPkg.RCT1)
AS
StoO_error INTEGER;
StoO_selcnt INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
BEGIN
StoO_rowcnt := 0;
StoO_error := 0;
StoO_selcnt := 0;
OPEN RC1 FOR
SELECT STATE_CODE, CITY_CODE, CITY_NAME
FROM CITIES
WHERE STATE_CODE = STATE_KEY
ORDER BY CITY_CODE;
StoO_rowcnt := SQL%ROWCOUNT;
EXCEPTION
WHEN OTHERS THEN
StoO_rowcnt := 0;
StoO_error := SQLCODE;
StoO_errmsg := SQLERRM;
END;
/Hi Mark,
Thanks for your recommendations.
I change the code with OCIDefineByPos, one for each parameter from cursor and then use the OCIStmtFetch.
I don´t receive a error when call OCIDefineByPos, but when I call OCIStmtFetch receive a -1 error number.
What is wrong with the code?
The script is the same.
I need your help!
Best Regards!
Antonio Garcia (Mexico)
This the new code:
#include <stdio.h>
#include <string.h>
#include <oci.h>
#include <stdlib.h>
char* pConnectChar ="ORAC617";
char* pUsernameChar = "C617_005_DBO_01";
char* pPasswordChar = "Tempora1";
char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
int retval;
ub4 parmcnt=0;
ub4 pos2=0;
sb2 *c_indp;
text *pcoln[20], *name,*name2;
ub4 namelen[20],len;
ub2 type,size;
char state_key[5];
OCIDefine *pdef;
OCIBind *p_bnd;
ub1 **c_buf;
OCIStmt* pOciStatement; /* Statement handle */
OCIStmt* pOciStatCursor; /* Statement handle */
OCIError* pOciError; /* Error handle */
OCIEnv* pOciEnviron; /* Environment handle */
OCIServer* pOciServer; /* Server handle */
OCISession* pOciSession; /* Session handle */
OCISvcCtx* pOciServiceContext; /* Service Context handle */
OCIBind* pOciBind[500]; /* Bind handle */
OCIParam* pOciParam; /* Param handle */
int OCI_Fetch(OCIStmt *p_select,OCIError *p_err, int *piOcc)
int iOcc, rc;
rc=OCIStmtFetch(p_select,p_err,1,OCI_FETCH_NEXT,OCI_DEFAULT);
printf("rc fetch %i",rc);
if(rc==0&&piOcc!=NULL){
printf("entro al if");
iOcc=*piOcc;
*piOcc=iOcc+1;
return rc;
int main()
int pos,i=0,rc;
retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
printf("EnvCreate retval=%d\n", retval);
retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
printf("EnvInit retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
printf("HandleAlloc OCI_HTYPE_ERROR retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
printf("HandleAlloc OCI_HTYPE_SVCCTX retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
(unsigned char *)pConnectChar,strlen(pConnectChar));
printf("OCILogon retval=%d\n",retval);
retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
OCI_NTV_SYNTAX, OCI_DEFAULT);
printf("StmtPrepare retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
(sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
(sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
strcpy(state_key,"CA");
retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
(OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
printf("StmtExecute retval=%d\n",retval);
c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
c_indp=(sb2 *)calloc(sizeof(sb2 *),3);
// Get number of parameters of the Cursor
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
(ub4)OCI_ATTR_PARAM_COUNT, pOciError);
printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
for (pos = 1; pos <= (int)parmcnt; pos++)
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
(ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,(ub4) pos );
// Get the column name
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &name,(ub4 *) &len, (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
// Get the column datatype
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &type,(ub4 *)0,(ub4)OCI_ATTR_DATA_TYPE,(OCIError *)pOciError);
// Get the column size
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &size,(ub4 *)0,(ub4)OCI_ATTR_DATA_SIZE,(OCIError *)pOciError);
printf("Column %i\tNAME = %.*s \ttype %d \tsize %d\n",pos,len,name,type,size);
// OCIDefine ByPos, one for each parameter
// c_buf store the STATE_CODE, CITY_CODE and CITY_NAME columns from the cursor
rc=OCIDefineByPos(pOciStatCursor,&pdef,(OCIError *)pOciError,pos,c_buf[pos-1],size+1,(ub2)type,(dvoid *)c_indp[pos-1],(ub2 *)0,(ub2 *)0,OCI_DEFAULT);
printf("OCIDefineByPos retval=%d\n,rc);
// call OCIStmtFetch. In the next line, I receive the error
rc=OCIStmtFetch(pOciStatCursor,pOciError,1,OCI_FETCH_NEXT,OCI_DEFAULT);
printf("rc fetch %i",rc);
return 0;
{code} -
How to call a stored procedure with only one output parameter using toplink
Can anybody help me to get out of this exception. I have tried through several ways, but could not find the solution.
I have a following stored proc : -
CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT VARCHAR2)
IS
buff VARCHAR2(32000) := ' ';
BEGIN
buff := ' Hi From Stored Proc' ;
outbuffer : = buff;
END;
When I am executing it using following code :-
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("spt_remove_duplicates_pr");
call.addNamedOutputArgument("a","a",String.class);
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
String buff1 = (String) session.executeQuery(query);
I am getting the exception as : -
LOCAL EXCEPTION STACK:
EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.4 (Build 432)): oracle.toplink.exceptions.DatabaseException
EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
INTERNAL EXCEPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ERROR CODE: 6550
at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)
INTERNAL EXCEPTION STACK:
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1141)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2149)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2032)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2894)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)I got the partial solution. The code is working now, however I am not getting the return value from stored proc.
The changed code is as :-
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("spt_remove_duplicates_pr");
call.addNamedOutputArgument("outbuffer","outbuffer",StringBuffer.class);
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
StringBuffer buff1 = (StringBuffer) session.executeQuery(query);
System.err.println("Done ! Output is : " + buff1);
The result is :-
Done ! Output is : null
How can I get the output ? -
How to call a procedure with SYS_REFCURSOR OUT parameter
Hi,
Using Oracle 11g R2.
I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor)
as
begin
open result for
select 1 from dual
union all
select 2 from dual;
end;
I'd like to call this procedure similar to the way a query is called and executed. Like this
select * from testprocedure
I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
No - you can only use schema object types (SQL) in SQL queries and only then if you call a function.
The function can return a SQL collection type or it can be a PIPELINED function whose return value is a SQL collection type. Either way your query will use the TABLE function and be of the form:
select * from TABLE(testfunction);
This is sample code for a PIPELINED function based on the SCOTT.EMP table. The function takes a department number parameter and returns the EMP rows for that department:
-- type to match emp record
create or replace type emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
return emp_table_type
PIPELINED
as
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
emp_cv EmpCurTyp;
l_rec emp%rowtype;
begin
open emp_cv for select * from emp where deptno = p_deptno;
loop
fetch emp_cv into l_rec;
exit when (emp_cv%notfound);
pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
end loop;
return;
end;
select * from table(get_emp(20)) -
Errer when, Call from java to pl sql procedure with table out parameter
Hi ,
Please help me ? It's urgent for me .....
My Oracle Code is like this ,
CREATE TABLE TEST_TABLE ( DATE1 DATE, VALUE_EXAMPLE VARCHAR2(20 BYTE), VALUE2_EXAMPLE VARCHAR2(20 BYTE), VALUE3_EXAMPLE NUMBER ); CREATE OR REPLACE TYPE TONERECORDTEST AS OBJECT ( DATE1 DATE, VALUE_EXAMPLE VARCHAR2(20), VALUE2_EXAMPLE VARCHAR2(20), VALUE3_EXAMPLE NUMBER ); CREATE OR REPLACE TYPE TTESTTABLE IS TABLE OF TONERECORDTEST; CREATE OR REPLACE PACKAGE test_collection_procedures AS PROCEDURE testCallProcedureFromJava(start_time IN DATE, end_time IN DATE, table_data OUT TTesttable); END test_collection_procedures; / CREATE OR REPLACE PACKAGE BODY test_collection_procedures AS PROCEDURE testCallProcedureFromJava(start_time IN DATE, end_time IN DATE, table_data OUT TTesttable) IS BEGIN SELECT TONERECORDTEST(date1, value_example, value2_example, value3_example) BULK COLLECT INTO table_data FROM TEST_TABLE WHERE DATE1>=start_time AND DATE1<=end_time; END testCallProcedureFromJava; END test_collection_procedures;
And my Java Code is like
import java.sql.Connection; import java.sql.DriverManager; import oracle.jdbc.OracleCallableStatement; import oracle.jdbc.OracleTypes; import oracle.sql.ARRAY; import oracle.sql.ArrayDescriptor; import oracle.sql.STRUCT; import oracle.sql.StructDescriptor; public class testPLCollectionType { public static void main(java.lang.String[] args) { try{ //Load the driver Class.forName ("oracle.jdbc.driver.OracleDriver"); // Connect to the database Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@serverbd:1521:squema1","user", "password"); // First, declare the Object arrays that will store the data (for TONERECORDTEST OBJECT TYPE) Object [] p2recobj; Object [] p3recobj; Object [] p4recobj; // Declare the Object Arrays to hold the STRUCTS (for TTESTTABLE TYPE) Object [] p2arrobj; // Declare two descriptors, one for the ARRAY TYPE // and one for the OBJECT TYPE. StructDescriptor desc1=StructDescriptor.createDescriptor("TONERECORDTEST",conn); ArrayDescriptor desc2=ArrayDescriptor.createDescriptor("TTESTTABLE",conn); // Set up the ARRAY object. ARRAY p2arr; // Declare the callable statement. // This must be of type OracleCallableStatement. OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall("{call test_collection_procedures.testCallProcedureFromJa va(?,?,?)}"); // Declare IN parameters. Realize that are 2 DATE TYPE!!! Maybe your could change with setDATE ocs.setString(1,"01-JAN-04"); ocs.setString(2,"10-JAN-05"); // Register OUT parameter ocs.registerOutParameter(3,OracleTypes.ARRAY,"TTESTTABLE"); // Execute the procedure ocs.execute(); // Associate the returned arrays with the ARRAY objects. p2arr = ocs.getARRAY(3); // Get the data back into the data arrays. //p1arrobj = (Object [])p1arr.getArray(); p2arrobj = (Object [])p2arr.getArray(); System.out.println("Number of rows="+p2arrobj.length); System.out.println("Printing results..."); for (int i=0; i<p2arrobj.length; i++){ Object [] piarrobj = ((STRUCT)p2arrobj).getAttributes();
System.out.println();
System.out.print("Row "+i);
for (int j=0; j<4; j++){
System.out.print("|"+piarrobj[j]);
}catch (Exception ex){
System.out.println("Exception-->"+ex.getMessage());
Actually when i running the java program it is showing error
Exception-->ORA-06550: line 1, column 58:
PLS-00103: Encountered the symbol "VA" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "VA" to continue.
I am not getting the error .Please help me out Dhabas Edited by: Dhabas on Jan 12, 2009 3:49 PM// Declare the callable statement.
// This must be of type OracleCallableStatement.
..."{call test_collection_procedures.testCallProcedureFromJa va(?,?,?)}");Looks like Ja divorced va. -
Calling a stored procedure with an XmlType parameter.
I am attempting to execute a stored function via a named query. The stored procedure has a single parameter of Oracles 'xmltype', and also returns an xmltype. For example this dummy function
function testXML(xml_in xmltype) return xmltype is
begin
return xml_in;
end;
Is it possible to make the named query call with an oracle.xdb.XMLType or oracle.xdb.dom.XDBDocument? I cannot find any examples of this being done. I also want the returning xmltype to be converted into a Java class.
Another question - will I need to work with a conversion manager to achieve this?Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Invalid column typeError Code: 17004
Call:BEGIN ? := TestPackage.testXML(XML_IN=>?); END;
bind => [=> RESULT, oracle.xml.parser.v2.XMLDocument@1a64732 => XML_IN]
Query:DataReadQuery()
at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:290)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:570)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:442)
at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:453)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:117)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:103)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:174)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:156)
at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(DataReadQuery.java:118)
at oracle.toplink.queryframework.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:110)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:603) -
How to exec. stored procedure having out parameter value in shell script ?
Hi Gurus,
I am writing a shell script which is calling a SP having out parameter as varchar2.
So how can i do this in shell scripting ? (I am a new in shell scripting)
a simple example is preferred.
Thanks
SandySo how can i do this in shell scripting ? Assuming you want to assign the out parameter value to a shell variable, here's a small example :
SQL> select ename from emp where empno=7902;
ENAME
FORD
SQL> create or replace procedure show_name (
2 v_empno in number,
3 v_ename out varchar2)
4 is
5 begin
6 select ename into v_ename from emp
7 where empno = v_empno;
8 end;
SQL> /
Procedure created.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
$ cat show_name.sh
ENAME=`sqlplus -s test/test << EOF
set pages 0
set feed off
var V1 varchar2(30);
exec show_name($1, :V1);
print V1
exit
EOF`
echo $ENAME
$ ./show_name.sh 7902
FORD
$ -
ORABPEL-11809 - call a stored procedure - error in OUT parameter
Hi all.
I have a problem in a BPEL process that calls a stored procedure.
I create a Partner Link that calls a stored procedure in the database. That procedure returns a type that is a table (is defined as a type of the database).
When I deploy the process I have the following error:
<messages>
- <input>
- <WC01_Pesquisa_Ut_InputVariable>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
- <InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/">
<P_NIR xmlns="">
165968274
</P_NIR>
<P_NOME_COMPLETO xmlns="">
carla diogo
</P_NOME_COMPLETO>
<P_SEXO xmlns="">
Feminino
</P_SEXO>
<P_DATA_NASC xmlns="">
2007-03-01
</P_DATA_NASC>
<P_NATURALIDADE xmlns=""/>
</InputParameters>
</part>
</WC01_Pesquisa_Ut_InputVariable>
</input>
- <fault>
- <remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
- <part name="code">
<code>
17002
</code>
</part>
- <part name="summary">
<summary>
file:/oracle/product/10.1.3/SOA/Integration10131/bpel/domains/default/tmp/.bpel_SaudeIdentificarCidadao_5.0_e3768f57d137443e1ba52d4a6d809426.tmp/WC01_Pesquisa_Ut.wsdl [ WC01_Pesquisa_Ut_ptt::WC01_Pesquisa_Ut(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'WC01_Pesquisa_Ut' failed due to: Error registering an out parameter.
An error occurred when registering parameter PESQUISA_UT as an out parameter of the IGIF.WC01.PESQUISA_UT API. Cause: java.sql.SQLException: Io exception: Connection reset [Caused by: Io exception: Connection reset]
; nested exception is:
ORABPEL-11809
Error registering an out parameter.
An error occurred when registering parameter PESQUISA_UT as an out parameter of the IGIF.WC01.PESQUISA_UT API. Cause: java.sql.SQLException: Io exception: Connection reset [Caused by: Io exception: Connection reset]
Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. Contact oracle support if error is not fixable.
</summary>
</part>
- <part name="detail">
<detail>
Internal Exception: java.sql.SQLException: Io exception: Connection resetError Code: 17002
</detail>
</part>
</remoteFault>
</fault>
</messages>
The code of the XSD created when I create the partner link is:
<schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/"
elementFormDefault="unqualified" attributeFormDefault="unqualified">
<element name="InputParameters">
<complexType>
<sequence>
<element name="P_NIR" type="decimal" db:index="1" db:type="NUMBER" minOccurs="0" nillable="true"/>
<element name="P_NOME_COMPLETO" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
<element name="P_SEXO" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
<element name="P_DATA_NASC" type="dateTime" db:index="4" db:type="DATE" minOccurs="0" nillable="true"/>
<element name="P_NATURALIDADE" type="string" db:index="5" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<element name="OutputParameters">
<complexType>
<sequence>
<element name="PESQUISA_UT" type="db:TABELA_DE_IDS" db:index="0" db:type="Array" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="TABELA_DE_IDS">
<sequence>
<element name="PESQUISA_UT_ITEM" type="decimal" db:type="NUMBER" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
</schema>
Any ideia?
Thanks in advance.
CarlaI'd suggest that you turn on xml validation on the bpel boundaries to make sure that the xml being passed to the adapter is valid. You do this by logging in to bpel console, go to Manage Domain, at the bottom of the Configuration tab, set validateXml to true.
Then see if it is an xml validation issue - in which case you will have to fix your maps to make sure it is valid indeed.
Assuming your XML is valid and you are still seeing this error, couple of follow up questions:
- are you using synonyms ?
-- note that synonyms are not supported completely by the adapter at this time.
- could you spell out where your types/sp-pkg resides and what are you connecting as at runtime ?
-- just to keep things simple enough to debug, i'd do everything as just one user and slowly go to a scheme that you desire.
HTH -
Stored Procedure with in out parameter of table of records type
Hi
I am tring to create a strore procedure inside a package like this:
procedure name_p(root in table.column%type, tab in out table_of_records_type);
I get the error:
PLS-00306: Wrong number or types of arguments in call to 'name_p'
I am working with oracle 8.1.7.
I dont really understand why this is happening.
Can anyone suggest anything.
Thnx
EdAn example :
TEST@db102 SQL> select ename, job from emp
2 where empno = 7902;
ENAME JOB
FORD ANALYST
TEST@db102 SQL> create or replace procedure show_emp (
2 v_empno in number,
3 v_ename out varchar2,
4 v_job out varchar2 )
5 is
6 begin
7 select ename, job into v_ename, v_job
8 from emp
9 where empno = v_empno;
10 end;
TEST@db102 SQL> /
Procedure created.
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ IN=7902
[ora102 work db102]$ set `sqlplus -s test/test@db102 << !
var out1 varchar2(30);
var out2 varchar2(30);
set pages 0
set feed off
exec show_emp($IN,:out1,:out2);
print
exit
`[ora102 work db102]$ echo $1 $2
FORD ANALYST
[ora102 work db102]$ -
Please help to call oracle procedure with out paramter from shell script
Hi
I want to call a process with out parameter from shell script. I am calling process in shell script in below way
function Process_loads {
( echo 'set serveroutput on size 1000000 arraysize 1'
echo "set pagesize 0 term on verify off feedback off echo off"
echo "BEGIN"
echo " dbms_output.put_line('Before Calling The package'); "
echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
echo " dbms_output.put_line('After Calling The package'); "
echo "EXCEPTION "
echo " WHEN OTHERS THEN "
echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
echo " ROLLBACK;"
echo "END;"
echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
Here $error_code is out paramter. All varaibles passed in process are declared with export command.
When executing .sh it gives below error
"sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
Thanks in advanceYou can try this:
From sql*plus
SQL> ed
1 create or replace procedure my_proc(p_id in int, p_result out int)
2 as
3 begin
4 select 10 * p_id
5 into p_result
6 from dual;
7* end my_proc;
SQL> /
Procedure created.
SQL> set serveroutput on
SQL> declare
2 v_r int;
3 begin
4 my_proc(10,v_r);
5 dbms_output.put_line(v_r);
6 end;
7 /
100
PL/SQL procedure successfully completed.
from bash:
testproc.sh:
#!/bin/bash
(echo 'set serveroutput on';
echo 'declare';
echo 'v_r int;';
echo 'begin';
echo 'my_proc(10,v_r);';
echo 'dbms_output.put_line(v_r);'
echo 'end;';
echo '/';) | sqlplus -s u1/u1
Console:
oracle@mob-ubuntu:~$ chmod u+x testproc.sh
oracle@mob-ubuntu:~$ ./testproc.sh
100
PL/SQL procedure successfully completed.With kind regards
Krystian Zieja
Maybe you are looking for
-
Want to add company logo in sharepoint site 2013 login page..
hi, I am trying to setup a customize SharePoint login page with company logo, while searching I found that it requires FBA authentication enabled which I did. now I have challenge, how to add company logo in SharePoint login page so while heats to si
-
OfficeJet all-in-one J6400 Not receiving incoming FAX
Hello, I have OfficeJet J6400 all in one in my office. I'm not receiving faxes from anywhere-- companies, from my home. Strangely, the only fax I receive is the Fax Test reply from HP when I do the 877-HP-FAXME test. I've tried the setup in all
-
ITunes doesn't allow me to put music in my iPhone 5
Hi. I have realized, that my iTunes doesn't introduce the music I select into my iPhone5. Kind of weird. If I choose just a few songs (5,10) they go in. But if I select a vast amount of them (400+) they just stay with this sign and sometimes with gre
-
Ora-03113 error in version 8.0.5
kindly guide me through the procedure to solve ora-03113 error "end of file on communication channel" in database version 8.0.5
-
Using USEREXIT_FIELD_MODIFICATION
Hello SDNites, Please tell me how to insert code in USEREXIT_FIELD_MODIFICATION and also tell me whether this exit is applicated for Sales Order transaction or can be used with Purchase Order or not? Please provide me steps for writing the code in US