Run the statement in a stored procedure with Out parameters and

Hi all

I have a stored procedure that calls a select statement. Here it is...

CREATE OR REPLACE PROCEDURE BLABLA_VIEW_PROCEDURE

* (BLABLA_KEY IN NUMBER, *)
XML_OUTPUT ON VARCHAR)
AS
BEGIN
SELECT SYS. XMLTYPE.getStringVal (OBJECT_VALUE) in XML_OUTPUT FROM BLABLA_VIEW WHERE extractValue (OBJECT_VALUE, ' / BLABLA_TYPE/BLABLA_KEY ') = 2876;
END;

Is to have both IN and OUT parameters as described above. I am able to compile and run the procedure.

The problem I want to share with everyone is...
I want to run the stored procedure together with a single EXEC command.

I tried different ways using the EXEC command but of no use.

Could someone help me?
Thanks in advance.

Published by: user10763276 on June 3, 2010 15:47

Please visit the following...

sudhakar@ORCL>CREATE OR REPLACE PROCEDURE BLABLA_VIEW_PROCEDURE
  2  (BLABLA_KEY IN NUMBER,
  3  XML_OUTPUT OUT VARCHAR)
  4  AS
  5  BEGIN
  6  XML_OUTPUT := BLABLA_KEY || ' and whatever else...';
  7  END;
  8  /

Procedure created.

sudhakar@ORCL>
sudhakar@ORCL>var XML_OUTPPUT varchar2(100);
sudhakar@ORCL>exec BLABLA_VIEW_PROCEDURE (9151, :XML_OUTPPUT);

PL/SQL procedure successfully completed.

sudhakar@ORCL>print XML_OUTPPUT;

XML_OUTPPUT
--------------------------------------------------------------------------------
9151 and whatever else...

sudhakar@ORCL>

Post tells you...

var OUTPUT VARCHAR
exec BLABLA_VIEW_PROCEDURE (9151, :OUTPUT);
print OUTPUT

VARCHAR is not a valid TYPe to declare. Use VARCHAR2 (nnn) where nnn is a number.
VR,
Sudhakar B.

Tags: Database

