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.

Tags: NI Software

Similar Questions

  • Using a stored procedure with the DBUM connector

    Hello, I am a new to the Oracle Identity Manager. The system that I am running on is Windows Server 2008. I recently installed the version 11.1.1.3.0 from the Identity and Access Management suite, as well as the appropriate components. I use a database of 11 g R2 as my deposit. I installed the DBUM connector and have successfully provided a user to my database (which is also an Oracle database).

    However, I have an instance where I need to provide not only a database user account, but also this user and password (after the execution of some arbitrary for her, as features by adding a 1 or chop) at a table in the same database.

    Could someone give me please a detailed description of what I need to do to achieve and possibly point me in the direction of certain documents? I greatly appreciate it.

    You can write your own custom code to execute a stored procedure. Here is the documentation for it: http://download.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html

    Create your code and deploy your jar file in the folder xellerate/JavaTasks. Create an adapter to use the code. Then on your commissioning process definition, create a new task and plug in the adapter. Finally, start the task of the user to create the task.

    -Kevin

  • Calling stored procedure with an input of DATE parameter

    Hello. A question about the Date input parameters when you call a stored procedure.

    I have a procedure that takes a DATE as input parameter. I would DATE this value to include a time element.

    My Application Module method takes an input as a java.util.Date (myParamDate) parameter - that will preserve a time element (?).

    However when I create the CallableStatement, I am trying to set the parameter using setDate like this (for the param 5):
                st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0);            
                Connection myConn = st.getConnection();
                ArrayDescriptor myArrDesc  =  ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn);
                Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray());
                Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray());
                Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray());
                    
                st.setString(1, repType);
                st.setObject(2, sqlParamNameArray);
                st.setObject(3,sqlParamValueArray);
                st.setObject(4,sqlFilterNameArray);
    
                java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime());
    
                st.setDate(5,myRepDate);
                
                System.out.println("Report Date = " + myRepDate.toString());
                st.setString(6,repUser);
                st.setString(7,repAttach);
                // set out param
                st.registerOutParameter(8, Types.NUMERIC);
                st.execute();
    I understand java.sql.Date does NOT include a time element. But setDate() only accepts a java.sql.Date so my parameter of the procedure ends with a zero time element.

    How to call this procedure keeping the time element?

    Thank you.

    It includes the time element, if you want more precision with time stamp.

    http://docs.Oracle.com/javase/6/docs/API/Java/SQL/date.html

  • Create the stored procedure with the table from another throw diagram PLS-00201

    Oracle 10g. I'm new on procedures, so maybe I'm missing something obvious.

    The ABC schema owner has table T2001_WRITEOFF. The SYSDBAs given SIUD Some_Update_Role and granted this role to developer user IJK. IJK user then created a private synonym T2001_WRITEOFF for ABC. T2001_WRITEOFF. It worked with the usual SQL DML commands.

    When I try to create a simple procedure, it throws PLS-00201 identifier "T2001_WRITEOFF" must be declared and the points of the 2nd line.

    create or replace procedure woof1(
      fooname
    in T2001_WRITEOFF.territory%TYPE,  <=== error points here
      bardesc
    IN T2001_WRITEOFF.ind_batch_submit%TYPE) IS
    BEGIN
      
    INSERT into T2001_WRITEOFF
      
    VALUES ( fooname, bardesc);
    END woof1;
    /


    What I am doing wrong?


    Thank you

    JimR


    Grant the necessary rights directly to the user (not through a role):

    http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551289900368934430

  • block of data based on a stored procedure with the input arguments

    Hello

    I am able to create a block of data based on the stored procedure.
    but I want that procedure to take both of the input arguments and I am facing issue while setting the value for this input arguments from another block element.
    Please someone help, how to set the value of the input of another block-element of control argument? (Note: data block is based on the stored procedure)

    Thanks in advance,
    Jean François Anandan

    I have an example that really works

    in the ownership of block

    arguments of data source query that you have two sections

    names one argument he write the name of the argument on the right, type the setting, fashion and value: block1.name and then pass the value to the procedure

  • Failed to create the stored procedure with the object as a parameter

    Hello

    No idea how to create procedures to the current data stored in SQLFire, try to run the command prompt "sqlf" per call "create_proc.sql" as give below error below

    C:\SQLFire10Beta>sqlf
    sqlf version 10.4
    sqlf> connect client 'localhost:1527';
    sqlf> run 'create_proc.sql';
    sqlf> CREATE PROCEDURE INSURANCE.SEARCHCUSTOMER (IN CUST OBJECT) DYNAMIC RESULT SETS 1 LANGUAGE JAVA PARAMETER STYLE JAVA READS SQ
    L DATA EXTERNAL NAME com.xxx.xxx.sqlfire.dao.CustomerSearchProcedure.searchCustomer;
    ERROR 42X01: Syntax error: Encountered "" at line 1, column 47.
    Caused by: SqlException: Syntax error: Encountered "" at line 1, column 47.
            at com.vmware.sqlfire.internal.client.am.Statement.completeSqlca(Statement.java:1838)
    sqlf> sqlf> 


    and I created a class Java as described below:

    public class CustomerSearchProcedure {
     
     public static void searchCustomer (BaseDTO[] customers, ResultSet[] outResults,
       ProcedureExecutionContext context) throws SQLException {
      BaseDTO searchCriteria = customers[0];
      StringBuilder sql = new StringBuilder();
      sql.append("SELECT * FROM INSURANCE.CUSTOMERS WHERE CUST_NAME LIKE '"+searchCriteria.getCustName().trim() + "%'");
      
      Connection cxn = context.getConnection();
      Statement stmt = cxn.createStatement();
      ResultSet rs = stmt.executeQuery(sql.toString());
      outResults[0] = rs;
     } //END OF METHOD
    }


    This procedure is called class using the class StoredProcedure Spring DAO

    You can let me know why am not able to create the procedure?

    FYI, pots can also can be dynamically installed in the system by using the SYS. Table client-side JARS to transport the jar bytes rather than by requiring that the pot be accessible side Server (http://pubs.vmware.com/vfabric5/index.jsp?topic=/com.vmware.vfabric.sqlfire.1.0/deploy_guide/Topics/sysjars_install.html)

  • How 2 call a procedure with the data type for the parameter Ftree.NODE

    Hello

    in this link
    http://Andreas.Weiden.ORCL.over-blog.de/article-29307730.html


    Down in the page after you run the package, I created the procedure and it compiled successfully but when call PR_WTNS in trigger WHEN-TREE-NŒUD-SELECTED

    PROCEDURE PR_WTNE (i_ndNode IN Ftree.NODE);

    as

    PR_WTNE (i_ndNode Ftree.NODE);


    I got the error message; A wrong number or types of argument in the call

    pls I'm stuck can help any one?


    Kind regards

    Abdetu...

    Published by: Abdetu on October 24, 2010 02:36

    Published by: Abdetu on October 24, 2010 02:36

    YKou have to give a variable of type Ftree.NODE when calling this function. If called fromm a WHEN-TREE-NODE-SELECTED-trigger, use: SYSTEM. TRIGGER_NODE

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

  • NullPointerException when calling stored procedure

    I have the stored procedure

    create or replace PROCEDURE GREETING_PROC

    (

    TEXT_PARAM IN VARCHAR2

    MSG_TEXT VARCHAR2 OUT

    ) AS

    BEGIN

    MSG_TEXT: = "Hello" | TEXT_PARAM;

    END;

    My stored procedure call method

    public class UserBean {}

    public UserBean() {}

    Super();

    }

    Public Shared Sub main (String [] args) {}

    UserBean userBean = new UserBean();

    userBean.callP ();

    userBean.callStoreProcedure ();

    }

    public void callStoreProcedure() {}

    CallableStatement st = null;

    SysUser SysUserEOImpl = new SysUserEOImpl();

    try {}

    String sql = "BEGIN GREETING_PROC (: TEXT_PARAM,: MSG_TEXT); END; « ;

    St = sysUser.getDBTransaction () .createCallableStatement (sql, sysUser.getDBTransaction (). DEFAULT VALUE);

    st.setObject ("TEXT_PARAM", "Scoot");

    st.registerOutParameter ("MSG_TEXT", Types.VARCHAR);

    St.Execute ();

    System.out.println ((String) St.GetObject ("MSG_TEXT"));

    } catch (SQLException e) {}

    throw new Aexception.getLocalizedMessage (e);

    }

    }

    then I got an exception:

    Exception in thread "main" java.lang.NullPointerException

    at cic.opsi.model.bean.UserBean.callStoreProcedure(UserBean.java:35)

    at cic.opsi.model.bean.UserBean.main(UserBean.java:27)

    Hello

    What statemet is UserBean.java:35)?

    Second, create a new SysUserEOImpl()!

    If you want to call stored proc, put the java code calling stored proc in ViewRowImpl/ViewObjectImpl/ApplicationModuleImpl and export this code in the customer interface. Then put this method in the pageDef as a call him as an OperationBinding

    Zeeshan Baig blog: the PL/SQL procedure call and function in the Oracle ADF application

    Extending the functionality of the components Business

    ADF/OFA for Oracle Techies: ADF call stored procedure with Out parameters

    Latest Oracle technology: call Store procedures for Oracle ADF Application

  • 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;
      }
    }
    
  • Problems calling a stored procedure with DG4IFMX

    Hi guys,.

    I try to call stored procedures of database Informix, which is connected by an Oracle for Informix database gateway.

    I ran select, update, delete correctly but when I try to execute a stored procedure, that nothing is happening.

    for example:
    When I run
    call branko"@link_informix (1) «»

    It returns that it is performed successfully, without error, but as you can see below no entry is entered in the branko_test table

    to informix:

    drop the branko procedure;
    Create procedure "informix".branko (integer _vlez)
    returning a Boolean;
    If _vlez = 1 then
    insert into branko_test values ('uspesen test', '1');
    on the other
    insert into branko_test values ('test 2 ', 2' uspesen);

    end if;
    end of procedure;

    the procedure runs ok when called to informix.

    Thanks for any help

    P.S I even tried running:

    declare
    Whole RET;
    Start
    RET: = DBMS_HS_PASSTHROUGH. EXECUTE_IMMEDIATE@link_informix (' branko procedure (2)');
    end;

    but the same thing happens, no entry in the branko_test table.

    Find the root cause:
    When you are using dbaccess to call the original procedure it displays on the screen (expression)
    => remove the return value as it is not managed

    -> looks like not supported return Boolean value. Changes to the procedure of

    drop the branko procedure;
    Create procedure "informix".branko (integer _vlez)

    If _vlez = 1 then
    insert into branko_test values ('uspesen test', '1');
    on the other
    insert into branko_test values ('test 2 ', 2' uspesen);

    end if;
    end of procedure;

    allows me to execute the procedure using passthrough
    DECLARE
    result VARCHAR2 (50);
    BEGIN
    result: = DBMS_HS_PASSTHROUGH. EXECUTE_IMMEDIATE@dg4ifmx (' run the informix.branko procedure (1)');
    END;
    /

    Edited by: kgronau may 6, 2011 07:31

  • Call stored procedures in the object module and application of entity

    Hello

    I've implemented a helper methods that contains the EntiyImpl base class to call stored procedures.

    Now, I need to call procedures stored from the module of the application.

    Apart from the creation of a module base class asks and the programme of assistance of duplication of code in the method is possible
    to share methods of assistance for calling stored procedures between the entity impl and application module impl?


    Concerning
    Paul

    Support code depends on characteristics of an object instance given entity beyond its database transaction?

    If so, I'm not sure I see how it could be used with a class of application module.

    Otherwise, here's what you do:

    Step 1:

    Set up the database transaction - you can even choose to. So instead of

    {myHelperMethod (Object someParam) protected
    DBTransaction trans = getDBTransaction();
    ...
    }

    This is for change

    protected myHelperMethod (DBTransaction trans, someParam Object) {}
    ...
    }

    Step 2: make the method public and static - once you set DBTransaction, you should be able to do.

    public static myHelperMethod (DBTransaction trans, someParam Object) {}
    ...
    }

    Step 3: Remove your EntityImpl base class method in a utility class:

    Public MustInherit class PlSqlUtils {}
    private PlSqlUtils() {}

    public static myHelperMethod (DBTransaction trans, someParam Object) {}
    ...
    }
    }

    When you call the method of application module, object entity or class of same view object, call

    PlSqlUtils.myHelperMethod (getDBTransaction (), paramValue);

    Unlike Transaction.executeCommand (), allows you to provide features like the setting procedure of parameter values, recovery of the values of the parameters, etc.

    Hope this helps,
    Avrom

  • How to call a stored procedure PL/SQL of the Disqualification?

    I figured I could do this from a Groovy script but I am unable to make it work.

    Let's take the simplest scenario:

    At the end of a job, I have a need to call an once stored procedure that has no arguments.

    Translated by the logic of the stored procedure with Disqualification is not an option.

    If you must call it once at the end of a task, you must use the external task.

    If you call a procedure for each record, it can be done using a script.

  • You can have two stored functions with the same name?

    Hi all

    You can have two stored functions with the same name?

    My version of DB - connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0

    Thank you.

    You can have the same name as long as they are within a package and with different parameters

    create or replace package test_pkg

    as

    function my_func (p1 in number)

    return number;

    function my_func (at number p1, p2)

    return number;

    end test_pkg;

    /

    create or replace package body test_pkg

    as

    function my_func (p1 in number)

    Return number

    as

    Start

    return 0;

    end;

    function my_func (at number p1, p2)

    Return number

    as

    Start

    return 0;

    end;

    end test_pkg;

    /

  • Connection problem with the database, the closure of Flex Builder

    Hello

    I developed a web page that connects to a database, reads data and it shows on the screen. I use HTTPService to connect to a php server that supports MySQL data. Everything is OK when I run the Flex Builder web page, but when I run the page doing double click on the file released .html the connection fails and the program generates this error:

    [RPC Fault faultString = "" error #2028: file:///Q:/2009-08-05-1330FinalFrontEnd/bin-release/FrontEnd.swf SWF file with Local file system cannot access Internet URL http://localhost/Test2/Test2.php. "faultCode ="InvokeFailed"faultDetail ="null""]
    to mx.rpc::AbstractInvoker / http://www.adobe.com/2006/flex/mx/internal: call ()
    at mx.rpc.http.mxml::HTTPService/ http://www.adobe.com/2006/flex/mx/internal: call ()
    at mx.rpc.http::HTTPService/send()
    at mx.rpc.http.mxml::HTTPService/send()
    in FrontEnd / submitLabelsQuery)
    in FrontEnd / updateLabels)
    in FrontEnd / ___FrontEnd_SetEventHandler5_handler)

    Does anyone know how can I use the web page without using Flex Builder?

    More information:

    I use Flex Builder 3 to the development of the web page and WampServer 2.0 for the connection with the database.

    Thank you

    Onditz

    Hi Onditz,

    Previously, I also faced the same problem when working with Php as the Backend, the problem is that Flex does not call your PHP page

    It is the way I solved it to export your Flex Project at Flex Release Build.

    Right click on the export of project---> Flex project---> Release Build---> copy all the files on your server where all of your PHP files are and then call the application from the browser

    http://localhost/test2/sample.html. »

Maybe you are looking for