Calling oracle procedure from ABAP program

There is a requirement to call the oracle stored procedure with some input parameter from ABAP program.
Suppose we have order number which is entered by the user in ABAP program.
This order number needs to be passed to oracle stored procedure as an input parameter in the same ABAP program.
We can call the oracle stored procedure without parameter using the following syntax
exec sql
execute procedure <procedure name>
end exec.
But do not know how to execute the oracle stored procedure with some input parameter?

Apologies , following is the correct code.
This will definetly solve your problem.
DATA scarr_carrid TYPE scarr-carrid.
SELECT-OPTIONS s_carrid FOR scarr_carrid NO INTERVALS.
DATA s_carrid_wa LIKE LINE OF s_carrid.
DATA name TYPE c LENGTH 20.
TRY.
    EXEC SQL.
      CREATE FUNCTION selfunc( input CHAR(3) )
        RETURNING char(20);
        DEFINE output char(20);
        SELECT carrname
               INTO output
               FROM scarr
               WHERE mandt  = '000' AND
                     carrid = input;
        RETURN output;
        END FUNCTION;
    ENDEXEC.
    LOOP AT s_carrid INTO s_carrid_wa
                     WHERE sign = 'I' AND option = 'EQ'.
      TRY.
         EXEC SQL.
            EXECUTE PROCEDURE selfunc( IN  :s_carrid_wa-low,
                                       OUT :name )
          ENDEXEC.
          WRITE: / s_carrid_wa-low, name.
        CATCH cx_sy_native_sql_error.
          MESSAGE `Error in procedure execution` TYPE 'I'.
      ENDTRY.
    ENDLOOP.
    EXEC SQL.
      DROP FUNCTION selfunc;
    ENDEXEC.
  CATCH cx_sy_native_sql_error.
    MESSAGE `Error in procedure handling` TYPE 'I'.
ENDTRY.
Reward points if usefull.
Thanks and regards,
Veerendranath.