Similar Questions

  • ORA-06565: cannot run the ROLE VALUE from stored procedures

    Hello!

    I'm trying to call a procedure from a function. Among the statements in the procedure stored is of dbms_session.set_role ('HAVE');

    I get the error "Cannot run a DEFINED ROLE less stored proceduers". I joined the call in an anonymous block above, but the error still exists.

    Any idea will really help me.

    Thank you

    >
    I'm trying to call a procedure from a function. Among the statements in the procedure stored is of dbms_session.set_role ('HAVE');

    I get the error "Cannot run a DEFINED ROLE less stored proceduers". I joined the call in an anonymous block above, but the error still exists.

    Any idea will really help me.
    >
    This will work only if the procedure is defined for the APPELLANT's rights.

    Roles are disabled in named PL/SQL blocks unless you use of the APPELLANT's rights by setting the code with AUTHID CURRENT_USER.

    The Oracle documentation provides a very clear explanation - based restriction is for the NAMED PL/SQL blocks rights DEFINER of this use (the default):
    >
    Roles used in the appointed with rights to define blocks

    All roles are disabled in any PL/SQL block named (stored procedure, function, or trigger) that runs with the rights of the author. Roles are not used to privilege control, and you cannot define roles within the procedure of a DEFINER rights.
    >
    The database Security Guide has the information in the section "operation of the roles in PL/SQL blocks (which, of course, wouldln was necessary if they didn't work.).
    http://docs.Oracle.com/CD/B28359_01/network.111/B28531/authorization.htm#i1007304
    >
    The use of roles in a PL/SQL block depends on if it is an anonymous block, or a block named (stored procedure, function, or trigger), and if it runs with the rights of the author or the rights of the applicant.

    Roles used in the appointed with rights to define blocks
    All roles are disabled in any PL/SQL block named (stored procedure, function, or trigger) that runs with the rights of the author. Roles are not used to privilege control, and you cannot define roles within the procedure of a DEFINER rights.

    The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that runs with DEFINER SESSION_ROLES rights issues, the query returns no rows.

    See also:

    Oracle database reference

    Roles used in blocks named with the rights of the plaintiff and anonymous PL/SQL
    Named PL/SQL blocks that run with the rights of the applicant and the anonymous PL/SQL blocks are executed at the end of the privileges granted through active roles. Current roles are used for verification within rights Summoner of privilege the PL/SQL block. You can use dynamic SQL statements to define a role in the session.

  • Cannot run RUN IMMEDIATELY statement in a stored procedure.

    Hi people,
    I use oracle 10g. In which I tried a procedure with the follwing code and am thrown with the error that says:
    SQL>   create or replace procedure ptable(ptab varchar2) is
      2  lstmt varchar(200);
      3  begin
      4  lstmt:='CREATE TABLE '||ptab||'(a int,b varchar2(30)) ';
      5  execute immediate lstmt;
      6  end;
      7  /
    
    Procedure created.
    
    SQL>  exec ptable('hos');
    BEGIN ptable('hos'); END;
    
    *
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "VIDYA.PTABLE", line 5
    ORA-06512: at line 1
    Procedure has been created, but the error occurs during the execution of it.why can I get this error even if I have the DBA privilege.? authorization is trolling for me?. Help me with your suggestions.thanks in advance.


    Regarding
    VIDS

    Check if you have the permission to CREATE ANY TABLE , if not, are looking for it.

    * 009 *.

  • What is the syntax to call a procedure with named parameters?

    I should know this, but I can't seem to remember how to do it and did not find reference.

    If I have a procedure like this:

    CREATE or REPLACE myProc (inParam1 IN VARCHAR2, inParam2 in NUMBERS)...

    If I want to call this stored proc with a call control and the name of the parameters instead of having to go through position, how should I do that?

    That is to say, I know that I can do: call the myProc('somevalue'1)

    But I want to be able to do something like this: call myproc (inParam1: = "somevalue", inParam2: = 1)-which doesn't seem to work. Anyone know the syntax I'm looking for?

    Thank you!

    I don't know if you are referring to the call to the procedure according to the parameters.

    His

    Call MyProc (inParam1-online "somevalue", inParam2-online 1)

    call MyProc (inParam2-online 1, inParam1-online "somevalue")

    Hopefully it's that you make reference to.

  • call a stored procedure with OUT VARCHAR2 parameter fails

    Hi all

    I use the Oracle 11.2.0.1 version OLE DB provider. I have a simple stored procedure that contains a VARCHAR2 OUT parameter:

    create or replace procedure TestOut (RESULT_CODE OUT VARCHAR2) is
    Start
    RESULT_CODE: = 'X '.
    TestOut end;

    The following c# code piece fails:

    String ConnStr = "Provider = OraOLEDB.Oracle; User ID = test; Password = test; Data Source = sandbox; « ;
    OleDbConnection Conn = new OleDbConnection (ConnStr);
    Conn.Open ();
    OleDbCommand Cmd new OleDbCommand();
    Cmd.Connection = Conn;
    OleDbParameter Param = Cmd.CreateParameter ();
    Param.ParameterName = "RESULT_CODE ';
    Param.Direction = System.Data.ParameterDirection.Output;
    Param.OleDbType = OleDbType.BSTR;
    Param.Size = 1;
    Cmd.Parameters.Add (Param);

    Cmd.CommandType = System.Data.CommandType.Text.
    Cmd.CommandText = "{TESTOUT (?). CALL} ";
    Cmd.ExecuteNonQuery ();

    If the stored procedure is modified to contain an OUT parameter, the same code works, after you change the type of parameter to appropriate OleDBType (OleDbType.SmallInt).

    What am I doing wrong when handling OUTPUT VARCHAR parameters? Y at - there any limitation on the types of parameters stored procedure using the Oracle OleDB provider?

    Published by: user957565 on 1/Ago/2011 06:31

    I get an access violation, using 11202. What do you get?

    In any case, it works fine for me using OleDbType.VarChar instead of OleDbType.BSTR.

    Hope this helps, comments welcome.

    Greg

  • Java - a stored procedure with call by result

    Hi the Oracle community,

    I'm looking for some example Code how to use a Java-Stored procedure with output parameters. Don't get me wrong. I don't want to call a procedure with the parameters Out of Java (there are many examples in this respect over there). I want to just implement the appeal of the concept of results in a Java-Stored procedure. A customer calls this procedure with certain parameters and the Java procedure will fill the. So my first question: is it possible? And my second Question: how to implement it?

    Greetings.

    I found a solution. It's very simple.

    Just setting the parameters as java array (e.g., String() P1). The first value (P1 [0]) is the returned value.

    Finally just contained JDeveloper in dialog box "Edit method Signature" the parametermode OUT.

    The dialog box are entitled on the stored procedure in the dbexport file. You can read this

    in Section 6, publishing Java Classes with call specifications-> defining the Modes parameter in

    The Oracle database Java Developer's Guide.

  • Calling stored procedures with parameters with the database connectivity Toolkit

    Hi all

    I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work.  I have a database in which I tables and stored procedures with parameters.  Some of these stored procedures have input, output and return parameters.

    I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument

    Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table).  In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).)  I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful.  I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step.  I then try to use the VI of parameter query create to call the stored procedure and set the parameters.  I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI?  I am also having some confusion during and after these steps as well.  I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert.  Also, I would be happy to provide more information that might be useful.

    Kind regards

    Jon

    Here's what I use to do this.  I think I had to change him create parameterized query VI for him to work.  There is a post on the forum about this somewhere.

  • How to do a select on the results of a stored procedure?

    Hello

    I am new to Oracle. I work with SQL Developer.

    I'm doing a simple select on the results of a stored procedure call. I don't know how to do it. Here's what I have so far:

    declare
    type ref_cursor is ref cursor;
    results ref_cursor;
    Start
    MyStoredProcedure (123 results);
    Select * from results;
    end;
    /

    but he said to me:

    Error from the 1 in the command line:
    declare
    type ref_cursor is ref cursor;
    results ref_cursor;
    Start
    GET_TAX_TYPE_BY_TAX_ENTITY_KEY (60670100000000, results);
    Select * from results;
    end;
    Error report:
    ORA-06550: line 6, column 15:
    PL/SQL: ORA-00942: table or view does not exist
    ORA-06550: line 6, column 1:
    PL/SQL: SQL statement ignored
    06550 00000 - "line %s, column % s:\n%s".
    * Cause: Usually a PL/SQL compilation error.
    * Action:

    Obviously, select * results; is not the right way to do it. But what is?

    Thanks for any advice forthcoming.

    If a SQL cursor is built by a reporting system, a Java application, a c# program, or a PL/SQL call - the database doesn't care, because he doesn't know the difference. A Select SQL cursor created in PL/SQL through the ref cursor interface, won't be faster than the same SQL select in Eclipse. If the SQL source code is the same, the same cursor SQL program will be used by both.

    What give you BIRT is the flexibility of the use of code Server (PL/SQL) to create the slider - this code doing business and technical decisions on how to design side than SQL, Select. Which is a good thing because it summarized the data model and the complexity BIRT server technique.

    So my choice would be to use the procedural interface and return to the reporting system for the rendering of the ref Cursor.

    The question of a slider running via the slider (selection of a cursor), is questionable. Yes, there are a set of specifications that allows to do this kind of thing. But it must be very firmly justified and careful design because it really is an exception. I personally (blame my DBA) would need a justification because it is much more of an exception. I have never seen it put in place in production in more than a decade of DBA'ing, despite the developers try to use such a hack - as it has always been much more powerful and the deployment of alternatives.

    The concept for robust and efficient code for Oracle is: Maximise SQL. Minimize the PL/SQL (or Java / c# / etc.).

    That means when it comes to database power, write an SQL program to do. Stop thinking of SQL as a language of data recovery a single simplistic statement. Think of it as a programming language. Extremely complex problems can be resolved with a single SQL, which requires easy code 100 + lines of PL/SQL, Java, or c#. Write SQL programs. Not SQL one-liners for a grinding program PL/SQL or Java data.

    Why then PL/SQL? It is the best language to manage the creation of SQL, dealing with the process flow, conditional processing, and so on of exception handling. It is less than SQL (such as Java and c#) in the treatment of the data.

  • 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;
      }
    }
    
  • Passing the params in mysql stored procedure

    Makes no mistake, but when I hard code the values in the stored procedure, I get results, I leave as params - if not.
    Something must be a miss with how I said, but I can't understand that:

    Can anyone help? details below:

    : the stored procedure:

    Create procedure keyword_getBySource (in sourceRecordName varchar (20), in sourceRecordId varchar (50))
    Start
    Select
    tblkeyword.*
    Of
    tblkeyword,
    tblrecordlink
    where
    tblrecordlink.sourceRecordName = @sourceRecordName
    and
    tblrecordlink.sourceRecordId = @sourceRecordId
    and
    tblrecordlink.linkRecordName = 'keyword'
    and
    tblkeyword.keywordId = tblrecordlink.linkRecordId
    ;
    end

    : cfm:

    "< cfstoredproc procedure ="keyword_getBySource"datasource =" "username =" "password =" ">
    < cfprocparam type = 'in' cfsqltype = "CF_SQL_VARCHAR" dbvarname = "sourceRecordName" value = "Log" / >
    < cfprocparam type = 'in' cfsqltype = "CF_SQL_VARCHAR" dbvarname = "sourceRecordId" value = "0d8a6d3e-cf1e - 19(d) 5-2b9fc8ee1de01ad0" / >
    < name cfprocresult = resultset "getBySource" = "1" / >
    < / cfstoredproc >

    @... seems mysql does not use these to designate the params in a stored procedure

    Take them out - it works.

  • stored procedure with cursor as param output

    This is the first time for me to test a stored procedure with a cursor as an out parameter. I performed the following:

    SQL > user_cur VARIABLE REFCURSOR; VARIABLE ret_code VARCHAR2; exec TEST_API. SEARCH_USER (: ret_code, ",", "John", ",: user_cur); print ret_code; print user_cur;

    I got the following error:

    Use: VAR [IABLE] [< variable > [NUMBER |]] TANK | CHAR (n [CHAR |]) BYTE]) |
    VARCHAR2 (n TANK). NCHAR. NCHAR (n) |
    NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR]]

    Can I know what is the problem?

    The purpose of the stored procedure is looking for user with the name 'john '.

    The declaration of input/output params to stored procedure is as follows:

    PROCEDURE SEARCH_USER
    (
    RETURN_CODE OUT VARCHAR2,
    USER_ID_IN IN VARCHAR2,
    POSITION_IN IN VARCHAR2,
    USERNAME_IN IN VARCHAR2,
    STATUS_IN IN VARCHAR2,
    USER_CUR_OUT ON REFCURSOR
    )

    Published by: user7383310 on October 19, 2008 21:05

    Published by: user7383310 on October 19, 2008 21:05

    refer here for the use of refcursors in pl/sql...
    http://download.Oracle.com/docs/CD/B14117_01/AppDev.101/B10807/06_ora.htm#sthref808

    You can code as...

    SQL> create or replace procedure p1(id number,csr out sys_refcursor) is  2  begin  3   open csr for select ename from emp where deptno = id;  4  end;  5  /
    
    Procedure created.SQL> var csr1 refcursorSQL> var n numberSQL> exec :n := 30;
    
    PL/SQL procedure successfully completed.
    
    SQL> exec p1(:n,:csr1);
    
    PL/SQL procedure successfully completed.
    
    SQL> print csr1
    
    ENAME----------ALLENWARDMARTINBLAKETURNERJAMES
    
    6 rows selected.
    
  • Process the Message on a stored procedure

    Hi all

    How do I call and diplay APEX the message of a stored procedure?

    Example of form on stored procedre.

    Thank you

    Hello

    What do you mean by 'the message '? If you are referring to the 'success Message', then you can use the variable apex.

    APEX_APPLICATION.G_PRINT_SUCCESS_MESSAGE := 'This is success message for page process';
    

    Kind regards
    Hari

  • a stored procedure with parameter

    Hi all

    Here is the code example
    declare 
             in_dt date  := '1-feb-2010' ;
     col1 ...;
     col2 ...;
     col3 ...;        
    begin 
     
      select e.* 
      into col1,
            col2,
            col3
      from table_xyz e 
      where e.start_dt  = in_dt;
       
    end;
    
     
    How to convert the code above in stored procedure in accepting "in_dt" as a parameter and pass the result the displayed value (output) setting OUT tell 'cur_out' (parameter)


    Thank you very much!!! I really appriciate it!
    variable cv refcursor;
    
    DECLARE
      P_DT DATE;
    
    BEGIN
      P_DT := '10-oct-2005';
      scott.foo ( P_DT, :CV );
     END;
    /
    print cv
    

    REF CURSOR is when a program using Mickeysoft ODBC or Mickeysoft .NET needs a result set.

    You don't need them in pure PL/SQL
    Of course, you do not read further documentation and you ask me to ignore documentation.
    I hate that!
    I want to teach people how do fish not spoon feed them.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • money more sunset "files needed to run the Planner missing or corrupted" then program encounters problem and closes. Downloaded multiple times on multiple computers

    money more sunset "files needed to run the Planner missing or corrupted" then program encounters problem and closes. Downloaded multiple times on multiple computers

    Hello

    I suggest you post the same question in Microsoft Technet forum for Microsoft Money Plus Sunset related issues. We have a dedicated team to help you with the problems of Microsoft Money Plus sunset.

    Microsoft Money:

    http://social.Microsoft.com/forums/is/category/money

    Hope this information is useful.

  • I have the model of macbook air 2016 with i5 Professor and 8 GB ram... since it's the fastest ssd, but I have not seen all speeds up to now, I want to say is bcz I need to have usb 3.0 USB key or hard drive to see the speed of the ssd to usb 2.0 will work

    I have the model of macbook air 2016 with i5 Professor and 8 GB ram... since it's the fastest ssd, but I have not seen all speeds up to now, I want to say is bcz I need to have usb 3.0 USB key or hard drive to see the speed of the ssd to usb 2.0 will work

    What do you mean, your message is not clear.

