How to incorporate  a Stored procedure with ARD file (ADD ON)

hi experts
i created a SP  which is called by the following code.
Dim GD As SAPbouiCOM.Grid
        Dim Query As String = "exec sp_Attendance_Report'" & vmonth & "','" & vyear & "'"
        GD = objForm.Items.Item("10").Specific
        GD.DataTable.ExecuteQuery(Query)
while creating add on (ard file )how to incorporate   this stored procedure?
thanks in advance

Hello
When the addon first time connect, you must check that the SP is exists or not exists in target database. If not exist, you may create it.
sql to check the sp exists
select 1 from sysobjects where name like 'sp_Attendance_Report'
if this query returns 1 the sp is exists in the database, skip installation, if returns no records, you must install the sp via recordset by create procedure command.
Regards
János

Similar Messages

  • How to execute plsql stored procedure with DbAccess

    sessionInfo object can give DbAccess .through
    which u can use javax.infobus.DbAccess API to
    execute sql satement and stored procedures according to infobus API .iam able to
    execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
    how to take in and out parameters
    suggestions are welcome
    waiting for your suggestions

    I am also looking for the same.
    Did you get any info on this
    Thanks,
    jagan
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by chandra sekhar ([email protected]):
    sessionInfo object can give DbAccess .through
    which u can use javax.infobus.DbAccess API to
    execute sql satement and stored procedures according to infobus API .iam able to
    execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
    how to take in and out parameters
    suggestions are welcome
    waiting for your suggestions<HR></BLOCKQUOTE>
    null

  • How to call a Stored Procedure with a REF CURSOR output parameter

    I am looking forward an example that call a stored function/procedure with a REF CURSOR output parameter and get the result.
    In other words, I have a stored function/procedure that execute a SELECT statement using the OCI library and then it could get the values of each column and each row.
    I put a code snippet, it have only the main thing to call a simple stored procedure and print the name of each column of the cursor, but I couldn´t to print out the values in the table that call the stored procedure.
    I understand that the next step, it is to call a OCIStmtFetch.
    How to associate the cursor with the OCIStmtFetch?
    If you need more information, only tell me.
    I am using ANSI C with HP-UX Operative System (C for HP-UX) and Oracle 10g.
    Regards.
    Antonio Garcia
    /* callOracleSP */
    #include <stdio.h>
    #include <string.h>
    #include <oci.h>
    #include <stdlib.h>
    char* pConnectChar ="server";
    char* pUsernameChar = "user";
    char* pPasswordChar = "passwd";
    char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :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("OCILogon retval=%d\n",retval);
    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 = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
         (sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
    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, (ub4) OCI_DEFAULT);
    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, (ub4) OCI_DEFAULT);
    printf("StmtExecute retval=%d\n",retval);
    /* How to get the values of the cursor? */
    /* Get number of parameters of the Cursor */
    OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
         (ub4)OCI_ATTR_PARAM_COUNT, pOciError);
    printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
    for (int pos = 1; pos <= (int)parmcnt; pos++)
         OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
              (ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
         retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,
              (ub4) pos );
         OCIAttrGet((void*) pOciParam, (ub4) 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("Column %i\tNAME = %.*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('NY', 10, 'NEW YORK')
    INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES('NY', 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 are T/SQL specific global variables. */
    TYPE RCT1 IS REF CURSOR;/*new weak cursor definition*/
    END globalPkg;
    CREATE OR REPLACE PROCEDURE SP_ADDCITY(
    P_STATE_CODE IN VARCHAR,
    P_CITY_CODE      IN NUMBER,
    P_CITY_NAME      IN VARCHAR2,
    P_RETURN IN OUT NUMBER)
    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 := SQL%ROWCOUNT;
    EXCEPTION
    WHEN TOO_MANY_ROWS THEN
    StoO_rowcnt := 2;
    WHEN 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 RC1 FOR
    SELECT STATE_CODE, CITY_CODE, CITY_NAME
    FROM CITIES
    WHERE STATE_CODE = STATE_KEY
    ORDER BY CITY_CODE;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
         END;
    /

    Hi Mark,
    Thanks for your recommendations.
    I change the code with OCIDefineByPos, one for each parameter from cursor and then use the OCIStmtFetch.
    I don´t receive a error when call OCIDefineByPos, but when I call OCIStmtFetch receive a -1 error number.
    What is wrong with the code?
    The script is the same.
    I need your help!
    Best Regards!
    Antonio Garcia (Mexico)
    This the new code:
    #include <stdio.h>
    #include <string.h>
    #include <oci.h>
    #include <stdlib.h>
      char*   pConnectChar ="ORAC617";
      char*   pUsernameChar = "C617_005_DBO_01";
      char*   pPasswordChar = "Tempora1";
      char*   sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
      int     retval;
      ub4 parmcnt=0;
      ub4 pos2=0;
      sb2   *c_indp;
      text *pcoln[20], *name,*name2;
      ub4 namelen[20],len;
      ub2 type,size;
      char state_key[5];
      OCIDefine        *pdef;
      OCIBind          *p_bnd;
      ub1          **c_buf;
      OCIStmt*     pOciStatement;      /* Statement handle */
      OCIStmt*     pOciStatCursor;     /* Statement handle */   
      OCIError*    pOciError;          /* Error handle */
      OCIEnv*      pOciEnviron;        /* Environment handle */
      OCIServer*   pOciServer;         /* Server handle */  
      OCISession*  pOciSession;        /* Session handle */
      OCISvcCtx*   pOciServiceContext; /* Service Context handle */
      OCIBind*     pOciBind[500];      /* Bind handle */
      OCIParam*    pOciParam;          /* Param handle */
      int OCI_Fetch(OCIStmt *p_select,OCIError *p_err, int *piOcc)
      int iOcc, rc; 
      rc=OCIStmtFetch(p_select,p_err,1,OCI_FETCH_NEXT,OCI_DEFAULT);
      printf("rc fetch %i",rc);
      if(rc==0&&piOcc!=NULL){
           printf("entro al if");
        iOcc=*piOcc;
        *piOcc=iOcc+1;
      return rc;
    int main()
    int pos,i=0,rc;
      retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
      printf("EnvCreate retval=%d\n", retval);
      retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
      printf("EnvInit retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_ERROR retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_SVCCTX retval=%d\n",retval);
      retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
      printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
                  strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
                    (unsigned char *)pConnectChar,strlen(pConnectChar));
      printf("OCILogon retval=%d\n",retval);
      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);
      printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
      retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
                 (sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
      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, (ub4) OCI_DEFAULT);
      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, (ub4) OCI_DEFAULT);
      printf("StmtExecute retval=%d\n",retval);
      c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
      c_indp=(sb2 *)calloc(sizeof(sb2 *),3);
      // Get number of parameters of the Cursor
      OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
                  (ub4)OCI_ATTR_PARAM_COUNT, pOciError);
      printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
      for (pos = 1; pos <= (int)parmcnt; pos++)
           OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
                (ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
           retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,(ub4) pos );
           // Get the column name
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &name,(ub4 *) &len, (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
            // Get the column datatype
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &type,(ub4 *)0,(ub4)OCI_ATTR_DATA_TYPE,(OCIError *)pOciError);      
            // Get the column size
           OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &size,(ub4 *)0,(ub4)OCI_ATTR_DATA_SIZE,(OCIError *)pOciError);
           printf("Column %i\tNAME = %.*s \ttype %d \tsize %d\n",pos,len,name,type,size);
           // OCIDefine ByPos, one for each parameter
           // c_buf store the STATE_CODE, CITY_CODE and CITY_NAME columns from the cursor
           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);     
          printf("OCIDefineByPos retval=%d\n,rc);
      // call OCIStmtFetch. In the next line, I receive the error
      rc=OCIStmtFetch(pOciStatCursor,pOciError,1,OCI_FETCH_NEXT,OCI_DEFAULT);
      printf("rc fetch %i",rc);
      return 0;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to call oracle stored procedure with OUT parameter?

    I create oracle stored procedure in eclipse oepe
    PROCEDURE SP_SELECT_ORA (
    ID_INPUT IN VARCHAR2,
    ID_OUTPUT OUT VARCHAR2,
    PASSWD_OUTPUT OUT VARCHAR2,
    NAME_OUTPUT OUT VARCHAR2) IS
    BEGIN
    SELECT EMP_ID, EMP_Passwd, EMP_Name
    INTO ID_OUTPUT, PASSWD_OUTPUT, NAME_OUTPUT
    FROM family
    WHERE EMP_ID = ID_INPUT;
    END;
    and I try to call the sp in jpa like below,
    @NamedNativeQueries({
         @NamedNativeQuery(name = "callSelectSP", query = "call SP_SELECT_ORA(?,?,?,?)", resultClass = Members.class)
    @Entity
    @Table(name="family")
    public class Members implements Serializable {
         @Id
         @Column(name = "EMP_ID")
         private String ID;
         @Column(name = "EMP_Passwd")
         private String Passwd;
         @Column(name = "EMP_Name")
         private String Name;
    ==============
    @PersistenceContext(unitName="MyFamily")
         EntityManager em;
    query = em.createNamedQuery("callSelectSP");
         query.setParameter(1, ID);
         String id_output = null;
         String passwd_output = null;
         String name_output = null;
         query.setParameter(2,id_output);
         query.setParameter(3,passwd_output);
         query.setParameter(4,name_output);
         query.executeUpdate();
         member = (Members)query.getSingleResult();
    But this query throws exception,
    19:55:35,500 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 1465, SQLState: 72000
    19:55:35,500 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-01465: invalid hex number
    I don't know how. Pls, give me your advice. Thanks in advnace.
    Best regards

    Thank you for your reply, Chris!
    I tried this one.
    @NamedNativeQueries({
    @NamedNativeQuery(name = "callSelectSP", query = "exec SP_SELECT_ORA( ?, :id_output, :passwd_output, :name_output) " , resultClass = Members.class)
    @Entity
    @Table(name="family")
    public class Members implements Serializable
    ===================
    query = em.createNamedQuery("callSelectSP");
    query.setParameter(1, ID);
    String id_output = null;
    String passwd_output = null;
    String name_output = null;
    query.setParameter("id_output", id_output);
    query.setParameter("passwd_output", passwd_output);
    query.setParameter("name_output",name_output);
    query.executeUpdate();
    On Console hibernate shew the sql and ora # like below,
    19:59:25,160 INFO [stdout] (http--127.0.0.1-8080-1) Hibernate: exec SP_SELECT_ORA( ?, ?, ?, ?)
    19:59:25,192 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 900, SQLState: 42000
    19:59:25,192 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-00900: Invalid SQL statement
    Pls, inform me your advice. Thanks in advance.
    Best regards.

  • How to execute a stored procedure with an out parameter ?

    Guys I am struggling with executing a stored procedure from sql plus.I mean my stored procedure has 2 input parameter and 1 out put parameter (status of the execution).
    MY_PROCEDURE(p_name in varchar2,p_age in number,p_status out varchar2)
    end my_procedure;
    When I say
    EXECUTE MY_PROCEDURE('manohar','Shetty');
    i get insufficient parameters errors.
    please help.

    EXECUTE isn't a valid PL/SQL construct. It's a SQL*Plus command. You don't want to put any SQL*Plus commands in a PL/SQL block.
    You can always execute a stored procedure purely through PL/SQL
    begin
      my_stored_procedure( x, y, z );
    end;SQL*Plus happens to give you the execute command so you can avoid the begin and end statements.
    Justin

  • Sqlbase - how to run a stored procedure with SYSDATE argument

    Hi, everyone!
    I'm trying to execute a stored procedure :
    cstmt = con.prepareCall("{ call PR_MYPROCEDURE(?, SYSDATE-1, SYSDATE) }");
    cstmt.setInt(1,1);And i get and SqlException - java.sql.SQLException: prepareCall(): An unexpected character 'S' found.
    Is there any way to pass a SYSDATE like argument?

    the problem that for sqlbase current date function is SYSDATE'sqlbase' the database?
    I couldn't ensure that the syntax that you posted looks correct but it seems possible.
    That would suggest there is a driver problem.
    Best I can suggest is modify the proc so it expects nulls for two parameters and then it creates the expressions that you are passing. Or create java Timestamp values and pass those.

  • How to call a stored procedure with only one output parameter using toplink

    Can anybody help me to get out of this exception. I have tried through several ways, but could not find the solution.
    I have a following stored proc : -
    CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT VARCHAR2)
    IS
    buff VARCHAR2(32000) := ' ';
    BEGIN
    buff := ' Hi From Stored Proc' ;
    outbuffer : = buff;
    END;
    When I am executing it using following code :-
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("spt_remove_duplicates_pr");
    call.addNamedOutputArgument("a","a",String.class);
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    String buff1 = (String) session.executeQuery(query);
    I am getting the exception as : -
    LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.4 (Build 432)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    INTERNAL EXCEPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ERROR CODE: 6550
         at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
         at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
         at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)
    INTERNAL EXCEPTION STACK:
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1141)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2149)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2032)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2894)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
         at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
         at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)

    I got the partial solution. The code is working now, however I am not getting the return value from stored proc.
    The changed code is as :-
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("spt_remove_duplicates_pr");
    call.addNamedOutputArgument("outbuffer","outbuffer",StringBuffer.class);
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    StringBuffer buff1 = (StringBuffer) session.executeQuery(query);
    System.err.println("Done ! Output is : " + buff1);
    The result is :-
    Done ! Output is : null
    How can I get the output ?

  • How to turn a stored procedure with a parameter into table function?

    Could someone please let me know how to turn the SP below into table-value function? I want to be able to run this function by using SELECT statements with the parameter. Thanks
    CREATE
    PROCEDURE
    [dbo].[Transformation](@year
    varchar(4))
    AS
    BEGIN
    Declare@Q1
    Varchar(100)=
    '['+@year+'Q1'+']'
    Declare@Q2
    Varchar(100)=
    '['+@year+'Q2'+']'
    Declare@Q3
    Varchar(100)=
    '['+@year+'Q3'+']'
    Declare@Q4
    Varchar(100)=
    '['+@year+'Q4'+']'
    Declare@StrQuery
    Varchar(1000)
    Set@StrQuery
    = 'Select Date, Job, [Cost Elements],Units,
    '+@Q1+'+'+'+'+@Q2+'+'+'+'+@Q3+'+'+'+'+@Q4+'
    as [Amounts], ''Update'' as [Description]  From Export with (nolock)'
    --Print @StrQuery
    Exec(@StrQuery)
    END

    You cannot use dynamic SQL in user-defined functions.
    Work around (not an ideal solution, it has problems): OPENQUERY.
    Blog:  http://www.sqlusa.com/bestpractices2005/selectfromsproc/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to use stored procedure with many return results and variable with perl

    Hi everybody,
    i´m writtting now a Perl programm, wich use a oracle stored procedure with more than 1 result and 1 variable(I have to return 2 variable fpr each result). I don´t now how I can get it.I already search the web but I didn´t find.
    My example:
    PROCEDURE get_projects_and_sub_projects (
    v_project_id IN INTEGER,
    v_project_c_id OUT INTEGER,
    v_project_id_find OUT VARCHAR2
    IS
    BEGIN
    SELECT c_id, proj_id
    INTO
    v_project_c_id,
    v_project_id_find
    FROM t_projet
    WHERE t_projet .ksa_pro_art_kbz = 'KU'
    AND t_projet.proj_id LIKE v_project_id || '%';
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    v_project_c_id := NULL;
    v_project_id_find := NULL;
    WHEN OTHERS
    THEN
    kmessages.error (NULL,
    'get_projects_and_sub_projects',
    'Project-Name: ' || v_project_id,
    'Errornumber: '
    || SQLCODE
    || ' Error: '
    || SQLERRM,
    TRUE,
    TRUE
    raise_application_error (-20001,
    'Error '
    || SQLCODE
    || ' get_projects_and_sub_projects: '
    || SQLERRM,
    TRUE
    END get_projects_and_sub_projects;
    in Perl Program:
    sub get_projects_unterprojects_name($$){
    my ($db_handle, $proj_name_id) = @_; #$db_handle ist the DB Connection return value
    my $db_proj_c_id;
    my $db_proj_name;
    eval{ my $csr = $db_handle->prepare(q{
    BEGIN
    pro_doc_ber.get_projects_and_sub_projects(:proj_name_id, :db_proj_c_id, :db_proj_name);
    END;
    # parameter value
    $csr->bind_param(":proj_name_id", $proj_name_id);
    # return values
    $csr->bind_param_inout(":db_proj_c_id", \$db_proj_c_id, 11);
    $csr->bind_param_inout(":db_proj_name", \$db_proj_name, 20);
    $csr->execute(); };
    But this didn´t work. Could somebody give me some idea?
    Thank you
    Felx

    Some additional info would probably be helpful.
    What is your programming enviironment? Java?
    In any case I suspect that you will need to use the OCI to deal with specific Oracle types such as user defined object types -- thats not standard ANSI SQL.
    In Java I believe you need to use OPAQUE, there are some examples out there. I'm mostly a PL/SQL developer with some Java expereince so others here are more qualifed to answer your question more directly.

  • How to call PL/SQL stored procedure with TWO or more arguments from URL?

    Hi all,
    does anybody know, how to call stored procedure with more than one argument?
    How to do this with one argument is known -
    <img src="#OWNER#.retreive_img_data?i_id=#IMG_ID#" width="70" height="80" alt="No Picture">
    But if I need to call procedure with two formal parameters? And need to pass through URL, for example, two page item values?

    Just separate with an "&". Using your previous example, I'll add i_name and i_type:
    <img src="#OWNER#.retreive_img_data?i_id=#IMG_ID#&i_name=somename&i_type=jpg" width="70" height="80" alt="No Picture" />
    Tyler

  • How to call a AS/400 Stored Procedure with a BigDecimal Value?

    Hi,
    Could you pls tell me how to call a stored procedure on the AS/400 which request an input value of packed decimal(10P 4) value.
    I have tried to convert it to a BigDecimal in Java and call the stored procedure as follows but it gave me a decimal point error on the AS/400.
    Could you pls show me where I'm wrong in the following code.
    Thanks
    Jan
    ========Java program to call AS/400 Stored procedure with setBigDecimal()===========
    //Assign the value to String
    string sBDVal = "30"
    //Convert the String value to BigDecimal
    BigDecimal bdAmt = new BigDecimal(sBDVal);
    //Call Stored Procedure with parameters,
    CallableStatement callSP = conn.prepareCall("{call OSCUPDLENS(?,?,?)}");
    // Set in parm values
    callSP.setString(1,"Value 1");
    callSP.setBigDecimal(2,bdAmt);
    callSP.setString(3,"");
    // Register out parameter
    callSP.registerOutParameter(3, Types.CHAR);
    // Execute call to stored procedure
    callSP.execute();
    // Retrieve out parameters
    sErrFlag = callSP.getString(3).trim();
    ========================Create Stored Procedure on AS/400===========================
    c/EXEC SQL
    c+ CREATE PROCEDURE TESTSPROC
    c+ (IN VAL1 CHAR ( 8),
    c+ IN BDAMT DEC (10, 4),
    C+ INOUT ERR CHAR ( 1))
    C+ LANGUAGE RPGLE NOT
    C+ DETERMINISTIC NO SQL EXTERNAL NAME TESTSPROC PARAMETER STYLE
    C+ GENERAL
    c/END-EXEC
    ======RPG program on AS/400 to accept the BigDecimal value to a Packed decimal======
    * Initialize the i/p parameter
    DP#VAL1 S 8A
    DP#AMT S 10P 4
    DP#ERR S 1A
    C*Input parameters
    C *ENTRY        PLIST                          
    C PARM P#VAL1
    C PARM P#AMT
    C PARM P#ERR

    Could you pls show me where I'm wrong in the following codeI don't know, you're doing a lot of things I have never tried. But "decimal data error" most likely means that the stored procedure is expecting packed data and the driver is giving it zoned data, or vice versa. You could confirm that by dumping your variables inside your RPG. If that is your problem, you could work around it by redefining your BDAMT parameter as integer or string and reformatting it in the RPG.

  • How to change stored procedure with Table Valued Parameter

    I am not sure how to change the normal stored procedure with Table Value Parameter.Do I have to create a separate Table or do I have to create a datatype. Can you please help me with this
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
    @dp_id char(32),
    @dv_id char(32),
    @em_number char(12),
    @email varchar(50),
    @emergency_relation char(32),
    @option1 char(16),
    @status char(20),
    @em_id char(35),
    @em_title varchar(64),
    @date_hired datetime
    AS
    BEGIN
    SET NOCOUNT ON;
    MERGE [dbo].[em] AS [Targ]
    USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
    AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
    ON [Targ].em_id = [Sourc].em_id
    WHEN MATCHED THEN
    UPDATE
    SET dp_id = [Sourc].dp_id,
    dv_id = [Sourc].dv_id,
    em_number = [Sourc].em_number,
    email = [Sourc].email,
    emergency_relation = [Sourc].emergency_relation,
    option1 = [Sourc].option1,
    status = [Sourc].status,
    em_title = [Sourc].em_title,
    date_hired = [Sourc].date_hired
    WHEN NOT MATCHED BY TARGET THEN
    INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
    VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
    END;

    It's not clear how you would change the procedure. But assuming that you want to replace the existing scalar parameters with tabular input, this is how you would do it. You first create a table type:
    CREATE TYPE  Insertor_type AS TABLE
        (dp_id                char(32),
         dv_id                char(32),
        em_number            char(12),
        email                varchar(50),
        emergency_relation   char(32),
        option1              char(16),
        status               char(20),
        em_id                char(35),
        em_title             varchar(64),
        date_hired           datetime)
    Then you change the procedure header:
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF] @tvp Insertor_type READONLY AS
    And finally you change the USING clause:
       USING (SELECT dp_id, dv_id , em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired
              FROM   @tvp) AS [Sourc] ON [Targ].em_id = [Sourc].em_id
    The rest is fine as it is.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to call stored procedure with multiple parameters in an HTML expression

    Hi, Guys:
    Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
    The orginal HTML expression is :
    <img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
    procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
    Thanks a lot.
    Sam

    Hi:
    Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
    <img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
    create or replace
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
        v_mime_type VARCHAR2(48);
        v_length NUMBER;
        v_name VARCHAR2(2000);
        v_image BLOB;
        v_counter number:=0;
        cursor cur_All_Images_of_Offender is
          SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
          FROM sor_image
          WHERE offender_id = p_n_Offender_id;
        rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
    BEGIN
        open cur_All_Images_of_Offender;
        loop
          fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
          v_counter:=v_counter+1;
          if (v_counter=p_n_image_Count) then
            owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
            htp.p('Content-length: '||rec_Image_of_Offender.image_length);
            owa_util.http_header_close;
            wpg_docload.download_file (rec_Image_of_Offender.image);
          end if;
          exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
        end loop;
        close cur_All_Images_of_Offender;
    END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
    Thanks
    Sam

  • Using stored procedures with a timestamp parameter with Delphi  and ADO

    Dear Oracle experts,
    I have a problem concerning using a stored procedure with Delphi.
    I try to use a stored procedure which hast two input parameters ( a integer and a timestamp).
    The timestamp parameter is my problem since I would like to use the "to_timestamp"
    Oracle-function to create the timestamp parameter to be inserted into my procedure.
    If I insert the to_timestamp statement as a adodatetime I have to perform the conversion to the oracle timestamp in my application.
    If I want to use the to_timestamp statement I have to use the ftstring datatype but in that case I get an error because I use a string as input for my procedure were it awaits a timestamp.
    So the problem seems to be that the function call "to_timestamp" is not interpreted if it is transferred through my ADO component.
    Do you know how to use a procedure with Delphi (ADO) with a function as input parameter ?
    Best regards,
    Daniel Wetzler
    P.S. :
    This is the Delphi code to use my Procedure.
    FactsTempDS:=TADODataset.Create(nil);
    Sproc1 := TAdoStoredProc.Create(nil);
    Sproc1.Connection := TDBConnection(strlistConnectionstrings.objects[iConnectionIndex]).Connection;
    Sproc1.ProcedureName := 'ECSPACKAGE.PROCFINDINITIALSWITCHSTATE';
    Sproc1.Parameters.CreateParameter ('SwitchID',ftInteger,pdinput,0,0);
    //Sproc1.Parameters.CreateParameter ('StartTime',ftdatetime,pdinput,50,0);
    Sproc1.Parameters.CreateParameter ('StartTime',ftString,pdinput,50,0);
    Sproc1.Parameters.Findparam('SwitchID').value:=SwitchID;
    Sproc1.Parameters.FindParam('StartTime').Value:= 'to_timestamp(''2005/12/30 19:36:21'', ''YYYY/MM/DD HH:MI:SS'')';
    Sproc1.CursorType := ctKeyset;
    Sproc1.ExecuteOptions:=[];
    Sproc1.Open;
    Sproc1.Connection := nil;
    FactsTempDS.Recordset:= sproc1.Recordset;
    if FactsTempDS.RecordCount=0
    then raise Exception.Create('No line switch variable found for switch '+IntToStr(SwitchID)+' before starttime. Check BDE dump filter.')

    I have my entity manager setup in a singleton.
    I'm finding it's costly to generate the emf, but if I don't close the em (enitity manager) and emf (entity manager factory) my open cursor count climbs until I exceed the max number of open cursors on the database (11g RAC)
    I'm committing the connection, and uow, and closing the em at the end of each call.
    But until I close the emf, the open cursors aren't released.
    TransactionhistoryPkg tranPkg = new TransactionhistoryPkg(conn); //Class created over database package via JPublisher
    tranPkg.transactionhistoryInsSp(insertTrans.getCardId()); // executes db package
    tranPkg.closeConnection();
    conn.commit();
    uow.commit();
    uow.getAccessor().decrementCallCount();
    em.close();
    Am I missing something really obvious here??
    btw - I found this link helpful in troubleshooting the max cursors issue: https://support.bea.com/application_content/product_portlets/support_patterns/wls/InvestigatingORA-1000MaximumOpenCursorsExceededPattern.html

  • How to use a stored procedure as a datasource in Crystal Report for Eclipse

    Hi All,
    I've written a stored procedure in oracle 10g with few input parameters and one refcursor output parameter. I want to use this stored procedure as a data source for creating a report in "Crystal Report For Eclipse 3.6.0".
    When I tried to add this stored procedure to the report using the connection explorer, I don't see any option to do this. But when I try to add any table, it shows options like "Add to the current report"....
    Can anybody assist me how to use a stored procedure as a data source in "Crystal Report For Eclipse"?
    Which driver should I use to connect to the oracle database? I tried using JDBC Driver for Oracle.
    Thanks in advance.

    Did you solve your problem? How did you do?

Maybe you are looking for