How to create control provided by PL/SQL ref-cursor
Dear valuable experts,I'm migrating oracle forms10g for JDeveloper. Currently I need a guideline or a reference to create pages of the ADF using the PL/SQL-Refcursor rather then tables or views.
I need help also how can I create using PL/SQL (package) - Refcursor datacontrol.
Please help me.
(!)
Thank you.
Zed
====
Zed,
The Fusion developer's Guide has 35.9.4 article titled "How to create a view object on a REF CURSOR" which should help you.
John
Tags: Java
Similar Questions
-
How to create a record of pl/sql in oracle
Oracle Forms 6i
Hai All
My question how to create a record with a cursor for loop.
While I'm generating my if statement elsif only some of my files are not completely recovered, so I generate using the cursor for loop pls tell how to do
My code is
declare
t_in dail_att.intime%type;
t_out dail_att.intime%type;
t_code dail_att.barcode%type;
dail_att.attend_date%type V_DATE;
cursor cur_test is
Select respondent, outtime, barcode, dail_att attend_date;
-in t_in, t_out, t_code, dail_att V_DATE;
Start
go_block ('TEST_SRI');
PREMIER_ENREGISTREMENT;
LOOP
If: bartime between 0145 and then 0630
Update dail_att set = outtime: bartime where barcode =: bar code
and ATTEND_DATE =: BARDATE-1 and intimate are zero and outtime is not null;
elsif: bartime between 0630 and 0900 or: bartime between 1130 and 1230 or
: bartime between 1700 and 1800 and t_in is null then
insert into dail_att(barcode,intime,attend_date)
values(:Barcode,:Bartime,:bardate);
elsif: bartime > 1645 and t_in is not null and t_out is null then
Update dail_att set = outtime: bartime where barcode =: bar code
and ATTEND_DATE =: BARDATE and respondent are not null and outtime has the value null.
on the other
Update dail_att set = outtime: bartime where barcode =: bar code
and ATTEND_DATE =: BARDATE and respondent are not null and outtime has the value null.
end if;
WHEN THE OUTPUT: SYSTEM. LAST_RECORD = "TRUE" OR: BAR CODE IS NULL;
NEXT_RECORD;
END LOOP;
forms_ddl ('commit');
exception
while others then
forms_ddl ('rollback');
message(SQLERRM|| dbms_error_Text);
message(SQLERRM|| dbms_error_Text);
End;
Pls tell me if I need to create a folder or other...
Concerning
Srikkanth.MYou can run a loop throgh query records of Pentecost an implicit cursor (which automatically manages the open cursor, fetch and next record):
for rec in (select intime,outtime,barcode,attend_date from dail_att; ) loop t_in :=rec.intime; t_out :=rec.outtime; t_code :=rec.barcode; t_date := attend_date; /* PUT YOUR CODE HERE ... (if ..then... elsif... logic) you can avoid setting variables 'cause you can directly use the implicit cursor variables: rec.intime etc. */ end loop; END;
In any case, I suggest you check the where the condition of your block... because if not all data is collected it should be a problem in your application... well, even the cursor (if it is based on the same query) will return less data than expected.
Luca
-
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; } } -
How to start the view off of the ref cursor Oracle as input/output param
Hello world
We use JDev 11.1.2.3 WL 10.3.6 and Java 7.
We are at the beginning of our transition from Oracle Forms to ADF. We have a very large forms that uses many store procedures that have IN/OUT ref Cursor parameters and tables plsql. I tried to find information on best practices to achieve, but only seemed to find tutorials on SEO of the Oracle ref Cursor return functions. I hope we don't have to rewrite our code of database to work with ADF.
This is an example of a proc currently a block on a form based on directly
The ref cursor parameter is input/output to satisfy the way the form handles this type of paradigm.
ADF we want I hope to reuse these procs existing (without the need to wrap/overload them) on the basis of the display objects.
Example:
/ * my record type which houses the information I want to go back * /.
TYPE rec_hist_vacpac_status IS RECORD)
rec_order NUMBER (5),
rec_rownum NUMBER (5),
return_column SAM_VACPAC.vacpac_status%TYPE,
rec_login_id SAM_VACPAC.ins_user%TYPE,
status_date SAM_VACPAC.status_date%TYPE
);
/ * Sets the ref cursor type * /.
TYPE lcur_hist_vacpac_status IS REF CURSOR;
/ * This is a procedure that would take some info link go / return
Return the ref cursor of this information as an in / out * /.
PROCEDURE prc_myinfo_refcur)
pnum_identify_seq_id in NUMBERS
pcur_myinfo IN OUT lcur_hist_vacpac_status);
Can anyone point me in the right direction on documentation on this?
Thank you!
Hi Cemerson:
See this example:
- 1. create a TYPE as an object
CREATE OR REPLACE
TYPE GOTYOB_EQUI
AS AN OBJECT
(
CDELEM VARCHAR2 (50).
TIELEM VARCHAR2 (2)
);
- 2. create a TABLE TYPE AS
CREATE OR REPLACE
TYPE GOTYTA_EQUI
AS THE GOTYOB_EQUI TABLE;
- 3 create a function, it returns the TYPE of the TABLE
FUNCTION fn_equiposarriba)
pa_cdelem IN VARCHAR2,
pa_nucomp in NUMBERS
pa_anperi in NUMBERS
pa_meperi in NUMBERS
)
Gotyta_equi RETURN PIPELINED IS
CURSOR trae_equimani (va_cdelem VARCHAR2) IS
SELECT cdelem, tielem, cdelempadr,
(SELECT cdequi
Of evm_alim
WHERE anperi = eq.anperi
AND meperi = eq.meperi
AND nucomp = eq.nucomp
AND cdalim = eq.cdalim) cdalim
Of evm_equimani eq
WHERE anperi = pa_anperi
AND meperi = pa_meperi
AND nucomp = pa_nucomp
AND cdelem = va_cdelem
AND cdelempadr <> cdelem
AND tielem <> 'A ';
equimani trae_equimani % ROWTYPE;
va_cdalim VARCHAR2 (100);
BEGIN
-Loading los equipos aguas arriba
WHILE equimani.cdelempadr IS NOT NULL LOOP
OPEN trae_equimani (equimani.cdelempadr);
equimani: = NULL;
SEEK trae_equimani INTO equimani;
CLOSE Trae_equimani;
IF equimani.cdelem IS NOT NULL THEN
PIPE ROW (gotyob_equi (equimani.cdelem, equimani.tielem));
END IF;
END LOOP;
RETURN;
END;
- 4 SQL Query with the help of the function... you can use this SQL in a display object
SELECT
*
Of
TABLE (gopq_eventos.fn_equiposarriba (' F-SCZ-043-103', '))
1,
2013,
6
)
)
Best regards, Marcelo
-
wanted to extract data from nested table pl/sql Ref Cursor getting an erro
create or replace type 'DEPT12' as an object (dno number (2), dname varchar2 (30), varchar2 (50)) loc;
create or replace type dept_tab in the table in "DEPT12".
create or replace type 'LOC12' as an object (locno number, loc_name varchar2 (100))
create or replace type loc_tab in the table of "LOC12.
create or replace type dept_loc_rec1 as an object (dept_tab, eno number, loc_dt loc_tab dept_dt);
Create type dept_loc_tb as table of the dept_loc_rec1
create table dept_loc_tb_bk1 (dept_dt dept_tab, eno number, loc_dt loc_tab)
NESTED TABLE dept_dt
STORE AS dept_tab12,
NESTED TABLE loc_dt
STORE AS loc_tab12
insert into dept_loc_tb_bk1 values (dept_tab (dept12(3,'ABD','LOC')
dept12(4,'ABD','LOC')
(, dept12(5,'ABD','LOC')), 3, loc_tab (loc12(21,'AAB'),
loc12(22,'AAB'),
loc12(23,'AAB')));
When I try to extract data from Ref cursor to pl/sql table that I get an error ora-06504: pl/sql: return types of the result set of variables or request do not match.
I created a table nested, as well as the pl/sql nested table object dept_loc_tb and I said the same dept_loc_tb lv_dept_loc_tb, but trying to get in this variable we get an error above.
Please anyone can solve my problem.
-----------------
declare
type cr is ref cursor;
cr_obj cr;
lv_dept_loc_tb dept_loc_tb;
Start
Open cr_obj to select dept_dt, eno, dept_loc_tb_bk1 loc_dt;
collect the fetch cr_obj in bulk in lv_dept_loc_tb;
close cr_obj;
end;Your query selects 3 distinct columns requires so 3 collections of matching types. You want to treat these 3 columns as an object of type DEPT_LOC_REC1:
SQL> declare 2 type cr is ref cursor; 3 cr_obj cr; 4 5 lv_dept_loc_tb dept_loc_tb; 6 7 begin 8 open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1; 9 fetch cr_obj bulk collect into lv_dept_loc_tb; 10 close cr_obj; 11 end; 12 / declare * ERROR at line 1: ORA-06504: PL/SQL: Return types of Result Set variables or query do not match ORA-06512: at line 9 SQL> declare 2 type cr is ref cursor; 3 cr_obj cr; 4 5 lv_dept_loc_tb dept_loc_tb; 6 7 begin 8 open cr_obj for select DEPT_LOC_REC1(dept_dt,eno,loc_dt) from dept_loc_tb_bk1; 9 fetch cr_obj bulk collect into lv_dept_loc_tb; 10 close cr_obj; 11 end; 12 / PL/SQL procedure successfully completed. SQL>
SY.
P.S. discover sys_refcursor. -
How to create insert statements in the SQL Developer client
Hi all
A toad, we can create instructions for insertion of data in the table by clicking with the right button on the table and selecting create insert Stmts. But I am new customer SQL Developer. Could you please let me know how to do that in SQL Developer. I would be grateful if someone posts a link to the manual of the SQL Developer (how to use SQL Developer).
Thank you.SQL> create table staging(x int, y varchar2(3)); Table created. SQL> create table base(x int, y varchar2(3)); Table created. SQL> SQL> insert into staging values(1,'ABC'); 1 row created. SQL> insert into staging values (2,'DEF'); 1 row created. SQL> commit; Commit complete. SQL> select * from staging; X Y ---------- --- 1 ABC 2 DEF SQL> select * from base; no rows selected SQL> SQL> insert into base 2 select * from staging; 2 rows created. SQL> commit; Commit complete. SQL> truncate table staging; Table truncated. SQL> SQL> select * from staging; no rows selected SQL> select * from base; X Y ---------- --- 1 ABC 2 DEF SQL> SQL> exit
-
Query dynamic SQL &; Ref Cursor - debug errors
Hello.
I am trying to execute the query below, but I am getting error for the part highlighted, could you please give some suggestions.
IMMEDIATE EXECUTION
' OPEN SPSN_ECMCODE7_C3 FOR ' |' SELECT OPS_OPTION_NUMBER, OPS_ITEM_PART_NUMBER, OPS_FILE_TYPE, OPS_NOUN_NAME, TO_CHAR(OPS_STOP_DATE,'DD-MON-YYYY') OPS_STOP_DATE
OF T_OPTION_STRUCTURE
WHERE OPS_FILE_TYPE IN '. V3 | »
AND OPS_STOP_DATE > SYSDATE
START BY OPS_STOP_DATE > SYSDATE
AND OPS_ITEM_PART_NUMBER LIKE '. V1 | »
CONNECT OPS_OPTION_NUMBER = PRIOR OPS_ITEM_PART_NUMBER';
Error:
- PLS-00103: encountered the symbol "DD" when expecting one of the following values: * & = +; <>/ to in mod rest not rem return comes back <>or! = or ~ = > = < = <>and or as like2 like4 likec between using | big Member submultiset the symbol ' * ' replaces 'DD' continue.
- PLS-00103: encountered the symbol ") OPS_STOP_DATE" when expecting one of the following values:. ". (* @ % & = - +; <>/ to in mod rest not rem return comes back <>or! = or ~ = > = < = <>and or as like2 like4 likec between using | bulk Member submultiset symbol "("a été substitué pour") OPS_STOP_DATE" to continue.)
- PLS-00103: encountered the symbol ";" when expecting one of the following values :), * & = - + <>/ is mod remains not rem = > <>or! = or ~ = > = < = <>and or as like2 like4 likec in reports between use. Members submultiset symbol ")" has been replaced by a ';' to continue.
Please suggest some possible solutions.
Thank you
open spsn_ecmcode7_c3 for select ops_option_number , ops_item_part_number , ops_file_type , ops_noun_name , to_char(ops_stop_date,'dd-mon-yyyy') ops_stop_date from t_option_structure where ops_file_type in ( select trim(regexp_substr(val, '[^,]+', 1, level)) val from ( select v3 val from dual ) connect by level sysdate start with ops_stop_date > sysdate and ops_item_part_number like case when(instr(1, 1234567890, substr(v_engmonsystem, 1, 1)) > 0) then substr(v_engmonsystem, 1, 7) else substr(v_engmonsystem, 1, 8) end || '%' connect by ops_option_number = prior ops_item_part_number;
-
How to create the constructor function for a pl/sql table?
I created a PL/SQL type as table below:
create or replace type typ_tbl_des_text is table of the typ_tof_des_text
OK so far, but I would like to have a constructor function which would be subject to validations and raise_application_error when a validation condition is not met.
How to do this?
The typ_tof_des_text that I created with a constructor function, so that the record-level validation are performed in the constructor. And I think the postings between several records shall be made in a constructor for typ_tbl_des_tex, but cannot figure out how to create such a constructor.
BEDE wrote:
So, if I have understood correctly, to a plsql table type, I can't have a member procedure. Or can I? I mean, just as for a type of failure I can have one or more constructors and possibly several procedures of Member.
For the standard tables in PL/SQL, you will need to create your own API (using procedures and functions) to handle beyond the basics provided by the language. No constructors and methods as it is no o - o.
After thinking a little deeper, I reformulate what I said earlier and actually wants to have a member procedure called add_item, who would be first to check if an item with a key value exists and, if so, it would be up-to-date and so not only extend the plsql table.
Two options.
As we already mentioned, an associative array can be considered - note however that this structure of table has name-value pairs.
Another method is to use a TWG (global temporary table). You define the structure of the once initial table. When a session uses the structure of the table, private copying is instantiated for this session. When the session ends, this copy is destroyed. The table is a temporary structure for this session only.
It can include indexes and so on – which means you can use the constraints of primary keys, unique indexes, secondary indexes and so on.
TWG scales are much better than collections or arrays that require a PGA (expensive private server) memory. In addition, SQL can be used natively against a GTT - unlike the arrays and collections.
-
I must control 4 proportional valves (Bürkert 2873 x 3 & 2875 x 1) installed on a gas pipeline. These type of valve control signal is 4-20 my. I have a data acquisition NI USB - 6343 with 4 AOs of V-10-10 X. How can I control these valves with the DAQ hardware? I am not familiar with ELECTRIC/ELECTRONIC, that is why I ask. Thanks in advance.
This device can produce only 5mA on the analog output. So, you will need an op amp that can display on your 20mA. See here for the creation of a converter with an op-amp circuit. Your USB-6343 should provide 1 to 5V to the op-amp.
-
Hi all
I would like to create a button custom as a master, so that if I change the look of the master all other buttons are changed.
I did it with a custom control, such as a 'type strict def' otherwise the look will change , BUT if I do this as a strict type def I can't change the Boolean text more which should be different on each button.
How to create a master control of a button where the look apply to everyone else but not the Boolean text?
Steve Chandler wrote:
I don't think that you can do. I just looked and as I suspected the Boolean property text is read only for strict typedefs, you cannot use the nodes property to change the text.
As a just solution make it a typedef. When you want to change the open look the typedef and strict rendering, make your changes, then make no strict again. You will need to update the text Boolean yet once for all instances. Kind of pain. This is perhaps something for the exchange of ideas.
Alternatively, remove Boolean text and replace with legend
-
How to create an association in the Set associations Control Panel?
When I try to open attachments to emails that have pps file it is said, this file does not have a program associated with it for performing this action. Create an association in the Set associations Control Panel. How to create an association in the Set associations Control Panel?
1: If you do not PowerPiont or PowerPoint Viewer, you need at least the Viewer.
PowerPoint 2007 Viewer:
http://www.Microsoft.com/downloads/details.aspx?FamilyId=048DC840-14E1-467D-8DCA-19D2A8FD7485&displaylang=en2: create a file association.
1. download and save the attachment to the office.
2. right click on the saved file.
3. Select: Open with on the shortcut menu.
4. click on: choose [default] program.
5 PowerPiont select: (Or PPViewer).
6. check: always use the selected program to open this type of file.
7. click on OK.3: Edit the registry here if necessary.
Cannot open. PPS directly from Windows Mail or Windows Live Mail attachments
http://www.Winhelponline.com/articles/149/1/Unable-to-open-PPS-attachments-directly-from-Windows-mail-in-Windows-Vista.htmlBruce Hagen ~ MS - MVP [Mail]
-
How to create an association in the control panel to the default programs with windows 8?
Separated from this thread.
HOW to CREATE a LINK WITH MY EMAIL(*** Email address is removed for privacy ***) BY THE DEFAULT PROGRAMS CONTROL PANEL?
BM
If you use a browser to access your e-mail, it is the question. You can set a default e-mail application if you have an e-mail application and the browser is NOT a messaging software.
Install an e-mail client and it will work, and that's why it worked on XP because you probably had Outlook express installed.
-
How to create an identifier SQL, sql Profiler
Hi team,
An application runs for a long time if I want to create the sql for If sql Profiler for the request. Example is my sql f70m2g5rbfvbg code.
My question is how to create the sql for the best recommendation Profiler and how to import the sql for acccepting Profiler the best profile for improved performance.
Please suggest
Hello
1. you must accept the best plan based on the recommendations of the Advisor tuning
2. second thing is to import the profile sql - transport to destination db (where you want to import)
-Pavan Kumar N
-
How to create a Shell (.sh) file in Oracle using PL/SQL?
Hello world
I would like to know how to create a .sh file or any .txt file in Oracle. I would like to get the contents of the file from a table that has different settings. I used bcp in SQL Server and wonder if it's possible in Oracle to create this file.
Here are the DDL and DML in the table:
-
How to create a planner oracle sql developer
Hello
How to create developer oracle sql Scheduler created?
Hello
Finally, I refer link below its helpful
ORACLE-BASE - Support SQL Developer 3.1 Scheduler (DBMS_SCHEDULER)
Maybe you are looking for
-
When there are only two tabs on the left, the tab bar disappears.
When I close my tabs and only have two left, any tab is open before finishing the third tab becomes the only thing in my window, as if I had closed the two legs instead of one. I can restore the hidden tab by opening a third tab. I have FF value does
-
Hello world! I have a problem with my Mac Book Pro 15 "mid 2014. Since yesterday, the temperature gets really high, even if I went on my Mac for the first time, and we're talking about 80 ° C to 85 ° C, I have updated to OS X El Capitan 10.11.4 but n
-
Firefox 5 does not work with the AVG and Google toolbar, among other problems
I downloaded Firefox 5, invited by Filehippo. Among other things, my anti-virus sw were not compatible, the Google toolbar disappeared and could not be put back because I was using an old browser! I did a system restore with the result that Firefox d
-
ORA-12154 tns could not resolve the specified correct identifier
I am facing the following problem: labVIEW 2012 32 bits 64 bits of Windows 7, 10.2.0.1.0 oracle client (32-bit). I created a DSN from Data Sources (ODBC) (32-bit version of what in % windir%\syswow64\odbcad32.exe) pointing to an instance of Oracle 10
-
Questions for the recovery of account with the code by email * help *.
Hey! I've been struggling with this for a while now and I finally had the time to ask for assistance through this Web site. I forgot the password for my account, and at one point, I thought that everything would be fine because I thought I could get