How to execute a stored procedure on Sybase with SQL Developer

We have accessed Sybase 15 with SQL developer.

We can see the data in the table, if we do not, run the stored procedure (for instance sp_who) developed on Sybase.

Could you tell me how we execute the stored procedure on Sybase with SQL Developer Sybase?

Thank you

Shige

We will not intended to be a Sybase ASE customer.

But

A SQL Developer... @dermotoneill: Workheet advice

Tags: Database

Similar Questions

  • How to execute a stored procedure that returns a cursor?

    How to execute a stored procedure that returns a cursor?

    Follow the code:

    CREATE OR REPLACE PROCEDURE stp_cashin_grupo
    (p_func in VARCHAR
    p_cod_grup in full
    p_des_grup in VARCHAR
    p_logi in VARCHAR
    p_curs_rset ON infoc.pck_cashin_grupo.curs_rset
    )
    IS
    BEGIN

    If p_func = "1" then
    OPEN FOR P_curs_rset
    Select
    cod_grup
    des_grup
    dat_manu_grup
    des_logi_manu
    of infoc.tbl_cashin_grupo
    order of des_grup;
    end if;
    END stp_cashin_grupo;


    and packaging:

    CREATE or REPLACE PACKAGE pck_cashin_grupo
    AS
    TYPE curs_rset IS REF CURSOR;
    END pck_cashin_grupo;

    My question is how to execute in sql plus?
    Stp_cashin_grupo EXEC ('1', 0, ", '465990', my doubt is how to move the cursor as return)


    Thank you

    It is described in the manual

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14357/CH5.htm#sthref1122

  • How can I force DAC to run always full load for one of the task that executes the stored procedure? And remaining tasks load incremental in the second and sub sequent executions.

    Hello

    How can I force DAC to run always full load for one of the task that executes the stored procedure? And remaining tasks load incremental in the second and sub sequent executions.

    Thank you

    Jay.

    Hi if your task is running an informatica mapping you can set your DAC task to run the full mapping for incremental and full loads, so tab task just point to the mapping.

    Hope that helps.

    Thank you

  • How to call a stored procedure in ADF

    How to call a stored procedure in the ADF (Jdev 11.1.1.6)?

    Code sample stored procedure:

    CREATE or REPLACE PROCEDURE SP_HELLOWORLD

    (

    NAME IN VARCHAR2

    OUT VARCHAR2 DESIRES

    ) AS

    BEGIN

    WISHES: = 'Hello'. name | ', Welcome to MS.';

    END SP_HELLOWORLD;

    Your Code of ADF is:

    try {}

    System.out.println ("* beginning of the code *");

    String sql = "start SP_HELLOWORLD(:NAME,:WISHES); end; ";

    CallableStatement st = getDBTransaction () .createCallableStatement (sql, getDBTransaction(). DEFAULT VALUE);

    st.setObject ("NAME", "ABC"); Replace with required param

    st.registerOutParameter ("WISHES", Types.VARCHAR); import java.sql.Types;

    St.Execute ();

    System.out.println ("the output of the function DB is:" + st.getObject ("WISHES"));

    System.out.println ("* end of code *");

    } catch (Exception e) {e.printStackTrace () ;}

  • Problem when executing a stored procedure

    Hello
    im a beginner, using v (10.2.0.1.0) of Oracle 10 g on a linux machine.
    Cannot run after the procedure through query iSQLPLUS im interface.

    create or replace procedure (pd_hr)
    PNO varchar2,
    PDT date default sysdate,
    PHR number,
    perr_msg out varchar2
    ) as
    Start
    PHR: = 2;
    end pd_hr;

    Number of phr VARIABLES;

    Perr_msg VARIABLE VARCHAR2 (250);

    run pd_hr('pno',,phr,perr_msg).

    It flashes the following error when I try to execute the stored procedure:
    ERROR on line 1:
    ORA-06550: line 1, column 44:
    PLS-00201: identifier "PHR" must be declared.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    I ran the following query through DBA connection before performing the procedure:
    GRANT EXECUTE ANY PROCEDURE 'SCOTT ';

    Any form of assistance will be invaluable!

    Peter

    Hi, Peter,.

    Put a colon (': ') before binding variable names except when declaring:

    -- No colons here:
    VARIABLE phr number;
    VARIABLE perr_msg VARCHAR2(250);
    
    -- Colons needed here
    execute pd_hr ('pno', NULL, :phr, :perr_msg);
    
  • Simple question-how to call a stored procedure or function of apex?

    Simple question-how to call a stored procedure or function of apex?
    Thanks advance.
    Doug

    Hi Doug,.
    You can call a procedure or function of apex. It depends on what you want to do with the function or procedure. If you want to retrieve table data in a specific area, you can try something like this-

    The following statement creates the function get_bal on the oe.orders of sample table (PL/SQL is in italics):

    CREATE FUNCTION get_bal (acc_no in NUMBER)
    RETURN NUMBER
    IS acc_bal NUMBER (11.2);
    BEGIN
    SELECT order_total
    IN acc_bal
    Orders
    WHERE customer_id = acc_no;
    Return (acc_bal);
    END;
    /

    The function created in the previous example can be used in a SQL statement. For example:

    SELECT get_bal (165) FROM DUAL;

    GET_BAL (165)
    ------------
    2519

    hope this will help,

    Kind regards

    Pascal M
    http://Tajuddin.whitepagesbd.com

  • How to connect to microsoft sql server with sql developer 4.1 2014

    Hello

    Please,

    I need to connect to a Microsoft SQL Server 2014 with SQL Developer 4.1 database, I installed the appropriate jdbc driver microsoft as having the active tab for SQL Server and to add the connection.

    Thank you very much

    We support no migration of SQL Server 2014, but you should be able to connect. There is a problem around tables in the connection of the navigation tree, but you should be able to execute queries and PROBABLY get a migration project going.

  • How to connect my APEX with SQL Developer workspace?

    Hi all

    I am a new user of Oracle Apex. Is there a way to connect to my workspace created to http://apex.oracle.com/pls/apex with SQL Developer. If so, then let me know how. If someone has done successfully then please help me.

    Thank you

    Gerard

    Hi Gerard,

    It is not possible to do this on apex.oracle.com.

    Joel

  • How to create a stored procedure to delete and create table

    Version: Oracle 10g

    I am trying to create a stored procedure that is delete it and create a table based on a select statement. I can create the table, but I can't let it go.

    CREATE or REPLACE procedure EC_LOAD is
    Start
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    Of
    sales_revenue;
    end ecload;

    I need to drop the Sales_table before inserting the values. How can I do this?

    user610131 wrote:

    I need to drop the Sales_table before inserting the values. How can I do this?

    If you drop off where you insert it :)? Do you mean DELETE or TRUNCATE?

    If table can be truncated (and don't forget TRUNCATE is DDL then he will commit):

    CREATE OR REPLACE procedure EC_LOAD is
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE Sales_table';
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    

    Otherwise, use DELETE:

    CREATE OR REPLACE procedure EC_LOAD is
    begin
    DELETE Sales_table;
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    

    SY.

  • RUN THE CALLBACK IMMEDIATE VS? TO EXECUTE THE STORED PROCEDURE

    Hello

    StatementExc: = SYMBOLS. DYNPLSQL_PLUGIN_CALL_BEGIN | rec_WfFunctionSourceCode.Schema | SYMBOLS. DOTc
    || rec_WfFunctionSourceCode.package | SYMBOLS. DOTc
    || rec_WfFunctionSourceCode.OPERATION_FUNCTION_CODE | SYMBOLS. DYNPLSQL_PLUGIN_CALL_END;

    -dbms_output.put_line (4 CALL ' | to_char (SYSTIMESTAMP));
    EXECUTE IMMEDIATE StatementExc with the HELP OF RetVal1, IN OUT eoBufferia;

    How to make the implementation of RECALL as an EXECUTE IMMEDIATE to exec Stored Procedure another package?

    Thanks in advance,

    Best regards

    Domenico Simone

    Hi, Domenico,.

    What is CALLBACK in PLSQL?

    Here is an example of use of object types [emulating callbacks | http://www.adp-gmbh.ch/blog/2005/august/19.html]

    Concerning
    Peter

  • 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;
      }
    }
    
  • How can I transfer content from an XML file in a MS SQL database of the stored procedure using LabWindows/CVI SQL Toolkit?

    Hello

    I have a problem to transfer content to an XML file in a MS SQL database through a stored procedure data/fixed. I am able to transfer the content of the file using method...

    HSTMT = DBPrepareSQL (hdbc, EXEC usp_InsertReport " ... ");

    resCode = DBExecutePreparedSQL (hstmt);

    resCode = DBClosePreparedSQL (hstmt);

    ... but in this case, I am not able to read the return value of the stored procedure.

    I tried to follow the example of the stored procedure in the help documentation (DBPrepareSQL), but I miss a xml data type?

    No idea how to solve my problem?

    Cake of KR

    DianaS salvation,

    Thanks for your comments. During this time I found another way which fullfill my needs:

    resCode = DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE, DB_COMMAND_TEXT);

    sprintf (sz_SqlStatement, "DECLARE @TESTID INT EXEC @TESTID = usp_InsertReport ' SELECT 'RetVal' %s = @TESTID", sz_Buffer ");
    HSTMT = DBActivateSQL (hdbc, sz_SqlStatement);

    While ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS)

    {

    / * Enter values in the record. */

    resCode = DBGetColInt (hstmt, 1, & s32_TestId);
    }

    resCode = DBDeactivateSQL (hstmt);

    sz_Buffer is the content of the XML file.

    Cake of KR

  • How to call oracle stored procedure with hibernate

    Hi all
    I wrote the following stored procedure:

    create or replace
    PROCEDURE SP_GET_NUMBER (p_cursor sys_refcursor, departmentId in number, userId in number, documentTypeId number)
    as
    Enter the integer;
    sqlScript varchar2 (60);
    Start
    sqlScript: = "select registrationnumber_seq.nextval from dual;
    immediately run sqlScript in register;
    dbms_output.put_line ('Nextval is: ' |) To_char (Regid));
    insert into roketsanuser.registrationnumbers
    (id, departmentid, documenttypeid, number, registrationstatus, status, updatedate, updateuserid, version)
    values
    (enter it, null, null, enter it, 0, 0, sysdate, 0, 0);
    commit;
    Open the p_cursor for
    Select id
    roketsanuser.registrationnumbers® systems
    where reg.id = regid;
    end;

    And I define in the annotations in my entity class:

    @Entity (name = "Number")
    @Table (name = "REGISTRATIONNUMBERS")
    @SequenceGenerator (name = "REGISTRATIONNUMBER_SEQ", sequenceName = "REGISTRATIONNUMBER_SEQ")
    @org.hibernate.annotations.NamedNativeQuery (name = "SP_GET_NUMBER", query = "{call? "{= SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)}"
    Callable = true, readOnly = true, resultClass = RegistrationNumber.class)
    @EntityListeners ({BaseEntityListener.class})
    Number/public class extends BaseEntity

    I call the query in my Dao class:

    public number getNumberForIncomingPaperworkByStoredProcedure (EntityManager Manager, number number)
    {
    A session = (Session) manager.getDelegate ();
    query org.hibernate.impl.SQLQueryImpl = (SQLQueryImpl) session.getNamedQuery ("SP_GET_NUMBER");

    query.setParameter ("departmentId", ObjectUtil.isNotNull (registrationNumber.getDepartment ())? registrationNumber.getDepartment () .getId (): "");
    query.setParameter ("userId", ObjectUtil.isNotNull (registrationNumber.getUser ())? registrationNumber.getUser () .getId (): "");
    query.setParameter ("documentTypeId", ObjectUtil.isNotNull (registrationNumber.getDocumentType ())? registrationNumber.getDocumentType () .getId (): "");
    Collection list = query.list ();
    return new RegistrationNumber();
    }

    But when I run the application exception occurred:
    < 01/02/2013 10:04:24 EET > < opinion > < Stdout > < BEA-000000 > < hibernation:
    / * name of SP_GET_NUMBER native SQL query * / {call? = SP_GET_NUMBER (?,?,?)} >
    < 01/02/2013 10:04:27 EET > < opinion > < Stdout > < BEA-000000 > < 10:04:27, 811 ERROR [IncomingPaperworkMBean] EJB Exception:; nested exception is:
    org.hibernate.exception.SQLGrammarException: could not execute the query. nested exception is: org.hibernate.exception.SQLGrammarException: could not execute the query >

    This is perhaps the reason why, please help me?

    Thanks in advance

    Message to research in syntax of:

    @org.hibernate.annotations.NamedNativeQuery

    It seems that following is a possible cause (but I'm not sure about this one):

    Query = "{call?" "{= SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)} '.

    You can change this:

    Query = "(?)". (= appeler SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)) "...

    or

    Query = "(call SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)).

    and check if that helps...

    You can take a look at:

    https://Forum.Hibernate.org/viewtopic.php?p=2401604

    HTH,

    Bravo!
    AJ

  • How to test the stored procedure in SQL Developer or SQL Plus

    Hello

    It's small, but I am confused. Can someone give me the EXACT command to run to test my stored procedure described below. Please don't refer me to the documentation or offer some sort of pseudocode. I've been through the documentation - and through it again - and I just don't get it. I know that the procedure works in general because I'm calling ColdFusion, but I want to test developer SQL or SQL more before I call my ColdFusion page - it only makes sense. I'm probably not initialize variables right or something - not sure.

    You will see that it is a line right insert in the firstname and lastname data base and there are 2 IN OUT values as well. Please use a fake name for the firstname and lastname values to demonstrate. I appreciate it!

    create or replace
    procedure sp_insertDirector_A)
    vFirstname IN Directors.Firstname%TYPE,
    vLastname IN Directors.Lastname%TYPE,
    vInsertStatus in on NUMBER,
    vNewDirectorID IN OUT NUMBER
    )
    IS
    row_count NUMBER;
    BEGIN
    SELECT Count (*) FROM directors WHERE Lastname vLastname = row_count;
    IF row_count > 0 THEN
    vInsertStatus: = - 1;
    RETURN;
    END IF;

    INSERT INTO administration)
    FirstName, Lastname)
    VALUES)
    vFirstname, vLastname
    );

    SELECT Directors_Seq.CURRVAL INTO vNewDirectorID FROM DUAL;
    vInsertStatus: = 1;
    END;

    If someone can tell me exactly how to test, I'd appreciate it. I asked on another site and got many responses that I tried and did not work due to various errors. Once I get a working example, I'm sure I can get the idea and continue on. I mainly use the SQL Developer.

    Thank you, mallethead

    p.s. I think that my if - THEN followed by the instruction INSERT is fixed - it is woring. Seems a little odd to me however.
    declare
       l_instatus  number;
       l_newdirid  number;
    begin
       sp_insertDirector_A('bob','smith',l_instatus,l_newdirid);
       dbms_output.put_line(l_instatus);
       dbms_output.put_line(l_newdirid);
    end;
    /
    
  • How do we call stored procedure in owb?

    Hello

    I have 20 mapping and I stored that I need to call after 20 mapping completed successfully.

    I want to run my stored as 21st mapping procedure. I should not call my stored procedure in the 20th mapping as the mapping process.

    How to achieve this?

    What I did was, I created another dummy mapping and just create simple mapping (copy couple of records from a fictitious table to another table. dummy so I called the post, process mapping procedure. Is there another way, we can achieve this task?

    In informatica, we have retained the transformation of the procedure. Is there something equivalent in OWB?

    Any help is appreciated!

    Two options, you can: -.

    1. create in OWB.

    Under Oracle-> your name of the Module-> Transformation
    -> Function
    -> Procedure
    -> Package
    2. right click-> new (it will sail with series of screen)

    2 2 creer create database, and then import into OWB.

    Once you have created and then form be it you can drag directly and drp then to the workflow process as done with mapping.

    See you soon
    Katia

    Published by: Nawneet_Aswal on July 19, 2010 01:53

Maybe you are looking for

  • Windows Photo Gallery - error OX 88982f72

    After you change the system does not new photo to go to print or save. Above the error code pops up.

  • Stop to rearrange my desktop icons!

    Hello. I would like to know if it is possible to stop Windows from automatically rearrange my icons to fill the holes on my desk. This happens when I make changes to a file (.doc, for example), and it's getting boring.

  • in windows movie maker, how to make an introduction countdown?

    as in the old movies, they will "4... 3... 2... 1..."and then start.I thought it would be funny to make it from 13 or 10

  • What to do when a PDC to Windows Server 2003 fails

    What to do when a PDC to Windows Server 2003 fails, We have already installed additional domain controllers to replicate with the PDC, but after that the Principal domain controller only not the system slows down and you get it working again. What is

  • Can't fix the driver AHCI, Windows 7

    I need to fix my AHCI, I think. I have windows on a SSD. Installation of Windows with the AHCI active and I have checked the registry for HKEY_LOCAL_MACHINE\System\CurrentControlSet\services\msahci\start setting is 0. I think that the pilot must have