Insert a record, call a stored procedure and execute a shell script

Hello

I am trying to build a page APEX do these three things in order.

#1. Insert a new record in a database table (pk, donnees_xml, attr1 and attr2, etc.) and download the XML file to the donnees_xml column

#2. Save this XML file on a file system

#3. Parse the XML file on a file system and update the database with the parsed data table

I can do #1 with a regular shape based on the database table. I can do #2 with a stored procedure.

I can do #3 with a shell script.

I wonder how these tasks can be combined into a single action in APEX.

do #1;

If successful, do #2;

If successful, do #3;

I'd appreciate comments on this.

Thank you

Define a process of PL/SQL page submit that runs after the record is inserted, if P1_FILE is not null.

Tags: Database

Similar Questions

  • Call the stored procedure, and bind parameters by name

    Hello

    I use the Oracle ODBC 12 c driver to pass values from one Interface to our database Oracle 11.2. The Interface software collects data from modbus protocoll and calls a stored procedure. Right now my syntax to call the stored procedure looks like this:

    CALL procedure-name ('STRING', 'Timestamp as String', numValue1);

    It works very well. Now, I have to add a default setting to my procedure. To stay flexible to make other changes, I want to call the procedure and bind the parameters by name. Release 10.2.0.1.0 ISC ODBC Notes:

    Added support for the named parameter, binding the parameters by name. ODBC Oracle driver now allows the application to specify the parameters of a stored procedure by name, in the procedure call. Named parameters are to be used in calls to stored procedures and should not be used in other SQL statements.

    So, it shouldn't be a problem to use named notation, but how do I do this in ODBC? I tried like this, but oracle returns an ora-00936 error of missing expression:

    call procedure-name (paramName1 = > 'STRING',= paramName2 > 'Timestamp as String',paramName3 = > numValue1).


    Thank you for your help.

    Finally, I was able to find the error. The syntax of the statement was very good. The problem was caused by another declaration that I edited before and the error has not attracted Attention immediately.

    Thanks for reading and looking for an answer.

  • Call the batch file and not the shell script using measures of the event

    Can I use EVENTACTIONS at the door of gold like

    eventactions (SHELL, /path-to-batch-file/test1.bat)

    will this work? I am on a windows machine, so I need to run a batch file and not a shell script

    In GGSCI, you can shell OUT to the BONE and call a command/executable file.

    For example on Windows:

    GGSCI (WIN2003) 2 > shell dir

    Volume in drive C has no label.

    Volume serial number is 8CCC-9E58

    Directory of C:\ggs

    18/08/2012 07:23

    .

    18/08/2012 07:23

    ...

    2010-10-15 06:37 bcpfmt.tpl 426

    2010-10-15 06:37 bcrypt.txt 1 725

    22/04/2011 03:41 2 560 category.dll

    05/11/2011 10:43

    cfg

    2010-10-15 07:15 739 chkpt_ora_create.sql

    ...

    What were the results when you tried this in an EVENTACTIONS clause?

  • two related issues: to call the stored procedure and passing in an array of elements using htmldb_Get

    I need to save items of ApEx generated dynamically via AJAX.  I use the APEX_ITEM API to generate the elements.  At runtime, I have no idea how much of elements are generated on the page, but I know that they're all separate and discreet 'name' attributes, i.e. f01, f02, f03, etc..  As a basic example, if I have to generate a selection list, I know that the parameter "p_idx" of the APEX_ITEM call is to say '3', so select all lists that get generated have a "name" attribute in "f03" DOM, all text elements will be "f01", etc.

    I want to record these data in the database using AJAX.  It is common to call the javascript htmldb_Get function that is standard for the use of an application process, but I am interested in the use of the rarely called upon 'internal' and queryString"options of this javascript function so that I can build the query string to the fly according to what is on the DOM when it tries to save the data they have entered into these items generated by APEX_ITEM.  Someone at - there are good examples of the use of the 'procedure' and 'queryString' the javascript htmldb_Get function parameters?

    I have found a handful of some blogs, messages, etc. online linked to this, but just for most people regurgitate the documentation.  I found this post (https://forums.oracle.com/thread/2549237), which has had a glimpse of hope to move from a table (which is something I need) as a parameter, but as someone in their right mind would check this before you go this route.

    Shane.

    ApEx 4.2.1

    Shane

    Since you mention that you are on 4.2 APEX I advise to use apex.server.process which is replacing the htmldb_Get officially undocumented documented.

    In the literature, it is that the first parameter is the ajaxidentifier but it's actually the name of the process.

    The data object would be something like

    var lData ={f01 : get_value_array('f01')}
    

    Where is get_value_array

    function get_value_array(pColumnName) {
      var l_values =[];
      apex.jQuery('[name="'+pColumnName+'"]').each(
       function(){
        var l_value;
        l_value = apex.item(this.id).getValue();
        l_values.push(l_value);
       }
      );
      return l_values
    }
    

    For an example see this demo.

    Nicolette

  • call the stored procedure in a column in the report

    Hi all
    I'm new to APEX. I did a search on this forum, but could not get an exact answer.
    I know how to call or execute a procedure from a button. as to create a PL/SQL anonymous bloack and partner is key.

    My question is a little different. I have a report with 11 columns. the last column shows just "delete" for all lines (I did it in my request to report as SELECT x, y, z,..., 'remove' AS delete). When I click on this cell for any line (this column can be a hyperlink or any clickable element), I would like to call a stored procedure that takes parameters as values in columns 2 and 4 for this particular line.

    for example, my report looks like somethnig like below,

    FILE_ID MEMBER_CD ACTION
    112 ABCD Remove
    WXYYZ 113 remove
    114 PQRS remove

    I want to click on the 'delete' in the first line which should call a stored procedure and pass of 112 and ABCD as parameters to the procedure.

    I now have the procedure as a process. sturggling to link this column to procedure but without success :(

    Hope realized. Please, any help is appreciated.

    Thank you

    Hello

    I work in the drudgery of google and firefox if ever the reliased, the thanks of the error to report

    exact code in URL should e

    javascript:document.getElementById('P1_RECORDID').value = '#recordid#';doSubmit('DELETE_RECORD');
    
  • call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. The other rows are based on the entities

    Hi Experts,

    JDeveloper 12.1.3.0.0

    I have a VO based on entity object. With a column of the VO is transient attribute (I created).

    I need to call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. As well as other attributes.

    So can anyone suggest how can I achieve this?

    Thank you

    AR

    I think that you need a stored function (which returns the value) in this case, is not?

    Take a look at:

    https://docs.Oracle.com/CD/B31017_01/Web.1013/b25947/bcadvgen005.htm

    and search for:

    Invoking stored function with only Arguments in

    call your function in the Get attribute and return value accessor...

  • Call the stored procedure to support bean w / table setting dimensional bi

    Hi all, I use jdeveloper 11g

    I have a requirement where instead of calling several times a "insert into" statement rather call a stored procedure, a table shipping two-dimensional bi as a parameter.

    The table must have size [n] [4] and [0] [0] = string and others must have numbers.

    This is because users will be inserting thousands of records at a time, remote sites, so the load of sending of a should be avoided.

    Any suggestions?

    Thank you.

    Miguel,
    If you use ADFbc (VO and EO sense), you can use batch insert for this archive.
    However, he must think about the user interface and how to transfer data from the client to the server taking the place of the insert.

    How you accumulate the data to insert into the DB?
    Are able to collect you say 1000 records a time and transfer them in a single segment on the server?
    How about data validation and exception handling while inserting into the db?

    I'm sure you can use a pl/sql procedure to do the Insert, but the questions above should always be answered.

    Timo

  • 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;
      }
    }
    
  • Problem with stored procedure and validation

    I have the following stored procedure:

    create or replace PROCEDURE SOME_PROC)

    /*

    Some settings

    */

    ) AS

    NUMBER of errors

    BEGIN

    errors: = FN_CHECK_BUSINESS_RULE_1 (/ * some args * /);

    if(Errors > 0) then

    raise_application_error (ERR_CONSTANTS. SOME_ERROR_NUMBER, ERR_CONSTANTS. SOME_ERROR_MESSAGE);

    end if;

    INSERT INTO une_table (/ * columns * /) VALUES (/ * values * /);

    END SOME_PROC;

    Because the business rule 1 is placed inside the stored procedure I can't check it out without calling the stored procedure.

    I need to call the stored procedure 10 times with a different set of parameters and validation of the changes only after all calls to the stored procedure

    are successful. I want to show the user all the errors that occurred during the stored procedure calls. If for a first example of stored procedure call

    succeeds and a second failure no data has to be stored in a database.

    How to prevent the stored procedure for insert lines until I call the method commit of ApplicationModule?

    Thanks in advance.

    No, other users only see the lines until you commit. The search term is the transaction isolation level. Tom Kite write a paper on this here ask Tom: on transaction isolation levels. This article gives some samples, according to theory, and you should read it.

    Timo

  • [BC] Call a stored procedure taking parameters of table

    Hello!

    I currently have a request of the OIC that makes thousands of calls per second stored procedure. The stored procedure runs a business logic that I want my client application to stay informed.  I want to reduce the cat of the database and instead to call the stored procedure from thousands of times per second, call the procedure (for example) once per second, but with values of one mile.

    I used OCIBindArrayOfStruct successfully to perform inserts bulk, where my OCI application executes a () INSERT INTO using the function "iters" and it might be possible to do something similar with the stored procedure, but I want to do something slightly different, because the procedure stored something like this:

    * If a specific condition is set, call a secondary stored procedure

    * If another special condition is set, insert a row into a table of some

    I so wanted to do was to pass a table (or a series of tables) in the stored procedure, then the stored procedure to use optimal methods that are available, such as FORALL, to perform each of the tasks, the more effectively.

    So I thought to create a type, such as a TABLE OF VARCHAR2, or a VARRAY and possessing of the parameters for the stored procedure based on this type, something like:

    create or replace TYPE 'NTT_VARCHAR2' AS TABLE OF VARCHAR2 (32700);

    create or replace FUNCTION bulk_process_values)

    p_error_message OUT NOCOPY VARCHAR2,

    p_module_context_name OUT NOCOPY VARCHAR2,

    p_sql_error OUT NOCOPY VARCHAR2,

    p_count in NUMBERS

    p_non_array_var_1 IN VARCHAR2,

    p_non_array_var_2 IN VARCHAR2,

    p_array_var_1 IN NTT_VARCHAR2,

    p_array_var_2 IN NTT_VARCHAR2,

    p_array_var_3 IN NTT_VARCHAR2

    < etc. for all the variables in table >)

    RETURN NUMBER

    .. .but I am struggling to find an example of how call the procedure "bulk_process_values" stored, and even if I use a TABLE OF VARCHAR2 or a VARRAY as a parameter type.

    I searched the Internet and found this: OIC - how to bind an array to a stored procedure? - and binding table of the structs (OCIBindArrayOfStruct) sample code

    - but they take different approaches and a bit confused (the second example spoke of OTT).

    I think that the first approach is more likely to be the solution I need - but I can't help thinking - it is a bunch of stuff to move if it does not end up significantly improve performance!

    My questions are:

    * Moves to a call-SP-thousands-of-times-per-second to call-SP-fewer-times-but-with-array-parameters sensitive?

    * Should the table or VARRAY, TABLE OF VARCHAR2 parameters or something else?

    * Should I use for my case OTT?

    Samples I found are both very old - and the second example indicators that the optimal approach evolves with the OCI versions - I'm on 11.2, what is the optimal approach these days?

    * < added later > why is there no official useful example?

    Thank you very much

    Much appreciated. https://community.oracle.com/message/4528528#4528528 has actually worked, with VARRAY, with a proof of concept. Now I just need to shake a little and then get my PL/SQL for optimal PC experts. I think I was really discouraged by the lack of official documents, with the Community (Paradise) is the only way to get real results.

    Thank you JJ.

    I intend me to use the binding enforcement of the table and the table and avoid N back and forth, but I do not then get the opportunity to do something clever in the PL/SQL.

    In the PL/SQL, there is no logic occurring - I don't call the same SP tons of times, but then I want to be able to use PL/SQL optimizations such as FORALL, BULK COLLECT, reduce the number of validations and others.  There is a commit after each SP run, because otherwise the nature of demand means that the application hangs occur; However, there is a way (I think) be smart on the part that is likely to deadlock (making a shape on the Bay First, then applying the updates in the order sorted and then failed to get a blocking theoretically), and then FORALL insert for the second part of the stored procedure.

    I guess I may apply the single return, passing a table (to a commit in the SP)-which will reduce back and forth, so gain in performance, but it will not reduce the number of validations that I do - and Oracle said that commits too frequent is not good for performance. I already have code in my framework that does - by making a simple INSERT INTO.

    Good to hear that OTT is not explicitly required - and VARRAY resembles the approach to try first.

  • Internal error: catalog view incompatible when calling a stored procedure

    Hello

    I use JDeveloper 11.1.1.4

    When you call a stored procedure from AppModuleImpl, I get this error internal error: inconsistent display catalog

    I'll call the stored procedure of this way

    String lErrCode;

    String lErrMsg;

    Result of an integer;

    ARRAY inputArray = null;

    Table STRUCT that can be passed to a PLSQL PROCEDURE

    inputArray =

    JdbcSqlMapper.preparePlSqlArrayUsingVOAttrbs (conn, recordType,

    view, rm);

    OracleCallableStatement st =

    (OracleCallableStatement) conn.prepareCall ("{?}") = call ("+

    procedureName +.

    "(?,?,?))}");

    st.registerOutParameter (1, Types.INTEGER);

    st.setObject (2, inputArray, OracleTypes.ARRAY);

    st.registerOutParameter (2, OracleTypes.ARRAY,

    recordType.getTableType ());

    st.registerOutParameter (3, Types.VARCHAR);

    st.registerOutParameter (4, Types.VARCHAR);

    St.Execute ();

    I checked the subsidies for this package to all users. All users with grants to this package.

    I don't know where I start to debug this issue.

    Kindly help.

    Thank you and best regards,

    John.

    Have yo uchecked the right of the types of data used (at least the TABLE) to the user (referred to Pokusak blog: JPublisher - incompatible catalog display)?

    Timo

  • A wrong number or types of arguments in the call to stored procedure

    Hi all...
    I'm missing something simple here, but I don't see what it is.
    I have looked around and cannot know what the problem is.
    Calling a stored procedure in Oracle 11g of Java 6.

    Here is my code:
       CallableStatement proc = null;                
       proc = conn.prepareCall("{ call storedProc(?, ?, ?, ?, ?) }");
       proc.setString("p_header", "8YR6TG");
       proc.setString("p_optype", "A");
       proc.registerOutParameter("p_headerCursor", OracleTypes.CURSOR);
       proc.registerOutParameter("p_detailCursor", OracleTypes.CURSOR);
       proc.registerOutParameter("p_status", OracleTypes.VARCHAR);
       proc.execute();
    Here are my stored procedure:
    PROCEDURE storedProc (
    p_header IN VARCHAR2,
    p_optype IN VARCHAR2,
    p_headerCursor OUT R_CURSOR,
    p_detailCursor OUT R_CURSOR,
    p_status OUT VARCHAR)
    Here's the exception I get:
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'storedProc'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:626)
         at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:181)
         at oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:870)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1081)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2905)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:2996)
         at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4120)
    Can you see what I'm doing wrong here?
    Thanks in advance for your comments!

    Published by: Brady on February 16, 2012 13:02

    try to use digital indexes instead of parameter names.

  • How to call a stored procedure accepts VARIABLE in run

    Hello

    CREATE OR REPLACE PROCEDURE getEmpName
    * (EMP_UNAME IN VARCHAR, EMP_PWD VARCHAR OUT) *.
    IS
    BEGIN
    SELECT PASS IN EMP_PWD
    USERS
    WHERE NAME = EMP_UNAME;
    END;

    How call this stored using the execute procedure, I tried to run getEmpName('Sai'); and I myself
    ERROR on line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in the call to 'GETEMPNAME '.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    The Sybrand & Tyro two examples show the declaration of the variable, i.e.

    SQL> variable ename varchar2(100);
    

    You must do it before SQL * Plus could know how to solve: ename in your call.

    Justin

  • Problem call Oracle10g stored procedure (bug?)

    Hello everyone, I'm trying to call a stored procedure Oracle on Oracle 10 g XE of Java.
    I can successfully run the query to Java, so I can't tell what driver, connection,... are very good.
    I have the following error when I try to call a stored procedure or a function.
    I think it's a bug OraClient10.Dll file, so, in general, a bug that depends on my code. So I install the latest version of the JDK/JRE, and I download new folder OraClient10.Dll but the result was the same.
    Please help me!
    Thank you
    Manti

    #
    # A fatal error has been detected by Java runtime environment:
    #
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc = 0x61d37460, pid = 3872, tid = 1224
    #
    # Version JRE: 6.0_16 - b01
    # Java VM: Java hotspot Client VM (14: 2 - b01 mixed mode windows - x 86)
    # Problematic frame:
    # C [OraClient10.Dll + 0 x 117460]
    #
    # A file error with more information report is saved as:
    [...]
    #
    # If you want to submit a bug report, please visit:
    [...]
    # The accident happened outside the Virtual Machine Java to native code.
    # See problematic frame for where report them the bug.
    #

    Why not just connect via thin mode of the driver, not the mode of the OIC?
    You will get all the features and no risk of native code bug.

  • How to call the stored procedure from javascript? (Google suggest, AJAX)

    Hi I want to set up a text field so that it behaves like [Google Suggest | http://www.google.com/webhp?complete=1 & hl = en].

    I read this post .

    Now, I installed everything according to this document. But it simply doesn't. And I don't know why.

    I think that problems can fall into the following three categories:
    1. the text field and the page invoking the appropriate javascript?
    2 - is the JavaScript call the stored procedure?
    3. the stored procedure correctly returns the result formatted?

    I'm assertive for 1 and 3, but I'm not sure 2. Because I don't know how if a stored procedure has been called? Is there a PL/SQL statement that I can query in SQL * more?

    Also, I would like to know how to debug AJAX in the APEX. It involves a lot of things.

    Finally, I used APEX 3.2 and Oracle XE. I can't find file dads.conf or marvel.conf. Is ' / apex / "the virtual directory for APEX?

    Thank you very much!

    Buffalo,

    I managed to make it work on XE with APEX 3.2!
    It took more time than expected because my XE installation was still on an earlier version of the Apex and I had put it first...

    But that's what I did:
    -in the ac.js file, I changed the path ' / apex / "and I added the ac.js file to my candidacy as a static file. So as you did.
    -J' copied my request to the XE and copied my procedure on the schema that is related to my request
    -J' gave to run anonymous rights my procedure

    Now at first, it did not work...
    Then I suddenly remembered something: If you want to run a procedure through the pl/sql gateway in the XE, XE please how it is.
    Do you this by changing the APEX_030200.wwv_flow_epg_include_mod_local function!

    This is the code for the function changed for my example:

    CREATE OR REPLACE function APEX_030200.wwv_flow_epg_include_mod_local(
        procedure_name in varchar2)
    return boolean
    is
    begin
        --return false; -- remove this statement when you modify this function
        --
        -- Administrator note: the procedure_name input parameter may be in the format:
        --
        --    procedure
        --    schema.procedure
        --    package.procedure
        --    schema.package.procedure
        --
        -- If the expected input parameter is a procedure name only, the IN list code shown below
        -- can be modified to itemize the expected procedure names. Otherwise you must parse the
        -- procedure_name parameter and replace the simple code below with code that will evaluate
        -- all of the cases listed above.
        --
        if upper(procedure_name) in (
              'MATTHIASH.INCSEARCH') then
            return TRUE;
        else
            return FALSE;
        end if;
    end wwv_flow_epg_include_mod_local;
    /
    

    After that, the AJAX function worked as expected...

    HTH
    Matthias Hoys

    Published by: mhoys on August 13, 2009 15:24

Maybe you are looking for