Procedure - in a output parameter

Hi all

I create one procedure. Below is my code

create or replace procedure sqroot

(

x number

)

is

Start

x: = x x;

end;

declare

a number;

Start

a: = sqroot (4);

end;

I get the following error

"Error from line: 10 in order--

declare

a number;

Start

a: = sqroot (4);

end;

Error report-

ORA-06550: line 5, column 7:

PLS-00222: no function with name "SQROOT" does exist in this scope

ORA-06550: line 5, column 3:

PL/SQL: Statement ignored

06550 00000 - "line %s, column % s:\n%s".

* Cause: Usually a PL/SQL compilation error.

* Action.

Kindly advice

I create one procedure. Below is my code

create or replace procedure sqroot

PLS-00222: no function with name "SQROOT" does exist in this scope

The procedure does NOT exist while you cannot reference it inside the procedure.

Use a "forward declaration" to declare the non-existent function. See the example provided in the Oracle documentation

http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/subprograms.htm#CIHIAEDF

Forward declaration

If nested in the same block of PL/SQL subprograms call each other, then one requires a forward declaration, because a subroutine must be declared before it can be invoked.

A forward declaration declares a nested subroutine, but does not define it. You define it later in the same block. The forward declaration, as well as the definition must have the same position of subprogramme.

In the example 8-8, an anonymous block creates two procedures that call each other.

Example 8-8 nested subprograms invoke each other

Tags: Database