Similar Messages

  • Call SXPG _ CALL _ SYSTEM from ABAP program

    Hi,
    Someone may help me?  I need to call the function module SXPG _ CALL _ SYSTEM from ABAP program for to encrypt a file.
    I created the command by SM49 , but I don't know how I can call it from ABAP program.
    Thanks
    Maria C

    Hi Maria.
    This is a possible code you can use:
    DATA: log LIKE TABLE OF btcxpm WITH HEADER LINE.
    Can contain STDOUT, STDERR
    commandname =
    CALL FUNCTION ‘SXPG_CALL_SYSTEM’
    IMPORTING
      COMMANDNAME = commandname
      PARAMETERS = parameters
    EXPORTING
    STATUS = status
      TABLES
      EXEC_PROTOCOL = log
    EXCEPTIONS
      NO_PERMISSION = 1
      COMMAND_NOT_FOUND = 2
      PARAMETERS_TOO_LONG = 3
      SECURITY_RISK = 4
      WRONG_CHECK_CALL_INTERFACE = 5
      PROGRAM_START_ERROR = 6
      PROGRAM_TERMINATION_ERROR = 7
      X_ERROR = 8
      PARAMETER_EXPECTED = 9
      TOO_MANY_PARAMETERS = 10
      ILLEGAL_COMMAND = 11
      OTHERS = 12.
    The following are the comments of the parameters taken from:
    http://help.sap.com/saphelp_40b/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/content.htm
    Parameters
    IMPORTING Parameters
    Parameter name
    Use
    COMMANDNAME
    The name of the definition of the external command, as specified in the maintenance function (transaction SM69).
    PARAMETERS
    Arguments for the external command as specified by the definition in the R/3 System and by the calling program or user.
    These arguments are checked for impermissible characters, such as the ; under UNIX. Problems are registered with the SECURITY_RISK exception.
    EXPORTING Parameters
    Parameter name
    Use
    STATUS
    Returns the final status of the execution of the external command:
    · Value ‘O’: The external command was started and ran to end successfully.
    · Value ‘E’: An error occurred; the external command was not run successfully.
    Tables Parameters
    Parameter name
    Use
    EXEC_PROTOCOL
    Contains the STDOUT and STDERR output of the external command and any output from the target host system.
    Exceptions
    Exception name
    Meaning
    X_ERROR
    Reserved for future use.
    NO_PERMISSION
    The AUTHORITY-CHECK of the user’s authorization for the authorization object S_LOG_COM failed. The user is not authorized to carry out the command named with the specified arguments on the target system.
    COMMAND_NOT_FOUND
    Command name, as identified by COMMANDNAME and OPERATINGSYSTEM, has not been defined in the maintenance function (transaction SM69).
    PARAMETERS_TOO_LONG
    The combined argument string (ADDITIONAL_PARAMETERS and the DEFINED_PARAMETERS, as returned in ALL_PARAMETERS) exceeds the limit of 128 characters in length.
    SECURITY_RISK
    Either:
    · The command contains impermissible characters. These are characters with potentially dangerous properties, such as ; under UNIX.
    · The command definition specifies that an extra-check function module be run. This function module has rejected execution of the command.
    WRONG_CHECK_CALL_
    INTERFACE
    The command definition specifies that an extra-check function module is to be run. Either this function module is missing, or the interface defined for this function module does not match that of the standard R/3 function module SXPG_DUMMY_COMMAND_CHECK. For more information, please see SXPG_DUMMY_COMMAND_CHECK: Interface for Extra-Check Function Modules.
    TOO_MANY_PARAMETERS
    The command definition specifies that user-specified arguments for the external command are not allowed. However, an additional string of command arguments was specified.
    PARAMETER_EXPECTED
    The command definition includes the placeholder character ?, which signifies that additional user-defined arguments are required. However, no additional arguments string was supplied.
    PROGRAM_START_ERROR
    An error occurred while starting the external command. The R/3 system field SY-MSGV1 contains additional information on the problem.
    PROGRAM_TERMINATION_
    ERROR
    An error occurred while trying to obtain the return code of the external program. The R/3 system field SY-MSGV1 contains additional information on the problem.
    ILLEGAL_COMMAND
    The external command definition was modified "illegally". That is, the command was not modified by means of the maintenance function (transaction SM69).
    The modified command is registered in the system log in its substituted form. The message is registered under the system log ID "LC".
    OTHERS
    Catch any new exceptions added to this function module.
    Hope this will be useful.
    Sandro Lombardo

  • Procedure to Call Workflow Object from ABAP program in Se38

    Hi All,
    I have one scenario like i have to call one Workflow object from ABAP program in SE38.The scenario is like below.....
    I have to select some records from database table.For example there are 100 records in the internal table.
    For all that records i have to invoke Workflow for getting approval from the authorized persons. Once Approval has come to program, It will post one document in SAP and process ends.
    Please suggest me how to move forward with this scenario.
    Regards
    Manas Ranjan Panda

    Hi,
    So you want to start a workflow from an ABAP, if an event exists for that particular workflow then the best way is to use fm SAP_WAPI_CREATE_EVENT,
    to start a workflow from an ABAP you can use fm SAP_WAPI_START_WORKFLOW.
    Kind regards, Rob Dielemans

  • Calling GUI Scripting from ABAP program

    Is it possible to call GUI Scripting from ABAP and thus to use GUI Scripting as an alternative to CALL TRANSACTION?
    Is the class CL_JAVA_SCRIPT suitable to access GUI Scripting engine? Accessing ABAP data object would work as well in this case as i think. What SAP Logon and WAS releases are required? Is the 6.20 release sufficient for this case?
    I would appreciate if somebody could post an example.

    Hi,
    CL_JAVA_SCRIPT has nothing to do with SAPGUI Scripting.
    Calling SAPGUI Scripting API from ABAP could be possible for programmes experienced with OLE automation calls from ABAP coding.
    The hardest thing will be, to access the scripting engine handle as an entry point. Once you have a handle in your abap session, any api function can be invoked.
    Best regards
    Jens
    BTW: SAP testtool eCATT does call SAPGUI-Scripting from ABAP.

  • Call oracle procedure from NT scheduler

    How can we call a procedure from NT schedular / Unix schedular ?
    Atul

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by ATUL SRIVASTAV ([email protected]):
    How can we call a procedure from NT schedular / Unix schedular ?
    Atul<HR></BLOCKQUOTE>
    Hi
    You can write SQL*Plus script and put sqlplus in NT scheduler or Unix cron table. The onle problem is that password must present in command line, so you should think how to keep it. Starting of sqlplus can be in .bat file or shell script unvisible for nonauthorized persons.
    Regards
    null

  • How to call stored procedures from java program?

    I have tried to run a program that calls a stored procedure on MySQL
    server version 5.0.17 by using connector/j 5.0, but it always fails on the
    statement: con.preparecall() ,
    have looked on the internet and found out that people can all mysql
    stored procedure all right in their programs, really dont know what's
    wrong with this small peiece of code:
    import java.sql.*;
    public class TestDB {
          // procedure being called is:
         CREATE PROCEDURE `dbsaystorm`.`getsite` ()
         BEGIN
            select  name  from tblsite;
         END
         public static void main(String[] args) {
              try  {
                  //Class.forName("org.gjt.mm.mysql.Driver");
                  Class.forName("com.mysql.jdbc.Driver");
                  Connection con = DriverManager.getConnection("jdbc:mysql://localhost/dbname",
                            "user", "pwd");
           * executing SQL statement here gives perfect correct results:
            // PreparedStatement ps = con.prepareStatement("select name from tblsite");      
            // ResultSet rs =ps.executeQuery();
                  // but in stored procedure way...
                  //it fails here on this prepare call statement:             
                  CallableStatement proc = con.prepareCall("call getsite()");
                  ResultSet rs =proc.executeQuery();                      
                  if (rs == null) return;                                      
                  while (rs.next()){                 
                      System.out.println("site name is: "+ rs.getString(1));                                
                  rs.close();
              } catch (SQLException e) {e.printStackTrace();}
               catch (Exception e) {e.printStackTrace();}         
    }it always gives this exception:
    java.lang.NullPointerException
         at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:959)
         at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1280)
         at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3668)
         at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:638)
         at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:453)
         at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4365)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:4439)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:4413)
         at saystorm.server.data.database.TestDB.main(TestDB.java:29)
    where have I gone wrong?
    when I commented out the statement that makes the procedure call and call preparedstatement to execute SQL select statement, it gave perfectly correct result.
    it looks like there is no problem with java prog accessing MYSQL server database, but the it seems that it's just java can't call stored procedure stored on the mysql server version 5.
    can it or can't it? if it can, how is that accomplished?

    It is a bug in the driver because it shouldn't be
    returning that exception (null pointer) even if you
    are doing something wrong.
    Are you using the latest version of the driver?
    The stored procedure runs when you run it from the
    gui/command line using a MySQL tool - correct?
    As suggested you should be using the brackets. What
    is the data type of the 'name' field?
    You could try returning another value like one of the
    following
    select 1, name from tblsite;
    select name, 1 from tblsite;
    That might get around the bug
    Additionally try just the following...
    select 'test' from tblsite;yes, the driver used is in connector/j 5.0--the lastest one, and the
    procedure can run correctedly at either command line or GUI mode
    with no problem whatsoever, the returned data type is string type,
    I have not got the chance to test it again with those values you
    suggested, as I have abandoned the laptop I used to write that code
    initately. There have been some other really weird cases happened on
    that computer. I guess that must be something wrong with the JVM
    installed on it, it was upgraded from jre5.0.04 to 06, and to 09.
    something within hte JVM must have been messed up(the only reasonable
    explanation). Because the same code runs correctly on my new laptop,
    using the same environment: jvm 5.0_09, mysql 5.0.18, connector/J 5.0.
    that old laptop really was a nightmare.

  • Call VB Script From ABAP Program

    Hi,
    I need to call a VBS program from an abap program.  This abap will run on both 4.6 and 4.0.
    I would be very grateful for any suggestions on how this can be done.
    Thanks and Kindest Regards
    Danielle

    data: commandline(1000).
    commandline = v_vbs_filename. "complete path of vbs file
      call function 'WS_EXECUTE'
           exporting
                commandline    = commandline
                program        = 'WSCRIPT.EXE'
           exceptions
                frontend_error = 1
                no_batch       = 2
                prog_not_found = 3
                illegal_option = 4
                others         = 5.
      if sy-subrc <> 0.
        raise execution_failed.
      endif.
    Raja

  • Oracle Query From ABAP Program

    Hello everybody,
    I have a doubt about if I can do a Query to a External Oracle Database to get some records and then process them in my ABAP Program, is this possible?, if this is the case can anyone help me with some documentation, thanks in advance for your answers.
    Regards,
    Julio

    Hi Julio,
    you can use the open SQL connect statement
    EXEC SQL.
      CONNECT TO dbs [AS con]
    ENDEXEC.
    or even you can define the DB in the FROM with the option CONNECTION
    ... FROM { {dbtab [AS tabalias]}
             | join
             | {(dbtab_syntax) [AS tabalias]} }
             [UP TO n ROWS]
             [CLIENT SPECIFIED]
             [BYPASSING BUFFER]
             [CONNECTION {con|(con_syntax)}] ... .
    Hope it helps,
    Edgar

  • Problem in calling oracle procedure from java

    Oracle procedure with the following parameters.
    CREATE OR REPLACE PROCEDURE CREDITED_TO_STORE_INSERT (P_CUST# IN NUMBER,
    P_INV_DATE IN DATE,
    P_MEMO# IN NUMBER,
    P_SESS_ID IN VARCHAR2 ) IS
    BEGIN
    /*.........Procedure Body with select and insert statements there no OUT or return variable/value......*/
    END;
    Now i am calling this procedure with the java code in java.
    public boolean execProcedure(String storeNo, String invoiceDate, String claimNo, String sessionID) throws SQLException {
         CallableStatement cstmt = null;
         java.sql.Date invicDate = this.StringToDate(invoiceDate);
         try
         cstmt = conn.prepareCall("{call WEBUSER.CREDITED_TO_STORE_INSERT(?,?,?,?,?,?)}");
         cstmt.setInt(1, Integer.parseInt(storeNo));
         cstmt.setDate(2, invicDate);
         cstmt.setInt(3, Integer.parseInt(claimNo));
         cstmt.setString(4, sessionID);
         cstmt.execute();
         catch (Exception e)
         System.out.println (e);
         } // catch (Exception e)
         finally
         try
         cstmt.close();
         catch (Exception ex)
         } // catch (Exception ex)
         } // finally
         return true;
    But it will return the following exception.
    [STDOUT] java.sql.SQLException: Missing IN or OUT parameter at index:: 5
    i don't know why :( please help me ...

    your procedure has 4 parameters but in the prepared statement you define 6 placeholders

  • Call to WS from abap program

    Hi,
    I Create WS in BE1 (Server ) and i want to call it explicitly via Code from other backend BE2 (Client) .
    I followed  this procedure
    1. Create WS on the Target system (in the Server).
    2. Generate proxy on the client (in the client).
    3. Create logical port Via Lpconfig (in client).
    I use this code to call to the service :
    DATA:  lv_port_name          TYPE srt_lp_name,
           lv_text               TYPE string,
           lt_return             TYPE bapirettab.
    DATA: lref_client_proxy TYPE REF TO z_ser_test_perf,
          in TYPE  z_ser_tst_per,
          out TYPE z_ser_tst_per_r.
    * Get Default Logical Port for Proxy
    CONSTANTS: lc_proxy TYPE srt_lp_proxyclass VALUE 'ZHCO_SER_T_PER'.
    in-user = 'AST'.
    in-work_id = '00570538637'.
    CALL METHOD cl_srt_lp_maintenance=>get_default_port_by_proxy
      EXPORTING
        proxyclass = lc_proxy
      RECEIVING
        lp_name    = lv_port_name.
    TRY.
        CREATE OBJECT lref_client_proxy
          EXPORTING
            logical_port_name = lv_port_name.
      CATCH cx_ai_system_fault.
    ENDTRY.
    TRY.
        CALL METHOD lref_client_proxy->z_tst_performance
          EXPORTING
            input  = in
          IMPORTING
            output = out.
    catch CX_AI_SYSTEM_FAULT into lr_error.
    lv_message = lr_error->get_text( ).
      CATCH cx_ai_application_fault.
    ENDTRY.
    In the method lref_client_proxy- i get exception :
    SOAP:14 Unexpected element -el=definitions ns=http://schemas.xmlsoap.org/wsdl/
    Does anyone have an idea how to avoid this  exception?
    P.S.
    I also create logical port via Soamanager but the first and the second method don't find it (i saw the entry in table SRT_CFG_CLI_ASGN ) and when i call to the third method alone i get dump for null reference.
    Best Regards
    Nina
    Edited by: Nina C on May 5, 2009 10:33 PM

    hi , nina
    the null poitnexception is that u r referring to the logicl port while creatign the object
    dotn pass anything , just use
    create object  proxy name
    Data : l_proxy type ref to ZSTRCO_ZSTARWEB,
            lo_sys_exception   TYPE REF TO cx_ai_system_fault,
           out type ZSTRZSTAR_RESPONSE,
           in type ZSTRZSTAR,
           it_controller type PRXCTRLTAB,
           wa_controller type prxctrl.
           create object l_proxy.
            in-a =    8.
            in-b = 4.
          TRY.
           CALL METHOD l_proxy->zstar
             EXPORTING
               input  = in
             IMPORTING
               output = out
    .        CATCH cx_ai_system_fault into lo_sys_exception .
           ENDTRY.
    write : out-c.
    i never used logical port , i created it but never used
    just instantiate the object and pass the input an dout put paramters , the logical port will be picked form run time
    and u can test the proxy from se80
    1) just double click on th eproxy name in SE80 , u can select the package in which u created the pproxy  , then under enterprise services --> client proxy and ur proxy name
    just test from there u get a pop up of  test service consumer and select the logical port from  drop down and seelct the generate template data  and execute it , u will get a screen where the input values will be autmatically proposed and then u execute from there u wil get the output.
    2) seond method is when in SE80 when u select the proxy u can see  the prxy name in the prpoerties which will be        Proxy Class (generated) , then test this class  by using execute button  u get a screen where u haev to instantiate the class , give the logical port name and click the instance button, then ur method wil be shown execute it and u get ur input paramters just clikc them, give the values and come back and execute u will get the output
    hope it solves ur prob
    regards
    afzal

  • Calling oracle procedure from batch script

    i have a .bat file, in which i am using sqlldr to load into a staging table from csv file, and then using merge to insert / update into target table
    i have 2 doubts
    1) my first doubt is regarding batch script..how to handle the errorlevels which are greater than 1?
    so generally speaking, how do i handle all the errors at once..and make sure the control goes to
    run_sqlldr0 always? and handle the error meaningfully if its other than 0 ?
    below is my batch script, and i get error
    goto run_sqlldr2
    the system cannot find the batch label specified - run_sqlldr2
    @echo on
    call oraenv.bat
    if not exist %mainpath% goto mainpath_def
    if not exist %scripts% goto scriptspath_def
    if not exist %logs% goto logspath_def
    if not exist %data% goto datapath_def
    goto x1
    :x1
    goto run_sqlldr%ERRORLEVEL%
    echo run_sqlldr%ERRORLEVEL%
    if run_sqlldr%ERRORLEVEL% NEQ 0 goto run_sqlldr1
    echo "entering sqlldr"
    :run_sqlldr1
    echo "entered sqlldr1"
    echo "some error"
    echo mergedata%ERRORLEVEL%
    :run_sqlldr0
    echo "entered sqlldr0"
    sqlldr userid = scott/tiger@orcl control=%mainpath%\cm.ctl log=%logs%\cm.log discard=%logs%\cm.dsc bad=%logs%\cm.bad SILENT=(HEADER, FEEDBACK)
    goto mergedata%ERRORLEVEL%
    :mergedata1
    echo "entered mergedata1"
    echo cleandata%ERRORLEVEL%
    :mergedata0
    sqlplus -s scott/tiger@orcl @%scripts%\merge_stg.sql
    goto cleandata%ERRORLEVEL%
    :cleandata1
    echo "entered cleandata1"
    sqlplus -s scott/tiger@orcl @%scripts%\clean_stg.sql
    goto exit
    :cleandata0
    echo "entered cleandata0"
    echo "error in removing data"
    goto exit
    :mainpath_def
    echo "mainpath not existing as specified %mainpath%, Please edit ORAENV with correct value"
    goto exit
    :scriptspath_def
    echo "scripts path not existing as specified %scripts%, Please edit ORAENV with correct value"
    goto exit
    :logspath_def
    echo "Logs path not existing as specified %logs%, Please edit ORAENV with correct value"
    goto exit
    :datapath_def
    echo "Data path not existing as specified %data%, Please edit ORAENV with correct value"
    goto exit
    :exit
    2) my second doubt, is this the right way of calling the stored procedures merge_stg and clean_stg?
    in clean_stg, i use dynamic sql to truncate the staging table
    create or replace procedure trunstg is
    lsql varchar2(2000) := 'truncate table stg_ldrtest';
    begin
    execute immediate lsql;
    end;
    /

    i have changed the code
    @echo on
    call oraenv.bat
    if not exist %mainpath% goto mainpath_def
    if not exist %scripts% goto scriptspath_def
    if not exist %logs% goto logspath_def
    if not exist %data% goto datapath_def
    goto x1
    :x1
    goto run_sqlldr%ERRORLEVEL%
    echo run_sqlldr errorlevel: %ERRORLEVEL%
    if run_sqlldr%ERRORLEVEL% NEQ 0 goto run_sqlldr1
    echo "entering sqlldr"
    :run_sqlldr1
    echo "entered sqlldr1"
    echo "some error"
    :run_sqlldr2
    echo errorlevel: %errorlevel%
    echo mergedata%ERRORLEVEL%
    :run_sqlldr0
    echo "entered sqlldr0"
    sqlldr userid = gautam/gautam@orcl control=%mainpath%\cm.ctl log=%logs%\cm.log discard=%logs%\cm.dsc bad=%logs%\cm.bad SILENT=(HEADER, FEEDBACK)
    goto mergedata%ERRORLEVEL%
    :mergedata1
    echo "entered mergedata1"
    goto end
    echo cleandata%ERRORLEVEL%
    :mergedata0
    sqlplus -s gautam/gautam@orcl @%scripts%\merge_stg.sql
    goto cleandata%ERRORLEVEL%
    :cleandata1
    echo "entered cleandata1"
    echo "cleaning error"
    goto end
    :cleandata0
    sqlplus -s gautam/gautam@orcl @%scripts%\clean_stg.sql
    goto end
    :mainpath_def
    echo "mainpath not existing as specified %mainpath%, Please edit ORAENV with correct value"
    goto exit
    :scriptspath_def
    echo "scripts path not existing as specified %scripts%, Please edit ORAENV with correct value"
    goto exit
    :logspath_def
    echo "Logs path not existing as specified %logs%, Please edit ORAENV with correct value"
    goto exit
    :datapath_def
    echo "Data path not existing as specified %data%, Please edit ORAENV with correct value"
    goto exit
    :end
    EXIT
    so the error is ORA - 30926, unable to get a stable set of
    rows in the source tables
    my merge is
    MERGE INTO ldrtest D
    USING (SELECT code,id,row_name,col1,col2,col3,crt_tm,md_tm,crt_user,mod_usr FROM stg_ldrtest) S
    ON (d.code = s.code and d.id = s.id and d.row_name=s.row_name )
    WHEN MATCHED THEN UPDATE SET d.col1 = s.col1,
    d.col2 = s.col2,
    d.col3 = s.col3,
    d.crt_tm = s.crt_tm,
    d.md_tm = s.md_tm,
    d.crt_user = s.crt_user,
    d.mod_usr = s.mod_usr
    WHEN NOT MATCHED THEN INSERT (d.code,d.id,d.row_name,d.col1,d.col2,d.col3,d.crt_tm,d.md_tm,d.crt_user,d.mod_usr)
    VALUES (s.code,s.id,S.row_name, s.col1,s.col2,s.col3,s.crt_tm,s.md_tm,s.crt_user,s.mod_usr);
    i did not understand what this error means..
    could anyone please help me out

  • How to call oracle procedure from vb

    i created a procedure in oracle8.1.7 to return on value,look the following script:
    Procedure P_COUNT (r out number)
    IS
    BEGIN
    select count(*) into r from demo;
    END;
    but i can get the value from VB,i display some errors:
    ORA-06502 PL/SQL: numeric or value errorstring
    ORA-06512 at stringline string
    what can i do now?
    null

    Hei Zhang,
    Thank You. You can return Cursor in many ways. You can write either a function to return cursor (return type is %ROWTYPE) or a package. Writing a Package seems laborious but I like it as it has lot of flexibility.
    I will give you the example for the second type:
    -- 1) Create a Package first:
    CREATE OR REPLACE PACKAGE pk_MyPackage AS Type RT1 IS RECORD (
    sp_ename emp.ename%TYPE,
    sp_job emp.job%TYPE,
    sp_mgr emp.mgr%TYPE
    TYPE RCT1 IS REF CURSOR RETURN RT1;
    END;
    sho err
    -- 2) Create a Procedure:
    CREATE OR REPLACE PROCEDURE sp_MyProcedure (
    in_empno emp.empno%TYPE,
    RC1 IN OUT pk_MyPackage.RCT1
    ) AS
    BEGIN
    OPEN RC1 FOR
    SELECT ename,
    job,
    mgr
    FROM emp
    WHERE empno = in_empno;
    RETURN;
    END;
    sho err
    --Testing
    SQL> var cr refcursor
    SQL> exec sp_MyProcedure (7934, :cr)
    PL/SQL procedure successfully completed.
    SQL> print cr
    ENAME JOB MGR
    MILLER CLERK 7782
    Hope this is clear and helps you to complete your task.
    Cheers!
    r@m@

  • Calling Stored Procedure from Oracle DataBase using Sender JDBC (JDBC-JMS)

    Hi All,
    We have requirement to move the data from Database to Queue (Interface Flow: JDBC -> JMS).
    Database is Oracle.
    *Based on Event, data will be triggered into two tables: XX & YY. This event occurs twice daily.
    Take one field: 'aa' in XX and compare it with the field: 'pp' in YY.
    If both are equal, then
         if the field: 'qq' in YY table equals to "Add" then take the data from the view table: 'Add_View'.
         else  if the field: 'qq' in YY table equals to "Modify"  then take the data from the view table: 'Modify_View'.
    Finally, We need to archive the selected data from the respective view table.*
    From each table, data will come differently, means with different field names.
    I thought of call Stored Procedure from Sender JDBC Adapter for the above requirement.
    But I heard that, we cannot call stored procedure in Oracle through Sender JDBC as it returns Cursor instead of ResultSet.
    Is there any way other than Stored Procedure?
    How to handle Data Types as data is coming from two different tables?
    Can we create one data type for two tables?
    Is BPM required for this to collect data from two different tables?
    Can somebody guide me on how to handle this?
    Waiting eagerly for help which will be rewarded.
    Thanks and Regards,
    Jyothirmayi.

    Hi Gopal,
    Thank you for your reply.
    >Is there any way other than Stored Procedure?
    Can you try configuring sender adapter to poll the data in intervals. You can configure Automatic TIme planning (ATP) in the sender jdbc channel.
    I need to select the data from different tables based on some conditions. Let me simplify that.
    Suppose Table1 contains 'n' no of rows. For each row, I need to test two conditions where only one condition will be satisfied. If 1st condition is satisfied, then data needs to be taken from Table2 else data needs to be taken from Table3.
    How can we meet this by configuring sender adapter with ATP?
    ================================================================================================
    >How to handle Data Types as data is coming from two different tables?
    If you use join query in the select statement field of the channel then whatever you need select fields will be returned. This might be fields of two tables. your datatype fields are combination of two diff table.
    we need to take data only from one table at a time. It is not join of two tables.
    ================================================================================================
    Thanks,
    Jyothirmayi.

  • Is it possible to call website from ABAP Program?

    Hi Experts,
           Is it possible to call website from ABAP Program?
    It is very Urgent Help me.
    Regards,
    Ashok.

    Hi,
    Check the following program:
    REPORT ZURL NO STANDARD PAGE HEADING.
    DATA: BEGIN OF URL_TABLE OCCURS 10,
    L(25),
    END OF URL_TABLE.
    URL_TABLE-L = 'http://www.lycos.com'.APPEND URL_TABLE.
    URL_TABLE-L = 'http://www.hotbot.com'.APPEND URL_TABLE.
    URL_TABLE-L = 'http://www.sap.com'.APPEND URL_TABLE.
    LOOP AT URL_TABLE.
      SKIP. FORMAT INTENSIFIED OFF.
      WRITE: / 'Single click on '.
      FORMAT HOTSPOT ON.FORMAT INTENSIFIED ON.
      WRITE: URL_TABLE. HIDE URL_TABLE.
      FORMAT HOTSPOT OFF.FORMAT INTENSIFIED OFF.
      WRITE: 'to go to', URL_TABLE.
    ENDLOOP.
    CLEAR URL_TABLE.
    AT LINE-SELECTION.
    IF NOT URL_TABLE IS INITIAL.
      CALL FUNCTION 'WS_EXECUTE'
           EXPORTING
                program = 'C:\Program Files\Internet Explorer\IEXPLORE.EXE'
                commandline     = URL_TABLE
                INFORM         = ''
              EXCEPTIONS
                PROG_NOT_FOUND = 1.
      IF SY-SUBRC <> 0.
         WRITE:/ 'Cannot find program to open Internet'.
      ENDIF.
    ENDIF.
    Regards,
    Bhaskar

  • Call workflow from ABAP program

    created a zbusiness object (ZPRODH)with
    one key field product hierarchy,
    one attribute level number and
    one method display.
    I tested that zobject and using this object created workflow to display product hierarchy ,it is displaying it. now I have to call it from one abap program.
    In the abap program I am calling the funcion module, I
    CALL FUNCTION 'SWW_WI_START_SIMPLE'
    EXPORTING
    TASK = TASK
    IMPORTING
    WI_ID = WI_ID
    TABLES
    AGENTS = AGENTS
    WI_CONTAINER = WI_CONTAINER.
    It is calling the workflow and subrc is 0, but not passing the value to the workflow. Because of that the method is not working, any idea?
    Thanks in advance

    ttpa,
    Please check this thread:
    Re: Workflow from abap program
    Also check that your Fm do requires any explicit commit or not?
    Hope it will help u
    Cheers
    Jai

Maybe you are looking for