Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP - Database Accesses →  ADBC - ABAP Database Connectivity →  Examples of ADBC 

ADBC, Stored Procedure

The example demonstrates the execution of a stored procedure using ADBC.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA:  sql     TYPE REF TO cl_sql_statement,
           err     TYPE REF TO cx_sql_exception,
           dref    TYPE REF TO data.
    call_screen( ).
    CREATE OBJECT sql.
    TRY.
        sql->execute_ddl(
          `CREATE OR REPLACE PROCEDURE increase_price (x IN NUMBER) IS `
           && `BEGIN `
           && `UPDATE sflight SET price = price + x`
           && `               WHERE mandt = '` && sy-mandt && `'; `
           && `END;` ).
        GET REFERENCE OF incprice INTO dref.
        sql->set_param( data_ref = dref
                        inout    = cl_sql_statement=>c_param_in ).
        sql->execute_procedure( proc_name = 'increase_price' ).
      CATCH cx_sql_exception INTO err.
        MESSAGE err TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.

Description

Using the method EXECUTE_PROCEDURE of the CL_SQL_STATEMENT class, the procedure increase_price defined in the same program with the method EXECUTE_DDL is called. This increases all the flight prices in the table SFLIGHT in the current client by the value contained in the parameter incprice. The example can only be executed with an Oracle database.