Maybe you are looking for

  • Satellite L500 - does not correctly play some CD

    Hello first time on this forum hoping to solve this problem. I often import CD into Itunes. We had the L500 for only less than a month and I noticed that he doesn't play the CD correctly. He plays all DVD very well, just to let you know.For example,

  • Filterpipelineprintproc.dll

    Filterpipelineprintproc.dll Msxpsdrv.cat Msxpsdrv.inf Msxpsinc.GPD Msxpsinc.PPD Mxdwdrv.dll Xpssvcs.dll Na installatie van updates Microsoft van staat op D-schijf een map (D:\443538c99537998ca229ee4fc3) met twee submappen (amd64 i386 en) met bovensta

  • HP laptop HP Pavilion dv6-3007TU-XB823PA #ACJ

    my friend brought Hp laptop HP Pavilion dv6-3007TU-XB823PA #ACJ yesterday. It comes with Free DOS. I tried to install WInXP on it, but I'm still looking for the driver. I don't even see the product described in the website of hp / is - this fake mode

  • DeskJet 3520 light problem

    Printer cannot well, sometimes, it can be downloaded right now. Some time need to unplug the cable try until the pronter. No idea what is the problem and how to solve? Thank you

  • I open a link in a spam e-mail. If I am infected?

    Original title: Virus threat I open a link in a spam e-mail. I scanned the computer and found no threat. The link was www.zaszlokeszites.com/gjilqO.php. What should I do?