Similar Questions

  • A stored procedure with input & output parameter as XML

    Hello

    I have a requirement in which I need to have a stored procedure accepts with huge XML from Java and MS a process all the records in the XML file and return the output with a few messages inside XML.

    CurrentY, I have a stored procedure to process the xml code stored in the Oracle database.

    I am using the following SQL statement to read data from the XML column.
    select xmltest1.id,xmltest1.name 
      from xmltest,
           XMLTABLE(
              XMLNamespaces(default 'syncpsna/schemas'),
              '/XMLTestRequest/insert/row'
                    PASSING xmltest.data_xml
                    COLUMNS
                    "ID" number(10) PATH 'id',
                    "NAME" varchar2(50) PATH 'name') xmltest1
    where xmltest.id = 2;
    I want to run similar queries to retrieve data from the XML passed as parameter of entry of JAVA.

    If I could get some examples to read the XML and return the xml to the calling program.

    Concerning

    I can run the query to extract the different sections in the xml file when the XML is stored in a table column. How can do the same thing on XML passed as an input parameter.

    Pretty much the same path, using the clause of PASSAGE.
    Assuming that the input XML is passed as parameter 'p_inputXML', you can do:

    SELECT x.id
         , x.name
    FROM XMLTable(
           XMLNamespaces(default 'syncpsna/schemas'),
           '/XMLTestRequest/insert/row'
           PASSING p_inputXML
           COLUMNS
             "ID"   number(10)   PATH 'id',
             "NAME" varchar2(50) PATH 'name'
         ) x
    ;
    
  • Is the version of the output parameter 32 bits 12.1.0.2 Oracle ODBC driver truncating values a known issue?

    We test 12.1.0.2 Oracle and ODBC see problems with the stored procedure being cut output parameter values and Associates when we use the 12.1.0.2 driver (we use the 32-bit version). We see a function sequence error every time that happens, too.

    For example, a stored procedure takes a NVARCHAR2 name and it out as a separate NVARCHAR2 output parameter. Using the 12.1.0.2 of the ODBC driver, if we "Basketball", the output can be "Basketball" (with a function sequence error).

    What is happening to many of our stored procedures. We do not get the errors of sequence of function or output truncated if parameters we use the 12.1.0.1 version of the ODBC driver to connect to our 12.1.0.2 database, or if we use the version 11.2.0.4 or 11.2.0.2 ODBC driver.

    Is this a known problem in the 12.1.0.2 ODBC driver?

    Thank you

    Daniel Meyer

    to submit a bug report to MOS

  • How to run a procedure with the object as OUTPUT parameter

    Hello

    I have a procedure and it composed of 2 parameters, there is an input parameter and it's some ID (NUMBER datatype) and 2nd parameter is an output parameter and it an object type. I want to run this procedure, but not able to do the same thing. Can someone please suggest me how to run a procedure that got the object as output parameter.

    Thank you very much 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 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;
      }
    }
    
  • SQL stored procedure input and output parameters

    Hello Gang,

    My dead end trying to call a stored procedure in SQL Server 2008 with the LV database tool.

    for purposes of experimentation, I've created a small procedure with an input parameter that returns an integer as return value.  It works describing a query, but all attempts at LV produce an error-2147217900 when executing query VI.  I did find examples of that.

    Sending a bunch of parameters to a stored procedure and checking the value of return seems to be pretty common stuff.

    I'll appreciate any help.

    Thank you

    Roger

    Hi Roger,

    There are a few prerequisites which I will list below. If you have not checked these things, so don't hesitate, as your hiccups can be there.

    Prerequisites:

    1. Ensure that you can read from a table in the database to verify that you can access the database (user permissions) and ensure that your login details are correct. Among other things, make sure that the. DSN switches to the correct database. (See the simple example below, SQL Select.vi)
    2. Make sure that your user (if you use SQL authentication) has permissions to run the STORED procedure by running the procedure in SQL Server Management Studio (you seem to have already done this)

    Example by calling a procedure without parameters (attached as SPROC_No_Parameters.vi):

    Example by calling a procedure with parameters (attached as SPROC_Parameters.vi):

    An article on the execution of stored procedures is here:

    http://digital.NI.com/public.nsf/allkb/07FD130746083E0686257300006326C4

    Don't forget to download the example VI since it includes the cases where you want an output parameter of the procedure rather than a table.

    I tested these against two very simple SPROCs and it worked fine (on SQL Server 2005, but 2008 should be the same).  Stored procedures have been:

    CREATE PROCEDURE [dbo]. [GetContacts]

    AS
    BEGIN
    -SET NOCOUNT ON added to avoid additional results sets from
    -interfering with SELECT statements.
    SET NOCOUNT ON;

    -Controls insert for procedure here
    SELECT * FROM Contacts
    END

    and

    CREATE PROCEDURE [dbo]. [MultiplyAges]
    @param1 INT = 1
    AS
    BEGIN
    -SET NOCOUNT ON added to avoid additional results sets from
    -interfering with SELECT statements.
    SET NOCOUNT ON;

    -Controls insert for procedure here
    SELECT (age * @param1) OF Contacts
    END

    I would like to know if these examples work for you or if you have any other questions.  Don't forget to go through this KB article and articles related to it, they should cover other situations.

    Matt

  • Service Web REST-output parameter does not work in the Manager POSITION

    I created a RESTful Web Service in Oracle Apex, using a POST method as a 'Manager'   I have installation 11 input parameters which all work fine, this is my setting an output that does not return successfully.

    Here are details on the output parameter

    Name: returns

    Name of the bind Variable: : return

    Access method: OUTPUT

    Source type: response

    Parameter type: String

    The actual source is a call to a pl/sql package that returns a value that I set: Returns equal to (for example: Returns: = v_result).   I tried this with header Type of Source and still the same result, "no exit".

    I see APEX calls wwv_flow_api.create_restful_param to generate the (import) settings, is there documentation on this procedure?

    How can I get this output parameter to return something to the answer?

    The application accepts a load of Json.

    Any help greatly appreciated

    Thank you

    James

    Solved my problem: feedback does not need to go back

    Does not work

    Name: returns

    Name of the bind Variable: : return

    Access method: OUTPUT

    Source type: response

    Parameter type: String

    Works

    Name: returns

    Name of the bind Variable: returns

    Access method: OUTPUT

    Source type: response

    Parameter type: String

  • Entity Framework stored procedure Mapping - OUT unrecognized parameter

    I use the following software:

    • ODP.NET 12 c Release 3
    • Entity Framework 6
    • Visual Studio 2013, SP3
    • Oracle 11g Server

      I created a package containing a stored procedure to update a row in a table.  The procedure is an OUT parameter (named ROWS_AFFECTED) which returns the number of rows affected.

      CREATE OR REPLACE PACKAGE BODY TST. Customer_Procs
      AS
      PROCEDURE Update_Customer
      (
      CUST_ID IN NUMBER,
      WHAT IN VARCHAR2,
      L_NAME IN VARCHAR2,
      EMAIL IN VARCHAR2,
      LAST_UPDATE TIMESTAMP IN
      ROWS_AFFECTED NUMBER
      )
      AS
      BEGIN
      UPDATE
      TST. CUSTOMER
      SET
      NAME = WHAT,.
      LAST_NAME = L_NAME,
      EMAIL_ADDR = EMAIL,
      LAST_UPDT_TIME = CURRENT_TIMESTAMP
      WHERE
      CUSTOMER_ID = CUST_ID
      AND LAST_UPDT_TIME = LAST_UPDATE;

      ROWS_AFFECTED: = NUMBER OF ROWS SQL %;

      END Update_Customer;


      I executed successfully the stored procedure in SQL * more.  The ROWS_AFFECTED OUT parameter is filled with the good

      value.

      I imported the stored procedure in my Entity Framework model using the function successfully import.

      I then traced the parameters of the stored procedure to my entity properties. The ROWS_AFFECTED parameter is shown in the stored procedure mappings, but the "rows affected parameter" check box is cleared.

      Attempt to run my results in the following exception being throw:
      "CustomerModel.msl (22,12): error 2047: a mapping liaison function specifies a function.

      CustomerModel.Store.CUSTOMER_PROCS_UPDATE_CUSTOMER with a parameter not supported: ROWS_AFFECTED. Output parameters cannot

      be mapped through the RowsAffectedParameter property. Use the result links to return values from a function call.

      I am trying to determine what I need to do in order to have the Entity Framework to recognize the ROWS_AFFECTED OUT parameter in the

      stored procedure chart for concurrency control.

      I found a solution: try to declare ROWS_AFFECTED such as 'PLS_INTEGER' instead of 'NUMBER '.  This solved it for me.

    • problem with the definition of a boolean as output parameter type

      Hi, I have a problem with the definition of type boolean as output parameter and it must return true if the query procedure retrieves one line else it shouuld return false

      Hi, I have a problem with the definition of type boolean as output parameter and it must return true if the query procedure retrieves one line else it shouuld return false

      And what are the issues? Its simple.

      SQL> create or replace procedure is_emp_exist
        2  (
        3     p_empno  in  emp.empno%type
        4   , p_result out boolean
        5  )
        6  as
        7     l_empno emp.empno%type;
        8  begin
        9     select empno into l_empno
       10       from emp
       11      where empno = p_empno;
       12
       13     p_result := true;
       14  exception
       15     when no_data_found then
       16        p_result := false;
       17  end;
       18  /
      
      Procedure created.
      
      SQL> declare
        2     l_result boolean;
        3  begin
        4     is_emp_exist (7788, l_result);
        5
        6     if l_result then
        7        dbms_output.put_line('Employee Exist');
        8     else
        9        dbms_output.put_line('Employee does not Exist');
       10     end if;
       11  end;
       12  /
      Employee Exist
      
      PL/SQL procedure successfully completed.
      
      SQL> declare
        2     l_result boolean;
        3  begin
        4     is_emp_exist (1000, l_result);
        5
        6     if l_result then
        7        dbms_output.put_line('Employee Exist');
        8     else
        9        dbms_output.put_line('Employee does not Exist');
       10     end if;
       11  end;
       12  /
      Employee does not Exist
      
      PL/SQL procedure successfully completed.
      
      SQL>
      
    • Appeal procedure in another procedure using the Out parameter slider - lesson

      Hello

      I am new to Oracle development so first I wonder if it is a good place with a simple way of the of on how to create stored procedures?  I'm looking for the most part at this stage for a quick read.

      Second, currently have hacked and slashed my way into getting one built.  It has 3 parameters and an output parameter sys_refcursor.  This procedure works.

      I want to have another created procedure that will call the above procedure and loop through each row in the setting out and write to a file.  Can someone point me to an example of this by any chance?

      Thanks for the help.

      Hello

      e28d78d3-c6c6-4BCE-b14f-0f6bf26fa17c wrote:

      Thanks for the reply.

      Here's what I have, but I'm getting many errors.  When I seem to fix one that I get a new one. Kind of like what it show me all questions vs one question at a time.  I never know if I create another error of my attempts at fixing what, in my view, could be the problem.  In any case, something to get used to.

      When you do any type of programming, take baby steps.  Write less code as possible, test what you wrote ' worm and, if it contains errors, correct them and test again.

      The PL/SQL compiler tries to show all errors, but often it is impossible to say what is a separate mistake, and which is a consequence of a previous error.  For example, the DECLARE statements in your code are perfectly valid PL/SQL statements, but they are the mistakes in the sense that they are not what you think, and you may not use them.  PL/SQL does not know that (I don't really know that, either, but I'm willing to guess in this case).  The works of compiler on the explanation that you really wanted to say SAID, until what it becomes obvious, maybe several lines later, that something makes no sense, but at this time, there is no way he could say that the undesirable DECLARE was the cause.

      So here is where I am stuck currently.  What I want should first, run the stored procedure and I think I do as you suggest.  Which returns data in the output parameter, which is of type sys_refcursor.  I think I would need to loop through each element that cursor and output to the file using the dbms_output you reference and like I did below.  This should be it.  Sounds simple enough, but it's where some of the basics for me.

      For example, by creating the procedure some examples have the name of the procedure and then some "AS", "IS".  When use the beginning and the end and when not I need?

      There is no difference betwwen

      CREATE PROCEDURE... AS and

      CREATE PROCEDURE... Use IS the one you prefer.  You must always one or the other, however.

      PL/SQL is written in blocks.  The basic structure of a block is

      DECLARE - optional, sometimes involved

      ...

      BEGIN

      ...

      -Optional EXCEPTION; forget it for now

      ...

      END;

      Almost all of the PL/SQL code is part of a block.  In fact, you could argue that anything not in a block isn't really PL/SQL.  (For example, CREATE PROCEDURE is really an SQL, PL/SQL not, it indicates the SQL that some PL/SQL compiler is coming.)

      You should always BEGIN and END keywords in a PL/SQL block; None is never optional.

      I think I'm doing the for loop correctly but I get an error on the portion of loop-end.  It is a part of these simple things that become I think that.

      That's what I have:

      CREATE OR REPLACE PROCEDURE APPS.boact_report_3

      AS

      DECLARE v_cur SYS_REFCURSOR;

      DECLARE v_file_out UTL_FILE.file_type;

      BEGIN

      I said earlier, DECLARED may be implied.  It's one of those places if there is nothing after CREATE PROCEDURE... IS and before STARTING, it is supposed to be a statement.

      You can have as many statements (0, 1, 2 or more) that you want in this section of the statement.  The semicolon at the end of each of them is all the separation you need each other; you don't need any keyword as STATED.

      Open the v_cur for

      bo_report (p_sv_id, p_start_date, p_end_date, out v_cur);  -stored procedure that girls v_cur witch is a sys_refcursor parameter.  It works

      END;

      BEGIN

      Don't forget, how to call a procedure is

      bo_report (x, y, z);

      not

      bo_report (x, y, z OUT);

      The key words are only necessary (and only used) in the declaration of a procedure, not in his appeal.  When you create a procedure, you decide if each argument is going to be an argument IN, an OUT argument, or IN OUT argument, and you tell the compiler that you decide.  When you call a procedure, you have no choice; each argument is IN, OUT or IN OUT has already been decided, and suffice to say compiling what are the variables (or expressions) that you use to play these predetermined roles.

      Dbms_output.put_line ('Date: ');

      v_file_out: =.

      UTL_FILE.fopen (' / public/scripts/smorau02 ', 'w_act.csv', 'W');

      FOR x IN v_cur

      LOOP

      () UTL_FILE.put_line

      v_file_out,

      x.cl_num | ','

      || x.wa_id | ','

      || x.Description | ','

      || x.a_date | ','

      || x.a_by | ','

      || x.v_Name | ','

      || x.SITE_NAME | ','

      || x.stage | ','

      || x.in_queue);

      END LOOP;

      UTL_FILE.fclose (v_file_out);

      END;

      Thanks again for the help.

      You have not to send the code to bo_report, so I can't run the procedure.  I do not notice any obvious mistakes immediately superior.

    • Procedure with input output and num_array sys_refcursor

      Hello

      I have to write a procedure with input of type of parameter num_array which will forward a list of IDs to the procedure and the output is sys_refcursor that will pass the id with the other columns in the table to the list of identifiers.

      operating system is the table with the id, os_name column with more than a few columns.

      create table os

      (identification number,

      OS_name varchar2 (30),

      .. .few more columns);

      I spend the os_name with id through the sys_refcursor.

      So I created the following procedure.

      num_array is a type of data defined by the user that is created as follows:

      create or replace type num_array in the table to the number;

      /

      create or replace procedure get_os_lang_dtls (num_array, id_os sys_refcursor id_num)

      is

      Start

      / * oses is the main table with id, os_name with other columns

      / * oses_gtt is the temporary table with id number data type varchar2 os_name * /.

      for indx in 1.id_num.count

      loop

      insert into os_gtt

      SELECT id, os_name

      of the operating system

      where id = id_num (indx);

      end loop;

      commit;

      Open the id_os for

      Select * from os_gtt;

      end;

      /


      I created a global temporary table with the column id and os_name.

      Insert in this table by using the id of i / p and setting os_name recovery operating system for this id in the loop.


      Then I open the exit sys_refcursor.


      Could someone please suggest me a better way to write the same logic?


      Thanks in advance

      No need of the TWG or anything too flashy here.

      Since you have a SQL type, you should be able to get away with...

      open out_ref_cursor for
      select 
      from os, table(cast(id_num as num_array)) nu
      where os.id = nu.column_value;
      

      A couple of notes apart from that. ID is not a great name for a column, why not OS_ID to be online with your OS_NAME? Second, always try to avoid use of the TWG, they are handy once in awhile, but not required nearly as often as find you them.

      A "rebate" in the casting of tables like that and their use in SQL is the cost based optimizer usually (depending on version) has no idea of how to do to optimize the query (it has no statistics on the table as it does on a table). In General, if you know that you have X items in this table, it is better to say Oracle. You can use the CARDINALITY indicator to tell Oracle about the number of lines, you expect your table to have on average. The default proposal is going to be your block size, so assuming that 8 k (standard) the estimate is going to be like 8000 items... probably not close to reality.

      See you soon,.

    • Output parameter is not created to Invoke in

      Hello

      I have a procedure with one IN and an OUTPUT parameter, I configured the DB adapter to call this procedure. Now using BPEL, when I call this procedure in the input variable only activity invoke gets does not create variable pitch, setting the EXIT procedure. What could be the problem? Please help me.

      concerning

      Nasir

      Thanks for your reply.

      I solved the problem, in fact, I was using a mediator for the transformation component. Now I just removed and used the transformation without him and it works now

    • An operator of power output parameter mapping

      Hello. I use on the 11.2.0.2.0 Oracle Database 11.2.0.2 OWB.

      I fight and need a pointer. I am trying to create a map that will pass parameters to USER_DEFINED operator in a process flow. I'm going by the following example.

      http://blogs.Oracle.com/warehousebuilder/entry/how_to_use_user_defined_activity_in_owb_process_flow

      But he gives no details on how to build the mapping. The settings I want to spend are stored in a database table, and I have a packaged procedure that takes a parameter (the key) and returns the three parameters that must be passed all the way to the user_defined in the process flow. The procedure basically collects the values of the parameters as the lines and the pivots in columns.

      I created a map containing a constant for the key, a mapping process before you run the proecedure and an operator of output parameter of mapping as the target of the mapping. I don't know if the prior mapping process is what I use. But I don't know what else to try. As it is, the mapping will not validate.

      I had already tried to use an operator unpivot instead of the procedure (btw, why do pivot/unpivot have meaning in SQL and the reverse in OWB?).

      Please suggest the best approach to send my parameter values to the output parameter of mapping operator. Thank you.

      Hello

      I suggest you write a pl/sql procedure to the hand that holds the key as a parameter and the three return values as of the settings out. Import it in owb and drag it in the process flow. Bind variables of process flow to the transformation parameters, then to USER_DEFINED operator settings.

      Kind regards
      Carsten.

    • The formal parameter, quot;@CCNumber &amp; quot; was not declared as OUTPUT parameter

      This stored procedure was working till last week and I do not remember change all the input variables / outputs, so I don't know why I get the error message I get. I counted and tells all the parameters in the CF to ensure that none are missing, but SQL still think I'm missing something. Can someone take a look at the code and see why SQL account 53 settings when there is really some 54?

      The beginning of MS:

      ALTER PROCEDURE [dbo]. [pr_EnterWebOrder]
      @User_Fk int,
      @Coupon_Fk int,
      @GiftCertificate varchar (200),
      Silver @GCAmount,
      @OrderNotes varchar (200),
      @PaymentMethod varchar (10),
      @CreditCard_Fk int,
      @BillTitle varchar (10),
      @BillFirstName varchar (50),
      @BillLastName varchar (50),
      @BillMiddleName varchar (50),
      @BillCompanyName varchar (50),
      @BillAddress varchar (2000).
      @BillCity varchar (50),
      @BillState_Fk int,
      @BillZip varchar (20),
      @BillProvince varchar (50),
      @BillCountry_Fk int,
      @BillPhone varchar (50),
      @BillExt varchar (8),
      @BillEmail varchar (100),
      @ShipTitle varchar (10),
      @ShipFirstName varchar (50),
      @ShipLastName varchar (50),
      @ShipMiddleName varchar (50),
      @ShipCompanyName varchar (50),
      @ShipAddress varchar (2000).
      @ShipCity varchar (50),
      @ShipState_Fk int,
      @ShipZip varchar (20),
      @ShipProvince varchar (50),
      @ShipCountry_Fk int,
      @ShipPhone varchar (50),
      @ShipExt varchar (8),
      @ShipEmail varchar (100),
      @OrderEditor_Fk int,
      @AdminUUID char (35),
      @CreditAccount int,
      @TransactionNumber varchar (20),
      @AffiliateCode varchar (50),
      @Register int,
      @OrderSource_Pk int,
      @CheckoutCharity int,
      @AuthCode varchar (6).
      @AffiliateLinkType int,
      Silver @CreditReceived,
      Silver @CashReceived,
      @PONumber varchar (20),
      @PromisedDate DateTime,
      @ShipDate DateTime,
      @CheckNumber varchar (20),
      @CCNumber varchar (200),
      @CCExpDate int,
      @Order_Pk int OUTPUT,.
      @OrderNumber varchar (20) OUTPUT

      The CF code calling:


      The error message in SQL. Notice that he just thinks there are 53 settings when there are 54:

      SQLSTATE HY000
      SQL {call pr_EnterWebOrder ((param 1), (param 2), (param 3), (param 4), (param 5), (param 6), (param 7), (param 8), (param 9), (param 10), (param 11), (param 12), (param 13), (param 14), (param 15), (param 16), (param 17), (param 18), (param 19), (param 20), (param 21), (parameter 22), (param 23), (24 param), (param 25), (param 26), (param 27), (param 28), (param 29) (param 30)} (, (param 31), (param 32), (param 33), (param 34), (35 param), (param 36), (param 37), (38 param), (param 39), (param 40), (param 41), (param 42), (param 43), (param 44), (param 45), (param 46), (param 47), (param 48), (param 49), (param 50), (param 51), (param 52), (param 53))}

      [Macromedia] [SQLServer JDBC Driver] [SQL Server] The formal parameter '@CCNumber' declared as OUTPUT, but the real parameter output parameter.

      Found the answer. CF error incorrect when you send an empty value for a cfsqltype DATE in a cfprocparam tag. Rather than tell you that data types do not match, it seems that it removes this procparam from the code.

    • Impossible to activate and deactivate the button "submit" all keeping the condition on the output parameter

      Hello

      I try to enable and disable the submit button based on the status of output parameter that I call in lov.

      Concerning

      Asia.


      Hi AJ,.

      Thanks for the reply

      I tried the method above, but it does not work.

      I am trying to enable and disable the submit button based on two input parameters and an output parameter.

      Based on two input parameters, I'm able to get the output parameter, and if the output parameter is "S" then iam allowing the submit button.

      on the other

      disable the submit button.

      Here is my code:

      IAM calling this co

      OASubmitButtonBean submitbean = (OASubmitButtonBean) webBean.findChildRecursive ("Submit");

      String crreason = pageContext.getParameter ("Reason")';

      Invnum string = pageContext.getParameter ("InvoiceNumber");

      String status = "";

      String ValidationDesc ="";

      OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl) getTransaction ();

      Try

      {

      String sql_qry = "BEGIN WEPIS_CM_DM_PKG. WEPIS_CM_RAISE_VALIDATION (P_CM_REASON =>: 1, P_INVOICE =>: 2, P_VALDIDATION_S "+)

      "(TS =>: 3, P_VALDIDATION_DESC =>: 4); END; « ;

      OracleCallableStatement sqlstmt = (OracleCallableStatement) oadbtransactionimpl.createCallableStatement (sql_qry,-1);

      sqlstmt.setString(1,crreason);

      sqlstmt.setString(2,invnum);

      sqlstmt.registerOutParameter(3,Types.CHAR);

      sqlstmt.registerOutParameter(4,Types.VARCHAR);

      sqlstmt. Execute();

      status = sqlstmt.getString (3);

      ValidationDesc = sqlstmt.getString (4);

      If ("S".equals (status))

      {

      submitbean.setRendered (true);

      }

      on the other

      {

      submitbean.setRendered (false);

      }

      }

      catch (SQLException sqlexception)

      {

      throw OAException.wrapperException (sqlexception);

      }

      catch (System.Exception Exception)

      {

      throw OAException.wrapperException (exception);

      }

      Concerning

      S.Asia

    Maybe you are looking for