How can we execute a procedure with object type as its parameter, by passing partial elements.

Can somebody help...
I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
PROCEDURE p_save (example IN OUT xyz_obj)
my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.

user13026549 wrote:
Can somebody help...
I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
PROCEDURE p_save (example IN OUT xyz_obj)
my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.
It ISN'T possible. How could it be? Each attribute has to be set to something don't you think?
A common way to handle that is to define a public package variable that is an instance of the object type and has ALL elements set to null. As Odie suggested a custom constructor function can be used for that.
Then you create your procedure instance by starting with an instance of the package variable (where everything is null) and setting values for the attributes you need.

Similar Messages

  • How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt

    Hi,
    I have a procedure with OUT variable is %ROWTYPE
    How can I execute the following procedure on SQL prompt.
    (without creating anonymous block)
    CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
    V_REC IN OUT EMP%ROWTYPE)
    AS
    BEGIN
    SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
    END;
    Thanks & Regards,
    Naresh

    as previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
    With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
    declare
    l_rec EMPLOYEES%ROWTYPE;
    begin
    zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
    DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
    DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
    end;
    first_name = Steven
    last_name = King

  • How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?

    Hi 
    I have a stored procedure. It can be executed like this
    exec test @p = 1;
    exec test @p = 2
    exec test @p = n;
    n can be hundred.
    I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
    If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
    However, the n is not static. It is coming from a table. 
    How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
    I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
    be run parallel. But I am not sure if it works.
    Any idea is really appreciated.

    Hi nam_man,
    According to your description, you want to call stored procedures in parallel, right?
    In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
    We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
    For more information about SSIS job and Sequence container, please refer to the following documents:
    http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
    https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • How to execute a procedure with Object as OUT parameter

    Hi,
    I have a procedure and it consists 2 parameter, one is an input parameter and that is some ID (NUMBER datatype) and 2nd parameter is an out parameter and it an Object type. I want to execute that procedure but not able to do the same. Can anyone please suggest me how do I execute a procedure which has got Object as an out parameter.
    Thanks a lot in advance for your support.

    Example:
    SQL> create or replace type t_obj as object (ename varchar2(10), deptno number);
      2  /
    Type created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure myproc (p_empno in number, obj out t_obj) is
      2  begin
      3    select t_obj(ename, deptno)
      4    into obj
      5    from emp
      6    where empno = p_empno;
      7* end;
    SQL> /
    Procedure created.
    SQL> set serverout on
    SQL> declare
      2    v_obj t_obj;
      3  begin
      4    myproc(7788, v_obj);
      5    dbms_output.put_line(v_obj.ename||','||v_obj.deptno);
      6  end;
      7  /
    SCOTT,20
    PL/SQL procedure successfully completed.

  • How to call procedure with Object types in java

    Hi,
    We have procedure declaration as follows
    ===============
    TYPE TEST_TYPE AS OBJECT (NAME VARCHAR2(10));
    TYPE TESTTYPE1 AS object (student1 TESTTYPE,student2 TESTTYPE,student3 TESTTYPE);
    TYPE rect AS OBJECT
    -- The type has 3 attributes.
    length NUMBER,
    width NUMBER,
    area NUMBER,
    -- Define a constructor that has only 2 parameters.
    CONSTRUCTOR FUNCTION rect(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
    PROCEDURE G(obj1 in TESTTYPE1,obj2 out rect) as
    n1 testtype;
    n2 testtype;
    n3 testtype;
    n4 testtype;
    begin
    obj2 := NEW rect(10,20,200);
    n1 := obj1.student1;
    n2 := obj1.student2;
    n3 := obj1.student3;
    obj2.length :=20;
    end;
    =====================================================
    I am not able to call the procedure in java code as I cannot figure out which out parameter type will it be registered using registeroutparameter. using cursor or struct type fails.
    please let me know how I can pass values from stored procedure with objects to java.

    I'm not sure what you're trying to accomplish with your procedure, but in general, this is an example of how you could use oracle.sql.STRUCT.
    First, prepare your java.sql.CallableStatement using java.sql.CallableStatement cStmt = java.sql.Connection.prepareCall({ call G(?, ?) });
    Note that you don't have to use the OracleCallableStatement. The java.sql.CallableStatement will work just fine.
    For the IN parameter, you need to create three TEST_TYPE objects. Then you need to create one TESTTYPE1 object.
    These will all be instances of oracle.sql.STRUCT.
    To create a oracle.sql.STRUCT object you need a descriptor and a set of attributes. For example, to create a TEST_TYPE object you would do the following
    1. StructDescriptor sd = StructDescriptor.createDescriptor("TEST_TYPE", java.sql.Connection).
    2. Add a VARCHAR2 attribute to an array of attributes (e.g. Object[] attributes = new Object[]{"Student Name"})
    3. oracle.sql.STRUCT struct = new oracle.sql.STRUCT(sd, java.sql.Connection, attributes)
    Then do something similar to create the TESTTYPE1 object, except that the attribute array will contain three instances of TEST_TYPE struct objects.
    To bind the IN parameter you need to use the java.sql.CallableStatement.setObject(1, <Instance of TESTTYPE1 object>).
    To register the OUT parameter, you need to call java.sql.CallableStatement.registerOutParameter(2, oracle.jdbc.OracleTypes.STRUCT, "RECT").
    Then, execute your procedure using cStmt.execute();
    Retrieve your OUT parameter using oracle.sql.STRUCT struct = (oracle.sql.STRUCT)cStmt.getObject(2).
    Once you've done that, to get the values of the attributes of all of your STRUCT objects, you need their descriptors and their metadata.

  • DB Adapter - Calling Stored Procedure with Object Type

    So, we are using JDeveloper 10.1.3.3
    We are trying to create an ESB process that invokes a SP with an object type. However, the owner of the package / SP, is NOT the owner of the object type. When going through the DB Adapter wizard, it gives us the following error:
    When attempting to use the DB Adapter in JDeveloper to create a partner link to execute a stored procedure. JDeveloper returns the following error:
    Unable to import WSDL.
    Error while writing wsdl file
    Database type is either not supported or is not implemented.
    Check to ensure that the type of the parameter is one of the supported datatypes or that there is a collection or user defined type definition representing this type defined in the database.
    However, if I create a wrapper package / SP, it works just fine. I'd really like to not be having to create wrapper code for these SPs to work. Is this resolved in 11g? Is there a patch available for 10.1.3.3?
    I think this is a JDeveloper Wizard issue, but thought I'd post this here as well.
    Thanks,
    BradW

    This problem can be resolved by granting execute permission on the object type to the caller. For example, if the stored procedure is in schema1 and the object type is in schema2 then you would connect as schema2 and execute
    SQL> grant execute on <object type> to schema1
    Referencing object types defined in other schemas is documented. This is the described method for accessing object types in other schemas.

  • 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}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • ADF how can i execute a query with parameters when the page renders

    hi
    i am using ADF web 11g
    i need to execute a query with parameters when the page renders
    thanks

    hello,
    I'm a fan of Java code, I really am.
    But when you use ADF, you decided to move to a more declarative environment.
    So why not do it declarative, the adf way?
    In your pagedef insert a action binding.
    This can be anything, a call to the application module, a call on the iterator(Like executeWithparams, etc.)
    Create an invokeAction in your pagedef and set the condition.
    This example refreshes(Action 2 is execute query) the data.
    First the method binding:
        <action IterBinding="PersoonIterator" id="Execute" InstanceName="LSAppModuleDataControl.Persoon"
                DataControl="LSAppModuleDataControl" RequiresUpdateModel="true" Action="2"/>And the invoke action
        <invokeAction Binds="Execute" id="refreshData"/>This always refreshes the data on page entry, but anything is possible, you can set condictions for the invokeAction.
    -Anton
    PS Yes I know that pagedefs become backing beans in the end and yes that is Java code, but if you wanna play the ADF way, the goal is the reduction of Java code and the increased performance of declarative programming.

  • How can I execute this procedure in sql developer, cursortype is refcursor

    PROCEDURE GET_CNTRY(CNTRY_NME_IN IN VARCHAR2 DEFAULT NULL,
    QRY_RSLT_OUT OUT CURSORTYPE) AS
    BEGIN
    OPEN QRY_RSLT_OUT FOR
    select
    CNTRY_NME,
    FRGN_CNTRY_CDE,
    INV_VEH_CNTRY_CDE,
    FRGN_CNCY_CDE,
    WTHH_PCT_COLA_CDE
    FROM
    CNTRY
    WHERE
    CNTRY_NME = NVL(CNTRY_NME_IN,CNTRY_NME);
    END GET_CNTRY;

    In SQL Developer run the following code as script (You need to hit F5 to run it as script).
    var rc refcursor
    exec get_cntry (<give your cntry_nme_in>, :rc)
    print :rc

  • Executing dynamic procedure with record type

    Hi,
    I have a small issue...I'm not attaching any tables / data..etc...I just want to know how to pass the record type to a procedure (which are actually obtained from a table) dynaically..Unable to form the sql statement..
    I get an error saying that "wrong number or types of arguments in call to ||"...
    -- see ** below where I'm getting an error.
    .Need to pass the whole record type "l_shl_order_msg"
    CREATE OR REPLACE PROCEDURE CM_BUILD_MSG_PRC (P_IN_BLD_MSG_CURSOR IN SYS_REFCURSOR,
                                                  P_OUT_BLD_MSG_CURSOR OUT SYS_REFCURSOR)
    IS
    l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ;
    V_MSG_SHELL_NAME VARCHAR2(1000);
    V_MESG_TEXT_SEGMENT VARCHAR2(1000);
    V_TEXT VARCHAR2(1000);
    V_MSG_TEXT VARCHAR2(4000);
    V_MSG_FINAL_TEXT VARCHAR2(4000);
    V_MSG_PROC VARCHAR2(1000);
    V_SQL VARCHAR2(4000);
    V_CNT NUMBER;
    L_STATUS  VARCHAR2(100);
    L_REASON  VARCHAR2(1000);
    BEGIN
    LOOP
          FETCH P_IN_BLD_MSG_CURSOR
            INTO l_shl_order_msg;
          EXIT WHEN P_IN_BLD_MSG_CURSOR%NOTFOUND;
    END LOOP;
    Select mesg_shell_text, mesg_dynamic_var_count
      into V_MSG_TEXT, V_CNT
       from CRAE_MESG_MASTER
        where mesg_shell_name = l_shl_order_msg.SHELL_ID;
      For i in 1..V_CNT
        LOOP
            SELECT MESG_SHELL_NAME, MESG_TEXT_SEGMENT, PROCEDURE_NAME
             INTO V_MSG_SHELL_NAME, V_MESG_TEXT_SEGMENT, V_MSG_PROC
              FROM CRAE_MESG_MASTER_DETAIL
                WHERE I = MESG_SEQ_NUMBER
                 AND  mesg_shell_name = l_shl_order_msg.SHELL_ID;
      V_SQL:= 'BEGIN '||V_MSG_PROC||'(''' || l_shl_order_msg|| ''',' ||
         '''' || V_MSG_SHELL_NAME || ''',' || '''' || V_MESG_TEXT_SEGMENT
         || ''', CRAE_INTERFACE.GLB_VAR_PKG.V_TEXT );'||'END;';
        DBMS_OUTPUT.PUT_LINE(V_SQL);
         EXECUTE IMMEDIATE (V_SQL);
         V_TEXT := CRAE_INTERFACE.GLB_VAR_PKG.V_TEXT;
         IF I = 1
           THEN
         V_MSG_TEXT := REPLACE(V_MSG_TEXT,V_MESG_TEXT_SEGMENT,V_TEXT);
         V_MSG_FINAL_TEXT := V_MSG_TEXT;
         ELSE
           V_MSG_FINAL_TEXT := REPLACE(V_MSG_FINAL_TEXT,V_MESG_TEXT_SEGMENT,V_TEXT);
         END IF;
    END LOOP;
       DBMS_OUTPUT.PUT_LINE(V_MSG_FINAL_TEXT);
    -- L_STATUS := CRAE_INTERFACE.GLB_VAR_PKG.V_STATUS;
    -- L_REASON := CRAE_INTERFACE.GLB_VAR_PKG.V_REASON;
    OPEN  P_OUT_BLD_MSG_CURSOR
    FOR
        SELECT  l_shl_order_msg.MESSAGE_DATE_TIME,
                 l_shl_order_msg.MASKED_ID,
                 l_shl_order_msg.OFFSET_DATE,
                 l_shl_order_msg.PATIENT_ACCOUNT_NUMBER,
                 l_shl_order_msg.ORDER_CONTROL,
                 l_shl_order_msg.PLACER_ORDER_NUMBER,
                 l_shl_order_msg.QUANTITY,
                 l_shl_order_msg.INTERVAL,
                 l_shl_order_msg.DURATION,
                 l_shl_order_msg.START_DATE_TIME,
                 l_shl_order_msg.END_DATE_TIME,
                 l_shl_order_msg.PRIORITY,
                 l_shl_order_msg.ORDERING_DATE,
                 l_shl_order_msg.ENTERED_BY_ID,
                 l_shl_order_msg.ENTERED_BY_FAMILY_NAME,
                 l_shl_order_msg.ENTERED_BY_GIVEN_NAME,
                 l_shl_order_msg.ORDERED_BY_ID,
                 l_shl_order_msg.ORDERED_BY_FAMILY_NAME,
                 l_shl_order_msg.ORDERED_BY_GIVEN_NAME,
                 l_shl_order_msg.REPEAT_PATTERN,
                 l_shl_order_msg.DRUG_CODE,
                 l_shl_order_msg.DRUG_DESCRIPTION,
                 l_shl_order_msg.REQUESTED_GIVE_AMOUNT,
                 l_shl_order_msg.REQUESTED_GIVEN_UNIT,
                 l_shl_order_msg.SIG,
                 l_shl_order_msg.ALLOW_SUBSTITUTION,
                 l_shl_order_msg.REQUESTED_DISPENSE_AMOUNT,
                 l_shl_order_msg.REQUESTED_DISPENSE_UNIT,
                 l_shl_order_msg.REFILLS,
                 l_shl_order_msg.ROUTE,
                 l_shl_order_msg.STATUS,
                 l_shl_order_msg.REASON,
                 V_MSG_FINAL_TEXT,
                 T.COMP_ID,
                 T.PROC_ID,
                 T.Procedure_Desc
              FROM CRAE_MESG_rule_MASTER T
               WHERE MSG_SHELL_NAME = l_shl_order_msg.SHELL_ID;
    --  dbms_output.put_line (l_shl_order_msg.MESSAGE_DATE_TIME);
    END;** I get an error saying that "wrong number or types of arguments in call to ||"...
    Not sure how to pass record type dynamically...

    sb,
    declare
        l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ;
        V_MSG_SHELL_NAME VARCHAR2(1000);
        V_MESG_TEXT_SEGMENT VARCHAR2(1000);
        V_SQL VARCHAR2(4000);
        V_MSG_PROC VARCHAR2(1000);
        begin
        V_SQL := 'BEGIN '||V_MSG_PROC||'(l_shl_order_msg)'||'END;';
           DBMS_OUTPUT.PUT_LINE(V_SQL);
          end;when I execute this...l_shl_order_msg is passed as variable..but instead I want to pass all columns in the recordtype to be passed..
    ex : l_shl_order_msg.id, l_shl_order_msg.name....etc..
    This is what is being passed :
    BEGIN ATTRIBUTE_PRC( l_shl_order_msg ,'CDS_1','text-1', CRAE_INTERFACE.GLB_VAR_PKG..V_TEXT );
    ATTRIBUTE_PRC has already been defines as record type with i/p parameter..
    Edited by: user7431648 on Jul 26, 2012 8:25 AM
    Edited by: user7431648 on Jul 26, 2012 8:27 AM

  • How can i sync my iphone with itunes without erasing its data?

    my computer crashed and i had to reinstall my windows,now i want to sync my iphone with the new itunes(with the same apple id) but it says all data should be erased from the device....is there some way to sync the iphone without the data being erased?

    Hello, I had this problem A few times. But there isn't A way I know. Keep the music on your computer and add them back after is what I do.

  • Calling Stored Procedure with table type as In parameter from Java

    Hi Everyone,
    Can anyone help me with the sample code to call a stored procedure having input parameter of Table type (consisting of multiple fields) from Java. This job is currently being done by a BPEL process.
    We want to implement the same using Java.
    Any sample code will be really helpful.
    Thanks & Regards,
    Vikas

    To start using a blob you have to insert it into the database and then get it back. Sounds weird but that is how it is. Here is a very simple program to do this:
    #include<occi.h>
    #include <iostream>
    using namespace oracle::occi;
    using namespace std;
    int main()
      try
        Environment *env = Environment::createEnvironment(Environment::OBJECT);
        Connection *conn = env->createConnection("hr","hr","");
        string stmt1 = "insert into blob_tab values (:1) ";
        string stmt2 = "select col1 from blob_tab";
        Blob blob(conn);
        blob.setEmpty(conn);
        Statement *stmtObj = conn->createStatement(stmt1);
        stmtObj->setBlob(1,blob);
        stmtObj->executeUpdate();
        conn->commit();
        Blob blob1(conn);
        Statement *stmtObj2 = conn->createStatement(stmt2);
        ResultSet *rs = stmtObj2->executeQuery();
        while(rs->next())
         blob1 = rs->getBlob(1);
        string stmt3 = "begin my_proc(:1) ;end;";
        Statement *stmtObj3 =  conn->createStatement(stmt3);
        stmtObj3->setBlob(1,blob1);
        stmtObj3->executeUpdate();
      catch (SQLException e)
        cout << e.getMessage();
      /* The tables and procedure are primitive but ok for demo
        create table blob_tab(col1 blob);
        create or replace procedure my_proc(arg in blob)
        as
        begin
         -- just a putline here. you can do other more meaningful operations with the blob here
          dbms_output.put_line('hello');
       end;
    }Hope this helps.
    Thanks,
    Sumit

  • Execute a procedure with a list of array in sql server 2008

    HI all,
    I have a procedure which has a list of values passed as an array . How can i execute my procedure with array list? how to implement this?Please help me.
    Thanks in advance
    Deepa

    Hi Deepa,
    basically Microsoft SQL Server does not support arrays as data types for procedures. What you can do is creating a type which represents a table definition. This type can than be used in a procedure as the following demo will show:
    The first script creates the environment which will be used for the execution
    -- 1. create the table as a type in the database
    CREATE TYPE OrderItems AS TABLE
    ItemId int PRIMARY KEY CLUSTERED
    GO
    -- 2. demo table for demonstration of results
    CREATE TABLE dbo.CustomerOrders
    Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY CLUSTERED,
    CustomerId int NOT NULL,
    ItemId int
    GO
    -- 3. Insert a few records in demo table
    INSERT INTO dbo.CustomerOrders
    (CustomerId, ItemId)
    VALUES
    (1, 1),
    (2, 1),
    (3, 3),
    (1, 3);
    GO
    -- 4. Create the procedure which accepts the table variable
    CREATE PROC dbo.OrderedItemsList
    @Orders AS OrderItems READONLY
    AS
    SET NOCOUNT ON;
    SELECT o.*
    FROM dbo.CustomerOrders AS O INNER JOIN @Orders AS T_O
    ON (o.ItemId = T_O.ItemId);
    SET NOCOUNT OFF;
    GO
    The above script creates the table data type and a demo table with a few demo data. The procedure will accept the table data type as parameter. Keep in mind that table variable parameters have to be READONLY as parameter for procedures!
    The second script demonstrates the usage of the above scenario
    When the environment has been created the usage is a very simple one as you can see from the next script...
    -- 1. Fill the variable table with item ids
    DECLARE @o AS OrderItems;
    INSERT INTO @o (ItemId)
    VALUES
    (1), (3);
    -- 2. Get the list of customers who bought these items
    EXEC dbo.OrderedItemsList @Orders = @o;
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

  • Ever used the Table API (TAPI) with object type in the DB?

    Hi all,
    We are trying to generate the table API of a table that has a column defined by an object type. It works without problems if that column always has a value (is instantiated in object term). The problem is when we update a row where the column is null (all attributes of the object are null thus the object is not instantiated).
    The "before update row" trigger of the Table API fails with error "ora-30625-method dispath on NULL SELF argument is disallowed".
    Any of you guys made it work? If so, how?
    Thanks

    user8879206 wrote:
    Hi friends,
    I have a procedure with object type IN OUT parameters which is used for fetching status. We are calling this from Java. But I want to call it from oracle for testing purpose. I am trying from my end but not able to do it as of now. This is the first time I am dealing with object type.We need more information. What is wrong? Your code looked okay and you did not mention any Oracle errors. What is happening that should not be or not happening that should be?
    You can call the procedure with a simple call in PL/SQL but will not be able to use it in SQL because 1) it is a procedure and 2) it has an OUT argument. A sample call should look something like (untested)
    declare
       x rec2;
       y rec3;
    begin
      --use the arguments rru was defined with as the arguments in the same order: types rec2 (x), rec3 (y)
      rru(x,y);
    end;>
    Any help would be appreciated.
    Details are given below.
    CREATE OR REPLACE TYPE REC1 AS OBJECT
    (RELAY_USAGE VARCHAR2(30)
    ,STATE VARCHAR2(1)
    TYPE REC AS TABLE OF REC1;
    CREATE OR REPLACE TYPE REC2 AS OBJECT
    (GSRN VARCHAR2(18)
    ,METERING_POINT_NAME VARCHAR2(80)
    ,RELAYS REC)
    CREATE OR REPLACE TYPE REC3 AS OBJECT
    (INFO VARCHAR2(2000)
    ,STATUS NUMBER
    PROCEDURE RRU(
    rcRelayControl IN OUT REC2
    , rcResp IN OUT REC3)
    IS
    BEGIN
    APKG.GetDetails(rcRelayControl, rcResp);
    IF rcResp.Status = BPKG.iStatusFailure THEN
    rcResp.Info := BPKG.Get_Message('20889', rcResp.Info);
    END IF;
    END RRU;
    How to call this procedure in oracle?
    Thanks.

  • How can i execute trigger from procedure

    Hi
    How can i execute trigger when-button-pressed from procedure.
    I knew i have to get the button name and then execute the trigger When-button-pressed.
    but how can i do that.
    Thanks
    null

    how can i execute trigger
    such as When-Button-Pressed on item name "item1"
    and i have more than one trigger with this name on onther
    items
    i know Execute_Trigger('when-button-pressed');
    but any trigger
    for example :
    Execute_Trigger('Item1.when-button-pressed');
    or
    Execute_Trigger('Item2.when-button-pressed');
    or
    other syntax
    i dont know
    please help me
    my email : [email protected]
    Hani

Maybe you are looking for

  • Opening a jar file

    hey all, i only have one class that i want to make a jar file. i make sure the msdos prompt is focused on the right folder, and i use the following command line... jar cf writer.jar writer.class it makes a jar file without any problems, but when i go

  • What imac for me? Recommendations please!!!

    I am thinking of getting one of the new imac i7 3.4GHz. I am using FCE and Logic Studio with tons of plugins like BFD2 and Amplitube etc. Will these new machines handle the programs properly unlike my current 2.33 GHz Core 2 Duo with 3 GB RAM. And if

  • Automatic import-help

    Hello forum,maybe somebody has wonder about this problem, is there a way in jdev903_pre to do the import of like, import javax.ejb.EJBObject;if it is missing ? or one has to find what package the class is manually ? is that the only way ? I am just a

  • Skinning table. Change width of the table.

    I want to change width of all table so that sub-control-bar gets affected too. I've learned that there's no way to define it that way: af|table { width:60%; and if I write: af|table::content { width:60%; and then change width of sub-control-bar compo

  • I take photos in B/V and den whith importing to Aperture , they is in color . What to do

    I take photos in B/W and then whith importing in Aperture , it is in color ??????