Call a procedure stored via JDBC with a REF CURSOR * input variable.
Hello
S/n of my client has provided me with a stored procedure that I need to call to get information about products prices. Something along the lines of:
some_package.getPrices (products IN OUT csr_type);
where csr_type represents a REF CURSOR. This cursor has a product ID column and a price column. The plan is to move the cursor with the populated product id column and have the routine decorate the slider with the prices.
The setting in this plan is that it seems that it is not possible to go from JDBC REF CURSOR in . However, I'm not sure, since I can only find throw comments on various forums (e.g. http://www.orafaq.com/forum/t/35088/0/), without any reference. If I go back to the client and tell them that their idea will not work, I prefer to be able to point them to a documentation somewhere
So I guess my questions are:
1. it is indeed impossible to pass a REF CURSOR type as a variable input on JDBC to a stored procedure?
2. is there information I can do about my client?
3. am I on the right track thinking I need to go down the path of an array of objects?
Thank you very much to anyone who can help
Peter Svehla.
Hi Peter,.
I see it, missed that you actually want to pass in a list of products. Don't think that you can do this with the current procedure. A slider is just a pointer to a result set.
How the result set is created and what it looks like, is determined when the cursor is opened.
What does this procedure with the cursor? -It does not have some OPEN
Or, perhaps, you are supposed to send in an open cursor (does not much sense to me)? Concerning
Peter
Tags: Oracle
Similar Questions
-
How to call a stored procedure with a REF CURSOR output parameter
I'm looking forward to example calling a function/stored procedure with a REF CURSOR output parameter and get the result.
In other words, I have a stored function/procedure that runs a SELECT statement using the OCI library and then he could get the values of each row and each column.
I put a code snippet, it have only the main thing to call a simple stored procedure and to print the name of each column of the cursor, but I couldn t to print out values in the table that calls the stored procedure.
I understand that the next step is to call an OCIStmtFetch.
How to associate the slider with the OCIStmtFetch?
If you need more information, just tell me.
I use ANSI C with HP - UX (HP - UX C) operating system and Oracle 10 g.
Kind regards.
Antonio Garcia
/ * callOracleSP * /.
#include < stdio.h >
#include < string.h >
#include < oci.h >
#include < stdlib.h > to
char * pConnectChar = "Server";
char * pUsernameChar = "user";
char * pPasswordChar = "passwd";
char * sqlCharArray1 = "BEGIN SP_GETCITIES (:,: 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 ("retval=%d\n",retval OCILogon);
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 = 1 OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4), (void *) & state_key,)
((sb4) sizeof (state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT (ub4));
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, OCI_DEFAULT (ub4));
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, OCI_DEFAULT (ub4));
printf ("StmtExecute retval=%d\n",retval);
/ * How to get the values of the cursor? */
/ * Number of parameters of the cursor * /.
OCIAttrGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), (void *) & parmcnt,(ub4 *) 0,)
(ub4) (OCI_ATTR_PARAM_COUNT, pOciError);
printf ("\nNumber of the slider settings = %d\n",parmcnt);
for (int pos = 1; pos < = (int) parmcnt; pos ++)
{
OCIAttrGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), (void *) & pos2,(ub4 *) 0,)
(ub4) (OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), pOciError, (void *) & pOciParam,)
POS (ub4));
OCIAttrGet pOciParam, (ub4) ((void*) 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 ("%i\tNAME = % column. ("* 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 ('NEW YORK', 10, 'NEW YORK')
/
INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
VALUES ('NEW YORK', 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 is specific global variables T/SQL. */
TYPE RCT1 IS REF CURSOR; / * new cursor low definition * /.
END globalPkg;
/
CREATE OR REPLACE PROCEDURE SP_ADDCITY)
P_STATE_CODE IN VARCHAR,
P_CITY_CODE NUMBER,
P_CITY_NAME IN VARCHAR2,
P_RETURN IN NUMBERS)
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: = number of LINES SQL %;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
StoO_rowcnt: = 2;
WHILE 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 FOR RC1
SELECT STATE_CODE, CITY_CODE, FRANCISCO
CITIES
WHERE STATE_CODE = STATE_KEY
ORDER BY CITY_CODE;
StoO_rowcnt: = number of LINES SQL %;
EXCEPTION
WHILE OTHERS THEN
StoO_rowcnt: = 0;
StoO_error: = SQLCODE;
StoO_errmsg: = SQLERRM;
END;
/Hi Antonio,.
I see this:
c_buf=(ub1 **)calloc(sizeof(ub1 *),3); ... 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);
That I don't understand. You allocate space for 3 pointers ub1 but I don't see where these pointers are then initialized to point to where the data is to be stored.
I do not read correctly?
Sorry for posting code long, but here is an example of code that I have. It is much more 'code' for your code, but maybe that will be enough...
NOTE: This is just the code example and not rigorous. For example, I don't check the memory, allocations etc in this code!
Kind regards
Mark
#ifdef WIN32 #define _CRT_SECURE_NO_DEPRECATE 1 #endif #include
#include #include #include void checkerr(sword status, OCIError *errhp); int main(int argc, char *argv[]) { OCIEnv *envhp = NULL; /* OCI Environment handle */ OCIError *errhp = NULL; /* OCI Error handle */ OCISvcCtx *svchp = NULL; /* OCI Service Context handle */ OCIServer *srvhp = NULL; /* OCI Server handle */ OCISession *usrhp = NULL; /* OCI User Session handle */ OCIStmt *stmtp = NULL; /* OCI Statement handle */ OCIStmt *cursr = NULL; /* OCI Statement handle */ OCIParam *prmp1 = NULL; /* OCI Parameter handle */ OCIParam *prmp2 = NULL; /* OCI Parameter handle */ OCIParam *prmp3 = NULL; /* OCI Parameter handle */ OCIDefine *defp1 = NULL; /* OCI Define handle */ OCIDefine *defp2 = NULL; /* OCI Define handle */ OCIDefine *defp3 = NULL; /* OCI Define handle */ OCIBind *bndp1 = NULL; /* OCI Bind handle */ OCIBind *bndp2 = NULL; /* OCI Bind handle */ OCIBind *bndp3 = NULL; /* OCI Bind handle */ /* used to hold column width */ ub2 col_width; /* used to set the prefetch count */ ub4 prefetch_count = 32; /* will hold output from database */ oratext *pEmpId = NULL; oratext *pFirstName = NULL; oratext *pLastName = NULL; /* the anonymous block to execute */ /* this opens a ref cursor */ oratext *sqlstmt = "begin " \ " open :1 for " \ " select to_char(employee_id), " \ " first_name, " \ " last_name " \ " from hr.employees " \ " order by last_name, " \ " first_name; " \ "end;"; /* used to hold the results of each OCI call */ sword result = 0; /* Initialize and create a default environment */ result = OCIEnvCreate(&envhp, OCI_DEFAULT, (dvoid *) 0, 0, 0, 0, (size_t) 0, (dvoid **) 0); /* allocate an error handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &errhp, OCI_HTYPE_ERROR, 0, (dvoid **) 0); /* allocate a service context handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &svchp, OCI_HTYPE_SVCCTX, 0, (dvoid **) 0); /* allocate a server handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &srvhp, OCI_HTYPE_SERVER, 0, (dvoid **) 0); /* allocate a user session handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &usrhp, OCI_HTYPE_SESSION, 0, (dvoid **) 0); /* create a server context using the "ORADEMO" database */ result = OCIServerAttach(srvhp, errhp, "ORADEMO", (ub4) strlen("ORADEMO"), OCI_DEFAULT); /* set the server attribute in the service context handle */ result = OCIAttrSet((dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *) srvhp, (ub4) 0, OCI_ATTR_SERVER, errhp); /* open the session with the database */ /* using external authentication */ result = OCISessionBegin(svchp, errhp, usrhp, OCI_CRED_EXT, OCI_DEFAULT); /* set the user session attribute in the service context handle */ result = OCIAttrSet((dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *) usrhp, (ub4) 0, OCI_ATTR_SESSION, errhp); /* allocate the statement handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &stmtp, OCI_HTYPE_STMT, 0, (dvoid **) 0); /* prepare the statement for execution */ result = OCIStmtPrepare(stmtp, errhp, sqlstmt, (ub4) strlen((char *) sqlstmt), OCI_NTV_SYNTAX, OCI_DEFAULT); /* allocate the handle for the ref cursor */ result = OCIHandleAlloc((dvoid *) envhp, (void **) &cursr, OCI_HTYPE_STMT, 0, NULL); /* bind the ref cursor parameter */ result = OCIBindByPos(stmtp, &bndp1, errhp, 1, &cursr, 0, SQLT_RSET, NULL, 0, NULL, 0, 0, OCI_DEFAULT); /* execute the statement */ result = OCIStmtExecute(svchp, stmtp, errhp, 1, 0, NULL, NULL, OCI_DEFAULT); /* get parameter descriptor for first column */ result = OCIParamGet((dvoid *) cursr, OCI_HTYPE_STMT, errhp, (dvoid **) &prmp1, (ub4) 1); /* get parameter descriptor for second column */ result = OCIParamGet((dvoid *) cursr, OCI_HTYPE_STMT, errhp, (dvoid **) &prmp2, (ub4) 2); /* get parameter descriptor for third column */ result = OCIParamGet((dvoid *) cursr, OCI_HTYPE_STMT, errhp, (dvoid **) &prmp3, (ub4) 3); /* get the first column width in characters */ result = OCIAttrGet((dvoid*) prmp1, (ub4) OCI_DTYPE_PARAM, (dvoid*) &col_width, (ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, errhp); /* allocate memory to hold the result */ pEmpId = (oratext *) malloc(sizeof(oratext) * (col_width + 1)); /* define the first column in the results */ result = OCIDefineByPos(cursr, &defp1, errhp, 1, (dvoid *) pEmpId, (sword) col_width + 1, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT); /* get the second column width in characters */ result = OCIAttrGet((dvoid*) prmp2, (ub4) OCI_DTYPE_PARAM, (dvoid*) &col_width, (ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, errhp); /* allocate memory to hold the result */ pFirstName = (oratext *) malloc(sizeof(oratext) * (col_width + 1)); /* define the second column in the results */ result = OCIDefineByPos(cursr, &defp2, errhp, 2, (dvoid *) pFirstName, (sword) col_width + 1, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT); /* get the third column width in characters */ result = OCIAttrGet((dvoid*) prmp3, (ub4) OCI_DTYPE_PARAM, (dvoid*) &col_width, (ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, errhp); /* allocate memory to hold the result */ pLastName = (oratext *) malloc(sizeof(oratext) * (col_width + 1)); /* define the third column in the results */ result = OCIDefineByPos(cursr, &defp3, errhp, 3, (dvoid *) pLastName, (sword) col_width + 1, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT); /* loop through and print the results */ while ((result = OCIStmtFetch(cursr, errhp, (ub4) 1, (ub2) OCI_FETCH_NEXT, (ub4) OCI_DEFAULT)) == OCI_SUCCESS) { printf("Employee ID: %s\n", pEmpId); printf(" First Name: %s\n", pFirstName); printf(" Last Name: %s\n\n", pLastName); } /* free allocated memory */ free(pEmpId); free(pFirstName); free(pLastName); pEmpId = NULL; pFirstName = NULL; pLastName = NULL; /* terminate the session with the database */ result = OCISessionEnd(svchp, errhp, usrhp, OCI_DEFAULT); /* detach from the server */ result = OCIServerDetach(srvhp, errhp, OCI_DEFAULT); /* deallocate the environment handle */ /* OCI will deallocate the child handles */ result = OCIHandleFree((dvoid *) envhp, OCI_HTYPE_ENV); return OCI_SUCCESS; } void checkerr(sword status, OCIError *errhp) { oratext errbuf[512]; sb4 errcode = 0; switch (status) { case OCI_SUCCESS: break; case OCI_ERROR: case OCI_SUCCESS_WITH_INFO: (void) OCIErrorGet((dvoid *) errhp, (ub4) 1, (oratext *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR); (void) printf("Error: %.*s\n", sizeof(errbuf), errbuf); break; case OCI_NEED_DATA: (void) printf("Error - OCI_NEED_DATA\n"); break; case OCI_NO_DATA: (void) printf("Error - OCI_NO_DATA\n"); break; case OCI_INVALID_HANDLE: (void) printf("Error - OCI_INVALID_HANDLE\n"); break; case OCI_STILL_EXECUTING: (void) printf("Error - OCI_STILL_EXECUTING\n"); break; case OCI_CONTINUE: (void) printf("Error - OCI_CONTINUE\n"); break; default: break; } } -
Hello
We have a requirement of click to call in installing 10.5 UCCX with customer website (user input) for our client, anyone who tested it in the laboratory/prod settings?
Thank you!!
MagaliHello magali.
It is possible to deploy with UCCX HTTP trigger type. To get the number of customer via the HTTP trigger to the script. Then we can place the outgoing number of customer to campaign or appeal directly to the customer and place this call to the QSC.
There are two scripts for web reminder in Cisco repository of scripts, see this http://www.cisco.com/c/dam/en/us/td/docs/voice_ip_comm/cust_contact/cont...
-
Create a procedure stored via CMD
How can I create stored via cmd procedure? A few reasons, I could not use SQL DEVELOPER or TOAD in the production server, so I create a sql file that contain SP then call sql via cmd file, but it does not work. Here is the sql file
SET pages 0
coil D:\SP\LOG\output_log.txt
Create or Replace procedure TRUNCATE_DATA
IS
BEGIN
RUN IMMEDIATELY 'TRUNCATE TABLE DONNEES_1;
RUN IMMEDIATELY 'TRUNCATE TABLE DATA_2. "
COMMIT;
END;
spool off
output
user11432758 wrote:
How can I create stored via cmd procedure? A few reasons, I could not use SQL DEVELOPER or TOAD in the production server, so I create a sql file that contain SP then call sql via cmd file, but it does not work. Here is the sql file
SET pages 0
coil D:\SP\LOG\output_log.txt
Create or Replace procedure TRUNCATE_DATA
IS
BEGIN
RUN IMMEDIATELY 'TRUNCATE TABLE DONNEES_1;
RUN IMMEDIATELY 'TRUNCATE TABLE DATA_2. "
COMMIT;
END;
spool off
output
COMMIT after that DDL is superfluous.
You must actually run the code as below by adding a slash on the END following line: statement
[oracle@localhost ~] $ cat make_it.sql
coil output_log.txt
Create or Replace procedure TRUNCATE_DATA
IS
BEGIN
RUN IMMEDIATELY 'TRUNCATE TABLE DONNEES_1;
RUN IMMEDIATELY 'TRUNCATE TABLE DATA_2. "
COMMIT;
END;
/
spool off
output
[oracle@localhost ~] $ sqlplus User1/User1 @make_it.sql
SQL * more: Release 11.2.0.2.0-Production on Mon Dec 16 19:56:41 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With partitioning, OLAP, Data Mining and Real Application Testing options
Created procedure.
Disconnected from the database to Oracle 11 g Enterprise Edition Release 11.2.0.2.0 - Production
With partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~] $
-
call a procedure stored since SQL developer UI
I have a stored procedure that is created with a date in parameter.
Then I tried running SQL Developer by right-clicking the stored procedure, then it comes out a parameter window and I tried to enter the value in the entry value field by entering January 1, 2015 "because I know our server date format is DD-MON-RR."
But it shows a window of incorrect format: Please use date format YYYY-MM-DD,
Why is this?
The generated SQL Developer code is less after I ' 2015-01-01'
DECLARE
DATE OF P_DATESTORED;
BEGIN
P_DATESTORED: = to_date('2015-01-01','yyyy-MM-dd');MySproc)
P_DATESTORED = > P_DATESTORED
);
-restoration;
END;I can just use below: for the date, the Server format is DD-MON-RR.
Begin
MySproc('01-JAN-2015')
End;
Thank you
We use oracle 11g 2, the window environment.
The code is generated (SQL Developer) client-side. This code generation, by design, does not count the current NLS_DATE_FORMAT of the session. Instead, it uses the date coded hard YYYY-MM-DD format. It seems to be a design decision.
If you want to enter this date value in a particular format, use the following snippet directly in the SQL worksheet (F5: run script), modified for your desired date format, or omitted date format - I really discourage the to do.
DECLARE
DATE OF P_DATESTORED;
BEGIN
P_DATESTORED: = to_date ('& myinput', 'YYYY-MM-DD');
MySproc)
P_DATESTORED-ONLINE P_DATESTORED
);
-restoration;
END;
/
-
Pass an array to a procedure stored via SQL more.
Hi, I want to spend multiple records in a table to a store proc, where inside, I'll do some DML (insert update delete etc...)
Later the RECS will be forwarded by my application using VB/ASP etc
Currently, I want to test this backend... I have a package and a proc.
But when I call the proc, I get a wrong number of aruments to proc.
CREATE or REPLACE PACKAGE in the UPD_All_TABs
TYPE Varry_emp IS TABLE EMP % ROWTYPE;
PROCEDURE UPD_emp (SheikYerbouti in Varry_emp);
end UPD_All_Tabs;
/
Package created.
CREATE or REPLACE PACKAGE BODY UPD_ALL_Tabs as
PROCEDURE UPD_emp (SheikYerbouti in Varry_emp) is
Start
I'm looping 1.emp_rec.count
dbms_output.put_line (emp_rec (i) .nvd_zobjdev);
/If otherwise etc here end if * /.
end loop;
END UPD_emp;
/
/ * I made a copy of the emp table and modified data. Now I'm selecting and passing
It internal tmy * /.
declare
Type add_varray IS TABLE OF THE emp % ROWTYPE;
var_add_varray add_varray;
Start
SELECT * COLLECT LOOSE var_add_varray FROM tab_copy_of_emp;
UPD_ALL_Tabs.UPD_emp (var_add_varray);
end;
/
/ * This call proc does not work as a type of arguments * /.
/ * However this sub work... displays all REBS copy table * /.
declare
Type add_varray IS TABLE OF THE emp % ROWTYPE;
var_add_varray add_varray;
Start
SELECT * COLLECT LOOSE var_add_varray FROM copy_of_emp;
FOR pos IN 1.var_add_varray.count LOOP
dbms_output.put_line(pos||) e '|| var_add_varray (POS) .emp_name);
end loop;
end;
/
I have seen 100s of pages & fourms I don't have a simple solution... all use java or speak to the application.
If someone had used sql in addition, the examples show a list of hard coded values.
If there is an example of selection in bulk, its inside the proc is stored.
I want to call the proc as I have used before.
Please guide me what is the problem by calling the proc,
If java is necessary, please give me sample for the above code...
Please please help. I'm totally lost.Maybe this will help you. He is little syntax errors in your code corrected too, those.
CREATE OR REPLACE PACKAGE UPD_All_TABs AS TYPE Varry_emp IS TABLE OF EMPLOYEES%ROWTYPE; PROCEDURE UPD_emp(emp_rec in Varry_emp); end UPD_All_Tabs; CREATE OR REPLACE PACKAGE BODY UPD_ALL_Tabs AS PROCEDURE UPD_emp(emp_rec in Varry_emp) is begin for i in 1..emp_rec.count loop dbms_output.put_line(emp_rec(i).FIRST_NAME); end loop; /*if else etc here end if*/ END UPD_emp; END UPD_ALL_Tabs; declare -- Non-scalar parameters require additional processing emp_rec upd_all_tabs.varry_emp; begin SELECT * BULK COLLECT INTO emp_rec FROM EMPLOYEES; -- Call the procedure upd_all_tabs.upd_emp(emp_rec => emp_rec); end;
-
Calling a procedure stored since SQL * PUS
Hi all
I want to call a procedure from SQL * MORE who returns the number, varchar2 and one OUT parameter as table index.
I can declare a variable for the number and varchar2.
How can I manipulate the array index passed into the procedure output parameter.
Thanks, Sandeepdeclare
a number, varchar2 (20) b;
type t as table of varchar2 (10) index directory. -identical to your procedure declaration
c t;
Start
procedure (a, b, c);
end;
/ -
Date Format question - calling a procedure stored on the side of java
What is the best approach to managing a DATE as a parameter to a procedure?
(1) the emp table has a column called hire_date and its data type is DATE.
(2) the procedure has tried to retrieve all employees hired on a specific date, there is a parameter called p_hire_date, type what data it should use? Something like p_hire_date IN emp. HIRE_Date % TYPE? < == is that correct?
(3) both within the body of the procedure, during the recuperation of registration,
SELECT first_name, last_name
FROM EMP
Where hire_date = p_hire_date < == is that correct? or when should I use to_date()?
(4) on the coast of Java, when you call this procedure, what data type the hire_date is?
Thank you
new2OracleHello
Procedure seems correct, do not use to_date.
Switch argument as a java.sql.Timestamp.
(Or java.sql.Date If you are absolutely certain that you DATE of Oracle is a component "hour")
Concerning
Peter -
Hello
I have a package that returns a Ref Cursor, in this procedure, I have a dynamic sql code that is built according to certain values, and the query is a select query, is it possible that I can put that dynamic sql in the ref cursor and return of the procedure.
Or y at - it no alternative better workaround.
Thanks in advance.
NaveenYes you can.
Try this...
create or replace package test_pack is type ref_cur is ref cursor; procedure just_print(ref_var ref_cur); end; / create or replace package body test_pack is procedure just_print(ref_var ref_cur) is l_var emp%rowtype; begin loop fetch ref_var into l_var; exit when ref_var%notfound; dbms_output.put_line(l_var.ename); end loop; end; end; / declare cur_var test_pack.ref_cur; dsql varchar2(100); begin dsql := 'select * from emp where deptno=10'; open cur_var for dsql; test_pack.just_print(cur_var); end; / CLARK KING MILLER PL/SQL procedure successfully completed. Elapsed: 00:00:00.00
Kind regards
Prazy -
Call a procedure stored in PS cs3
Hello
someone has already seen such a strange code (in my view) screenshot ? This code was generated in cs3 adding a record set with a server behavior. In the window 'record set', I see all the parameter differently on the right. But in the source code, I see just '? ' and 'settings' with automatic numbering.
Is it okay then? Or a bug to adobe? should not be too the names of the parameters in the command text?
Yet is this work correct? I think that the parameters must be in the same order as in the stored procedure (MS - SQL)?
Another question: is it true that I have to set the size of a parameter in the source code? (When I use the function 'command' rather than the licence feature has I can add size in the window also developing.) Is this works is not in the folder defined in the window?
(BTW: I tried to use the "order server behav." but I did not return the recordset - so opt for the 'Recordset behav', but here I can not change the size...)
thx for any help in this
Sebastian
"eFscl" wrote in message
News:f58b74$6MP$1@forums. Macromedia.com...
> Hi there,
>
> has anyone seen such a strange code (from my point of view)
> http://www.imagehosting.com/out.php/i792345_screenshot.jpg already? This
> code
> has been generated in cs3 adding a record set with a server behavior. Within the
> the
> window 'record set' that I see all the parameter differently on the right. But within the limits of the
> source
> code I see just '? ' and 'settings' with automatic numbering.
>It's normal. ADO (the layer between your ASP pages and OLE DB
provider for the database) only supports the transmission of position parameters, and
the parameters are marked with a? in the command text.> Another question: is it true that I have to set the size of a parameter
> in the source code? (When I use the function 'order' instead of the)
> Adjustment disc I can add the size of the window in development too. Is
> This is not
> working in the record window?I do not believe, but ADO supports certain configurations of parameters which
the translation of "I don't know, ask the waiter." The recordset behavior may be
help of these.> (BTW: I tried to use the "order server behav." but I did not back)
> the
> save set - so opt for the 'Recordset behav', but here I can't change
> the
(> size...)The command object returns a set of records and is in fact how DW implements
the behavior of recordset in DW CS. -
XSLT transformation with more than one input variable
Hello
We have a requirement to generate the body of the e-mail using XSL. But the fields that should be included in the mail require the content of two different variables.
If we use 2 transformations for the above use case, we are not able to achieve what we want.
The content of the e-mail must be formatted in a format similar as below. The content of the 2nd transformation must be placed at a certain point within the content of the first.
+ < some 1st transformation xsl content > +.
+ < 2nd transformation xsl content > +.
+ < rest of the content of the 1st xsl transformation > +.
Please give your input on how we can deal with such a transformation
Thanks and greetings
JohnXSL transformation in 11g excludes several parameters
If you want to achieve in older versions, you must use the third parameter to the call of xsl to process, you could suppy a sort of list of parameters (name/value list)http://blogs.Oracle.com/rammenon/2007/05/passing_bpel_variable_contents.html
http://soaranch.WordPress.com/2008/09/08/passing-parameters-from-BPEL-to-XSLT/both will explain how
-
call a packed stored procedure from within another stored procedure
I have a stored procedure (STROKEQC) on a scheme that is not in a package. I want to be able to call a procedure stored that IS inside a package on the same scheme of STROKEQC. When I try the syntax below, I get an error "no function with name 'PARTICIPANTSPECIFICEDITS' exists in this area." That the procedure exists.
Is not the way to do inside a stored procedure?/*Generate admin field data*/ execute immediate QCPROCEDURES.PARTICIPANTSPECIFICEDITS('ALL'); execute immediate QCPROCEDURES.GENERATE_SURGYEAR_ERRFLAG;
Thank you!
EvaHi, Eva,.
You need not EXECUTE IMMEDIATE to call a stored procedure (including a procedure in a package) on the other. Just use the name and the arguments (if any):
QCPROCEDURES.PARTICIPANTSPECIFICEDITS('ALL'); QCPROCEDURES.GENERATE_SURGYEAR_ERRFLAG;
I guess qcprocedures is the package name, and participantspecificedits and generate_surgyear_errflag are procedures in this package.
In case you're wondering, the error was probably because you do not have a variable called participantspecificedits. If you had a dynamic code in a string called variable x, then "EXECUTE IMMEDIATE x"; would be the way to run it.
-
Calling a procedure that returns a cursor in a procedure
Hello
I have two stored procedures. They both return a cursor as output variables. However, I have another stored procedure that calls these procedures and return their results once again an output variable. I know that sounds strange to want to do something like this, but how can I do this?Mikhail says:
My first procedure returns a cursor. But the cursor is opened on one condition. Like, if PARAM1 = 1 THEN OPEN cursor_1 to SELECT... OTHERWISE, OPEN CURSOR_1 TO SELECT... And the second slider has the same structure. The thing is in the two procedures if I declare that a single CURSOR_1 IN OUT parameter that the procedure will not work. So in both entities, I have two variables IN OUT SYS_REFCURSOR: c1 and c2. Then, in the third procedure I first call the first procedure, then the second. How can I write my third procedure in order to obtain the result two procedures United?
Why the appellant (3rd procedure) need to have 2 ref Cursor? How will the appellant to "unite" the sliders?
The actual data, a power of work must be done inside sliders. Not in PL/SQL or other languages. The SQL language is a very powerful and flexible language.
So if the SQL 2 data sets (or more) must be "United", then you should not use the 3rd procedure and PL/SQL code to do. Should use you 2 sliders.
You should watch this by using SQL only. The 2 sets of data can be merged, joined, union'ed. You can determine the intersection. You can determine the difference (with a negative sign). It can be rotated. It can be aggregated. It can be cube' ed. Etc.
This SQL will then be used as a single slider and a unique reference cursor handle will be used to consume the output of the cursor.
The basic rule to develop Oracle applications is simple. Optimize SQL. Minimize the PL/SQL.
Use the SQL language to the data of the crisis. No PL/SQL.
-
Example of using a Ref Cursor variable procedure
I'm looking for an example of how to execute a stored procedure with a Ref cursor variable in SQL Developer 3.0. I am familiar with the syntax in SQL * Plus, for example:
variable my_cur refcursor;
Start
my_package.my_proc ("in param"
(: my_cur);
end;
/
print: my_cur
How would I do the same thing in SQL Developer 3.0?
Thank you!Run a procedure directly. For example, select the package in the browser-> menu-> Run. The dialogue with anonymous block box. Edit, OK it to run, then the procedure would be and all settings including Ref Cursor appear in the grid. (This functionality is there since 3.0)
-
Calling an Oracle stored procedure.
Stored procedures have always given me trouble, I don't know why.
I want to call a procedure from Oracle to a piece of CFML code.
My CFML code:
<cfstoredproc datasource="purload" procedure="PUR_XML_LOAD.load_raw" returncode="yes"> <cfprocparam cfsqltype="CF_SQL_FLOAT" value="999" type="out"> </cfstoredproc>
The error I get:
[Macromedia] [Oracle JDBC Driver] [Oracle] ORA-06550: line 1, column 18:
PLS-00306: wrong number or types of arguments in the call to 'LOAD_RAW '.
ORA-06550: line 1, column 7:
PL/SQL: Statement ignoredTest code PL/SQL that works with Oracle SQL Developer:
DECLARE foo NUMBER :=999; begin PUR_XML_LOAD.load_raw (foo); dbms_output.put_line('>' || foo || '<'); end;
The top of the stored procedure:
create or replace PACKAGE BODY PUR_XML_load AS -- *** PROCEDURE: PUR_XML_load *** -- Loads values from previously-validated XML file -- into the raw_pur table PROCEDURE Load_raw (res_val OUT NUMBER) AS
So, how can I make the code the same way CFML function that code PL/SQL?
TIA
Ian
OK, maybe you're RTFMing, but maybe RWAS (read this as Adam Said) ;-)
Does THIS work:
?
--
Adam
Maybe you are looking for
-
Problems after upgrade to Sierra.
After the upgrade to Sierra I have questions. App & external drives are locked after the iMac is off mode 'sleep'. Unable to perform even normal shutdown. After you have reinstalled the operating system, again always get the same result. Updated from
-
Photo HP Envy all in a single 5660: Memory stick compatibility
I just bought this printer. I can't know if my stick duo memory will work. When I try it says it's corrupt or not a format supported. I had a chat with technical support and they say that it is supported. My camera is a sony cyber shot and uses memor
-
Hello I'm trying to calculate cksum for hexadecimal string. but I can't get a good result. I use MS calcuator, I got the result "cksum = 51", and I use labview 8.5. I got the result "cksum = 11. Can someone tell me what I did wrong? Thank you Johnny
-
Visio 2010 Value Stream Mapping
Is it possible to include formulas with Visio 2010, specifically the symbol VSM defined so that the calculation can be made of the data entered - as with Excel?
-
Windows xp pro does not work in normal mode. I can make it work in safe mode. I can't find my XP cd. I don't have the serial code and key. How can I load xp and try to fix the problem. Thank youMike original title: need windows xp pro