EXEC SQL PERFORMING

when run the following program ,it reported error as
"the error occurred in the current  database connection "DEFAULT".
how to solve the problem ?
=================================
DATA : BEGIN OF WA,
  CLIENT(3),
  ARG1(3),
  ARG2(3),
  END OF WA.
DATA F3  VALUE '1'.
EXEC SQL PERFORMING LOOP_OUTPUT.
  SELECT CLIENT , ARG1 INTO  :WA FROM TABLE_001 WHERE ARG2 = :F3.
ENDEXEC.
FORM LOOP_OUTPUT.
  WRITE : / WA-CLIENT,WA-ARG2.
ENDFORM.
==================================

hi
   try
    SELECT * FROM TABLE_001 INTO CORRESPONDING FIELDS OF WA WHERE ARG2 = F3.
KUMAR

Similar Messages

  • SQL error 3113 occurred when executing EXEC SQL.

    Hi,
    We are facing one typical problem, One background is failing regularly with
    below dump. as we now got all notes giving information, if database  restarted
    taking backup, these type of failures occur, but our database is only down for backup once in a week, but it is failing with frequenly.
    in this two servers are located in different place, in this job tries to connect
    another server to get material statistics.
    It is giving some error message in sm21 with
    SQL error 3113 occurred when executing EXEC SQL.
    work procees in reconnect mode.
    all notes saying these types of dump occur when database restared, but this dump
    even though database is up.
    below is short dump, please can anyone help me from this problem.
    ABAP runtime errors    DBIF_DSQL2_SQL_ERROR
          Occurred on    08.01.2007 at 00:30:28
    >> Short dump has not been completely stored. It is too big.
    SQL error 3113 occurred when executing EXEC SQL.
    What happened?
    The error occurred in the current database connection "AZ1".
    What can you do?
    Note the actions and input that caused the error.
    Inform your SAP system administrator.
    You can print out this message by choosing "Print". Transaction ST22
    allows you to display and manage termination messages, including keeping
    them beyond their normal deletion date.
    Error analysis
    How to correct the error
    Database error text........: "ORA-03113: end-of-file on communication channel#"
    Triggering SQL statement...: "select mara.groes, mara.brgew, mara.ntgew,
    mara.gewei, mara.volum, mara.voleh, mara.mstae, mara.mstde, mara.prdha,
    marc.matnr, marc.werks, marc.mmsta, marc.mmstd from sapr3.mara, sapr3.m
    where sapr3.mara.mandt = sapr3.marc.mandt and sapr3.mara.matnr =
    Internal call code.........: "[DBDS/NEW DSQL]"
    Please check the entries in the system log (Transaction SM21).
    If the error occurred in a non-modified SAP program, you may be
    able to find a solution in the SAP note system.
    If you have access to the note system yourself, use the following
    search criteria:
    "DBIF_DSQL2_SQL_ERROR"
    "ZM2431216 " or "ZM2431216 "
    "EXTRACT_GENERAL_DATA"
    If you cannot solve the problem yourself, please send the
    following documents to SAP:
    1. A hard copy print describing the problem.
      To obtain this, select the "Print" function on the current screen.
    2. A suitable hardcopy prinout of the system log.
      To obtain this, call the system log with Transaction SM21
      and select the "Print" function to print out the relevant
      part.
    3. If the programs are your own programs or modified SAP programs,
      supply the source code.
      To do this, you can either use the "PRINT" command in th
      print the programs using the report RSINCL00.
    4. Details regarding the conditions under which the error o
      or which actions and input led to the error.
    System environment
    SAP Release.............. "46C"
    Application server....... "essceu3"
    Network address.......... "172.19.119.198"
    Operating system......... "AIX"
    Release.................. "5.3"
    Hardware type............ "00C7ADBD4C00"
    Database server.......... "ukblx176"
    Database type............ "ORACLE"
    Database name............ "EU3"
    Database owner........... "SAPR3"
    Character set............ "es_ES.ISO8859-1"
    SAP kernel............... "46D"
    Created on............... "Jul 9 2006 20:26:33"
    Created in............... "AIX 1 5 00447C4A4C00"
    Database version......... "OCI_920__OCI_7_API "
    Patch level.............. "2257"
    Patch text............... " "
    Supported environment....
    Database................. "ORACLE 8.0.5.., ORACLE 8.0.6.., ORACLE
    8.1.6.., ORACLE 8.1.7.., ORACLE 9.2.0.., ORACLE 10.2.0.."
    SAP database version..... "46D"
    Operating system......... "AIX 1 4, AIX 2 4, AIX 3 4, AIX 1 5, AIX 2 5, AIX 3
    5, , System build information:,                                      , LCHN :
    841480"
    User, transaction...
    Client.............. 600
    User................ "MPZMMES"
    Language key........ "S"
    Transaction......... " "
    Program............. "ZM2431216 "
    Screen.............. "SAPMSSY0 1000"
    Screen line......... 6
    Information on where termination occurred
    The termination occurred in the ABAP/4 program "ZM2431216 " in
    "EXTRACT_GENERAL_DATA".
    The main program was "ZM2431216 ".
    The termination occurred in line 980
    of the source code of program "ZM2431216 " (when callin
    The program "ZM2431216 " was started as a background jo
    Source code extract
    009500              mara.ntgew,
    009510              mara.gewei,
    009520              mara.volum,
    009530              mara.voleh,
    009540              mara.mstae,
    009550              mara.mstde,
    009560              mara.prdha,
    009570              marc.matnr,
    009580              marc.werks,
    009590              marc.mmsta,
    009600              marc.mmstd
    009610        into :w_ops-groes,
    009620              :w_ops-brgew,
    009630              :w_ops-ntgew,
    009640              :w_ops-gewei,
    009650              :w_ops-volum,
    009660              :w_ops-voleh,
    009670              :w_ops-mstae,
    009680              :w_ops-mstde,
    009690              :w_ops-prdha,
    009700              :w_ops-matnr,
    009710              :w_ops-werks,
    009720              :w_ops-mmsta,
    009730              :w_ops-mmstd
    009740        from sapr3.mara, sapr3.marc
    009750        where sapr3.mara.mandt = sapr3.marc.mandt
    009760          and sapr3.mara.matnr = sapr3.marc.matnr
    009770          and sapr3.mara.mandt = :p_mandt
    009780          and sapr3.mara.matnr = :w_ebs-matnr
    009790          and sapr3.marc.werks = :p_owerks
        >    ENDEXEC.
    009810  endform.                    " extract_general_data
    009820  *&
    009830  *&      Form  append_i_ops
    009840  *&
    009850  *      Appends W_OPS to I_OPS
    009860  *
    009870  form append_i_ops.
    009880    append w_ops to i_ops.
    009890  endform.                    " append_i_ops
    009900  *&
    009910  *&      Form  extract_material_description
    009920  *&
    009930  *      Extracts a Material Description from the remote database an
    009940  *      modifies the current record in I_OPS.
    009950  *
    009960  *        >P_SPRAS  Language Key
    009970  *
    009980  form extract_material_description using    p_spras.
    009990    EXEC sql performing set_langauge.
    Contents of system fields
    SY field contents..................... SY field contents............
    SY-SUBRC 0                            SY-INDEX 0
    SY-TABIX 1                            SY-DBCNT 1
    SY-FDPOS 18                            SY-LSIND 0
    SY-PAGNO 0                            SY-LINNO 1
    SY-COLNO 1
    Chosen variables
    Name.......................... Contents.1........2........3....+..
    W_EBS-PRAT4
                                  2
                                  0
    W_OPS-GROES
                                  22222222222222222222222222222222
                                  00000000000000000000000000000000
    W_OPS-BRGEW                    #######
                                  0000000
                                  000000C
    W_OPS-NTGEW                    #######
                                  0000000
                                  000000C
    regards,
    krishnaiah.

    Hi,
    This is usually a SERVER SIDE DATABASE PROBLEM or SQLNET LISTENER (server side) PROBLEM.  The client side should initially be ignored and instead the server should be investigated. In rare cases, this can be caused by client
    side memory or other resource problem, or a DLL version mismatch, but this is
    unlikely.
    Enlist the assistance of your DBA.  Then reproduce the ORA-3113 error on your
    client application.  Ask your DBA to look at the database side Alert.log and
    trace files and look for ANY activity.  Any activity that coincides with your
    ORA-3113 will be a clue.
    REgards
    Vinod

  • TRY ... CATCH doesn't work with EXEC SQL?

    When I created a native SQL statement, I knew before, that it would take a few tries to get it working. I decided to use exception classes to avoid short dumps, but it didn't work.
    Following code causes a short dump because of the dot after :xp_stras in the native SQL SELECT statement:
       try.
           EXEC SQL                     PERFORMING  list.
             SELECT LIFNR, NAME1, STRAS
                                    INTO  :xsl
                                    FROM  LFA1
             WHERE  UPPER( NAME1 )  LIKE  :xp_name1
             AND    UPPER( STRAS )  LIKE  :xp_stras.
           ENDEXEC.
                                                                                    catch CX_SY_NATIVE_SQL_ERROR.
           write: /1 'CX_SY_NATIVE_SQL_ERROR'.
       catch CX_SY_SQL_ERROR.
           write: /1 'CX_SY_SQL_ERROR'.
       catch CX_DYNAMIC_CHECK.
           write: /1 'CX_DYNAMIC_CHECK'.
       catch CX_ROOT.
           write: /1 'CX_SY_ROOT'.
       endtry.
    In ST22 you can see
    Name of runtime error: DBIF_DSQL2_SQL_ERROR
    Exception:
    The name of the exception is empty, in other short dumps you can find there the name of the exception class. Maybe that's the reason for CATCH does'nt work, but I don't understand it.
    Online help for EXEC SQL says:
    Catchable Exceptions
    CXSY_NATIVE_SQL_ERROR_
    Cause: SQL-Error at the execution of a Native SQL-command.
    Runtime Error: DBIF_DSQL2_SQL_ERROR
    We have SAP ECC 6.0 with SAP_BASIS rel. 700 lvl. 0013.
    If You have an idea why CATCH doesn't work, please tell me!
    Regards,
    Klaus

    Hi Rob,
    I tried out Your original code as program ZTEST5 and got a short dump (sorry, some of the short dump symbols are formatting this post in a wrong way ...):
    Short text
        An SQL error occurred when executing Native SQL.
    What happened?
        The error 919 occurred in the current database connection "DEFAULT".
    What can you do?
        Note down which actions and inputs caused the error.
        To process the problem further, contact you SAP system
        administrator.
        Using Transaction ST22 for ABAP Dump Analysis, you can look
        at and manage termination messages, and you can also
        keep them for a long time.
    How to correct the error
        Database error text........: "ORA-00919: invalid function"
        Database error code........: 919
        Triggering SQL statement...: "FETCH NEXT "
        Internal call code.........: "[DBDS/NEW DSQL]"
        Please check the entries in the system log (Transaction SM21).
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "DBIF_DSQL2_SQL_ERROR" " "
        "ZTEST5" or "ZTEST5"
        "START-OF-SELECTION"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction
           Restrict the time interval to 10 minutes befor
        after the short dump. Then choose "System->List->
        (Unconverted)".
        3. If the problem occurs in a problem of your own
        program: The source code of the program
           In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".
        4. Details about the conditions under which the e
        actions and input led to the error.
    System environment
        SAP-Release 700
        Application server... "lux01617"
        Network address...... "195.217.80.104"
        Operating system..... "Linux"
        Release.............. "2.6.5-7.283-smp"
        Hardware type........ "x86_64"
        Character length.... 16 Bits
        Pointer length....... 64 Bits
        Work process number.. 5
        Shortdump setting.... "full"
        Database server... "lux09208"
        Database type..... "ORACLE"
        Database name..... "D10"
        Database user ID.. "SAPDAT"
        Char.set.... "C"
        SAP kernel....... 700
        created (date)... "Dec 2 2007 20:18:08"
        create on........ "Linux GNU SLES-9 x86_64 cc3.3.3"
        Database version. "OCI_102 (10.2.0.2.0) "
        Patch level. 138
        Patch text.. " "
        Database............. "ORACLE 9.2.0.., ORACLE 10.1.0.., ORACLE 1
        SAP database version. 700
        Operating system..... "Linux 2.6"
        Memory consumption
        Roll.... 16192
        EM...... 16759392
        Heap.... 0
        Page.... 98304
        MM Used. 694160
        MM Free. 3493088
    User and Transaction
        Client.............. 500
        User................ "Z0000D2P"
        Language key........ "E"
        Transaction......... "SE38 "
        Transactions ID..... "48FE92EB921F51C3E1000000C3D95068"
        Program............. "ZTEST5"
        Screen.............. "SAPMSSY0 1000"
        Screen line......... 6
    Information on where terminated
        Termination occurred in the ABAP program "ZTEST5" - in "START-OF-SELECTION".
        The main program was "ZTEST5 ".
        In the source code you have the termination point in line 16
        of the (Include) program "ZTEST5".
    Source Code Extract
    Line  SourceCde
        1 REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.
        2
        3 TABLES: lfa1.
        4
        5 DATA: BEGIN OF xsl,
        6         lifnr TYPE lfa1-lifnr,
        7         name1 TYPE lfa1-name1,
        8         stras TYPE lfa1-stras,
        9       END   OF xsl.
       10
       11 DATA: xp_name1 TYPE lfa1-name1,
       12       xp_stras TYPE lfa1-stras.
       13
       14 TRY.
       15     EXEC SQL PERFORMING list.
    >>>>>       SELECT LIFNR, NAME1, STRAS
       17       INTO :xsl
       18       FROM LFA1
       19       WHERE UPPER( NAME1 ) LIKE :xp_name1
       20       AND UPPER( STRAS ) LIKE :xp_stras.
       21     ENDEXEC.
       22
       23   CATCH cx_sy_native_sql_error.
       24     WRITE: /1 'CX_SY_NATIVE_SQL_ERROR'.
       25   CATCH cx_sy_sql_error.
       26     WRITE: /1 'CX_SY_SQL_ERROR'.
       27   CATCH cx_dynamic_check.
       28     WRITE: /1 'CX_DYNAMIC_CHECK'.
       29   CATCH cx_root.
       30     WRITE: /1 'CX_SY_ROOT'.
       31 ENDTRY.
       32
       33 &----
       34 *&      Form  LIST
       35 &----
    Edited by: Klaus Babl on Oct 22, 2008 6:42 AM

  • EXEC SQL

    Hi,
    What does an EXEC SQL stmt do in ABAP?
    What is the disadvantage of using it?
    Regards,
    Kalai

    Hi
    <b>EXEC SQL</b>
    EXEC SQL [PERFORMING subr].
    ENDEXEC.
    These statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check. The statements entered there are passed to the Native SQL interface and processed there as follows:
    Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC, in particular the DDL statements. These SQL statements are passed from the Native SQL interface to the database system largely unchanged. The syntax rules are specified by the database system, in particular the case sensitivity rules for database objects. If the syntax allows a separator character between individual statements, you can include several Native SQL statements between EXEC and ENDEXEC. Generally, the semicolon ( is used as the separator character.
    You can also include SAP-specific Native SQL language elements between EXEC and ENDEXEC. These statements are not passed directly from the Native SQL interface to the database, but are converted appropriately. These SAP-specific language elements are::
    <b>Host variables</b>
    Statements for cursor processing
    Database procedure calls
    Statements for establishing database connections
    All Native SQL statements bypass SAP buffering. Automatic client handling is not performed.
    <b>System fields</b>
    The statement ENDEXEC sets the system fields sy-subrc and sy-dbcnt.
    sy-subrc Meaning
    0 The statements between EXEC and ENDEXEC were executed successfully.
    4 The statements between EXEC and ENDEXEC were not executed.
    The ENDEXEC statement sets sy-dbcnt to the number of table rows processed in the last Native SQL statement.
    Programs with Native SQL statements are generally dependent on the database system used, so that they cannot be executed in all SAP Systems. This is especially true for the examples in this section, which was written for Informix database systems.
    <b>Example</b> Inserting two rows in the database table SCARR. If neither of these rows exists, sy-subrc is set to 0 by ENDEXEC and sy-dbcnt to 1. Otherwise, an exception is raised and handled.
    DATA: exc_ref TYPE REF TO cx_sy_native_sql_error,
          error_text TYPE string.
    TRY.
        EXEC SQL.
          INSERT INTO scarr
                      (MANDT, CARRID, CARRNAME, CURRCODE, URL)
            VALUES ('000', 'FF', 'Funny Flyers', 'EUR',
                    'http://www.ff.com');
          INSERT INTO scarr
                     (MANDT, CARRID, CARRNAME, CURRCODE, URL)
            VALUES ('000', 'EF', 'Easy Flyers', 'EUR',
                    'http://www.ef.com');
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO exc_ref.
        error_text = exc_ref->get_text( ).
        MESSAGE error_text TYPE 'I'.
    ENDTRY.
    <b>Reward if usefull</b>

  • EXEC SQL STATEMENT

    Is there something wrong with this EXEC SQL Statement...
            EXEC SQL PERFORMING sr_STORE_data.
              select *
                     into :<FS_wt> @:c_db
                     from (lwt_source-PS_STRUCT)
                     where sb_effdt = :p_date
            ENDEXEC.

    hi,
    Check whether the table name can be passed dynamically by specifying it in parantheses.
    check this sample code, it might help you,
    **** A field-symbol to access that work area
      assign NEW_LINE->*  to <wa_it>.
    *PERFORMING loop using <wa_it> changing itab_test
      EXEC SQL.
       open c for
       SELECT
       HOB_KH_IK as Ik, count(*) as ANZAHL,
       AVG(ENTL_DATUM - HOB_AUFN_DAT) AS VWD,
       SUM(KOSTEN_GESAMT/100)  as KOSTEN
      FROM BUSI.BW02_K_FALL
      GROUP BY HOB_KH_IK
      ENDEXEC.
    DO.
          EXEC SQL.
            fetch next c into :<wa_it>
          ENDEXEC.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          append <wa_it> to itab_test.
        ENDDO.
        EXEC SQL.
          close c
        ENDEXEC.
        write: / 'OK ?'.
    Regards,
    Sailaja.
    Message was edited by:
            Sailaja Nalam

  • Getting core dump when using EXEC SQL CLOSE

    In my pro*c program , i have used a cursor to fetch the set of accounts.Once cursor is opened , code will perform set
    of operation using fetched data and then cursor is closed. Between open and closing of cursor , i have used 23 EXEC
    SQL CLOSE. For example i am copying the value of a to b using strlcpy between fetch and close cursor statement.If
    returned value from strlcpy is greater than size of destination variable, then flow should not proceed , in that case I will
    close the cursor using EXEC SQL CLOSE and return the flow to calling program. Similarly i have closed the cursor at
    another 22 locations.
    When i compile the code and run binary the core dump occurs. On analyzing the core it shows
    t@null (l@8) terminated by signal SEGV (no mapping at the fault address)
    0xffffffffffffffff: <bad address 0xffffffffffffffff>
    dbx: core file read error: address 0xfc4ffe48 not in data space
    Current function is dbMtBaseClass::Pswd_Change
    7860 sqlcxt(&_dbMtCtx, &sqlctx, &sqlstm, &sqlfpn);
    if I remove any of the three EXEC SQL CLOSE commands , core dump does not occurs.
    It looks strange.Please help me to resolve the issue.

    In my pro*c program , i have used a cursor to fetch the set of accounts.Once cursor is opened , code will perform set
    of operation using fetched data and then cursor is closed. Between open and closing of cursor , i have used 23 EXEC
    SQL CLOSE. For example i am copying the value of a to b using strlcpy between fetch and close cursor statement.If
    returned value from strlcpy is greater than size of destination variable, then flow should not proceed , in that case I will
    close the cursor using EXEC SQL CLOSE and return the flow to calling program. Similarly i have closed the cursor at
    another 22 locations.
    When i compile the code and run binary the core dump occurs. On analyzing the core it shows
    t@null (l@8) terminated by signal SEGV (no mapping at the fault address)
    0xffffffffffffffff: <bad address 0xffffffffffffffff>
    dbx: core file read error: address 0xfc4ffe48 not in data space
    Current function is dbMtBaseClass::Pswd_Change
    7860 sqlcxt(&_dbMtCtx, &sqlctx, &sqlstm, &sqlfpn);
    if I remove any of the three EXEC SQL CLOSE commands , core dump does not occurs.
    It looks strange.Please help me to resolve the issue.

  • SQL Performance issue: Using user defined function with group by

    Hi Everyone,
    im new here and I really could need some help on a weird performance issue. I hope this is the right topic for SQL performance issues.
    Well ok, i create a function for converting a date from timezone GMT to a specified timzeone.
    CREATE OR REPLACE FUNCTION I3S_REP_1.fnc_user_rep_date_to_local (date_in IN date, tz_name_in IN VARCHAR2) RETURN date
    IS
    tz_name VARCHAR2(100);
    date_out date;
    BEGIN
    SELECT
    to_date(to_char(cast(from_tz(cast( date_in AS TIMESTAMP),'GMT')AT
    TIME ZONE (tz_name_in) AS DATE),'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:ss')
    INTO date_out
    FROM dual;
    RETURN date_out;
    END fnc_user_rep_date_to_local;The following statement is just an example, the real statement is much more complex. So I select some date values from a table and aggregate a little.
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stampThis statement selects ~70000 rows and needs ~ 70ms
    If i use the function it selects the same number of rows ;-) and takes ~ 4 sec ...
    select
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin'),
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin')I understand that the DB has to execute the function for each row.
    But if I execute the following statement, it takes only ~90ms ...
    select
    fnc_user_rep_date_to_gmt(stp_end_stamp,'Europe/Berlin','ny21654'),
    noi
    from
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stamp
    )The execution plan for all three statements is EXACTLY the same!!!
    Usually i would say, that I use the third statement and the world is in order. BUT I'm working on a BI project with a tool called Business Objects and it generates SQL, so my hands are bound and I can't make this tool to generate the SQL as a subselect.
    My questions are:
    Why is the second statement sooo much slower than the third?
    and
    Howcan I force the optimizer to do whatever he is doing to make the third statement so fast?
    I would really appreciate some help on this really weird issue.
    Thanks in advance,
    Andi

    Hi,
    The execution plan for all three statements is EXACTLY the same!!!Not exactly. Plans are the same - true. They uses slightly different approach to call function. See:
    drop table t cascade constraints purge;
    create table t as select mod(rownum,10) id, cast('x' as char(500)) pad from dual connect by level <= 10000;
    exec dbms_stats.gather_table_stats(user, 't');
    create or replace function test_fnc(p_int number) return number is
    begin
        return trunc(p_int);
    end;
    explain plan for select id from t group by id;
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from t group by test_fnc(id);
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from (select id from t group by id);
    select * from table(dbms_xplan.display(null,null,'advanced'));Output:
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL>
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "TEST_FNC"("ID")[22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL> select * from table(dbms_xplan.display(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$F5BB74E1
       2 - SEL$F5BB74E1 / T@SEL$2
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$F5BB74E1" "T"@"SEL$2")
          OUTLINE(@"SEL$2")
          OUTLINE(@"SEL$1")
          MERGE(@"SEL$2")
          OUTLINE_LEAF(@"SEL$F5BB74E1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    37 rows selected.

  • ABAP Open SQl or EXEC SQL

    1.     I want to do following:
    Select material_no  from mara where material_type in (u2018XXXu2019, u2018YYYu2019, u2018ZZZu2019)
    Where material_no, mateial_type will re replaced by the actual field names.
    Is it possible to do that in OPEN SQL or do I have to use native SQL u2013 EXCE SQL in my case Oracle SQL.
    2.     I have to refer to material type in (u2018XXXu2019, u2018YYYu2019, u2018ZZZu2019) in several sql querie in ABAP, so is it possible to move this code an ABAP function e.g., allowed_mattypes which will true or false
    , so I say
    Where allowed_mattypes(materail_type) = true.
    Once again can it be done in OPEN SQL or in EXEV SQL.
    3. Is there any disadvantage to using EXEC SQL; I know my database Oracle is not going to change and I am qite familiar with EZEC SQL.
    THnaks a lot

    Hi ,
    oh yes it is an object (well, how the database should handle it in any context if it wasn't)
    i.e. for ORACLE you would have several thousands of them:
    select count(*) from dba_objects where object_type ='VIEW'
    If you avoid some kind of foreground processing (i.e. pull the data over the network) and handle the processing inside the database it can improve somehow performance a little (i.e. using the retieved rows of the view to stuff into a database table directly). But his may not always possible...
    bye
    yk

  • EXEC SQL STMT

    What does an EXEC SQL stmt do in ABAPTM? What is the disadvantage of using it?

    Hi
    EXEC SQL statement will occupy more memory
    when you done program just check in SQL trace tool.
    performance tool is there to check
    just go to SE39.Enter your program if its red you have to change SQL query in your program.If its green thats a good program.
    if its useful reward points
    Thanks
    senthil

  • Create data base table with EXEC SQL

    Hello,
    I nead to create o data base table with EXEC SQL in an Abap program.
    My code is :
    TRY.
       EXEC SQL.
          CREATE table zt_hello ( mandt char(4) NOT NULL,
                                  kunnr char(10) NOT NULL,
                                  PRIMARY KEY (mandt, kunnr) )
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO exc_ref.
        error_text = exc_ref->get_text( ).
    ENDTRY.
    IF sy-subrc = 0.
      COMMIT WORK.
    ENDIF.
    But it still not working.
    Can you help me please.
    Thanks.
    Edited by: widad soubhi on Jul 14, 2010 5:26 PM

    Please refer this code
    REPORT z_struct_create .
    DATA: my_row(500) TYPE c,
    my_file_1 LIKE my_row OCCURS 0 WITH HEADER LINE.
    DATA: dd02v TYPE dd02v.
    DATA: my_file_tab1 LIKE dd03p OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text
    NO INTERVALS.
    PARAMETERS:
    name TYPE ddobjname,
    testo TYPE text40,
    file_1 LIKE rlgrap-filename.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN END OF BLOCK blk.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_1.
    PERFORM file_selection USING file_1.
    INITIALIZATION.
    text = text-001.
    START-OF-SELECTION.
    IF file_1 IS INITIAL.
    MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 001.
    EXIT.
    ENDIF.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = file_1
    filetype = 'ASC'
    TABLES
    data_tab = my_file_1.
    IF sy-subrc 0.
    MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 002.
    EXIT.
    ENDIF.
    LOOP AT my_file_1.
    IF sy-tabix > 1.
    CLEAR my_file_tab1.
    SPLIT my_file_1 AT ';' INTO
    my_file_tab1-fieldname
    my_file_tab1-datatype
    my_file_tab1-leng
    my_file_tab1-decimals
    my_file_tab1-ddtext
    my_file_tab1-inttype = 'C'.
    my_file_tab1-INTLEN = my_file_tab1-leng.
    my_file_tab1-tabname = name.
    my_file_tab1-position = sy-tabix - 1.
    my_file_tab1-ddlanguage = sy-langu.
    my_file_tab1-OUTPUTLEN = my_file_tab1-leng.
    APPEND my_file_tab1.
    ENDIF.
    ENDLOOP.
    dd02v-tabname = name.
    dd02v-ddlanguage = sy-langu.
    dd02v-tabclass = 'INTTAB'.
    dd02v-DDTEXT = testo.
    dd02v-MASTERLANG = sy-langu.
    IF NOT my_file_tab1[] IS INITIAL.
    CALL FUNCTION 'DDIF_TABL_PUT'
    EXPORTING
    name = name
    dd02v_wa = dd02v
    TABLES
    dd03p_tab = my_file_tab1
    EXCEPTIONS
    tabl_not_found = 1
    name_inconsistent = 2
    tabl_inconsistent = 3
    put_failure = 4
    put_refused = 5
    OTHERS = 6
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ELSE.
    MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 003.
    EXIT.
    ENDIF.
    *& Form file_selection
    -->P_FILE_1 text
    FORM file_selection USING p_file.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    def_filename = ''
    def_path = 'c:\'
    mask = ',.,..'
    mode = '0'
    title = 'Selezione file'
    IMPORTING
    filename = p_file
    RC = RCODE
    EXCEPTIONS
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    OTHERS = 5.
    ENDFORM. " file_selection
    File Template:
    Fieldname;Data Type;Lentgh;Dec.;Descr.
    FIELD1;CHAR;000020;000000;my field 1
    FIELD2;CHAR;000008;000000;my field 2
    FIELD3;CHAR;000007;000000;my field 3
    FIELD4;CHAR;000006;000000;my field 4

  • Help needed in SQL performance - Using CASE in SQL statement versus 2 query

    Hi,
    I have a requirement to find count from a bunch of tables.
    The SQL I have gives the count of all members.
    I have created 2 queries to find count of active and inactive members.
    The key difference is only the active dates.
    Each query takes 20 seconds to execute.
    I modified the SQL to use CASE statement in the SELECT.
    So after the data is fetched the CASE statement will evaluate the active date and gives 2 counts (active and inactive)
    Is it advisable to use this approach. Will CASE improve SQL performance ? I have to justify this.
    Please let me know your thoughts.
    Thanks,
    J

    Hi,
    If it can be done in single SQL do it in single SQL.
    You said:
    Will CASE improve SQL performance There can be both cases to prove if the performance is better or worse.
    In your case you should tell us how it is.
    Regards,
    Bhushan

  • Use Of "#EC CI_EXECSQL in ABAP with EXEC SQL. Statement giving Syntax Error

    Dear Gurus,
    I have encountered an issue while trying to remove warning for using Native SQL statement using pseudo comment "#EC CI_EXECSQL
    The thing is like this -- i have used follwing native sql command in abap.
    EXEC SQL.
        CONNECT TO 'SURROUND_DB'
      ENDEXEC.
    Now when i am checking this code in code inspector it is showing a warning with information below
    CA CL_CI_TEST_CRITICAL_STATEMENTS0006
    Code Inspector
    Critical Statements
    Use of Native SQL
    Authorization checks cannot be appropriately run using EXEC SQL and should be carried out at program level.
    The message can be hidden using the pseudo-comment "#EC CI_EXECSQL
    Use of exceptin handling section for that warning showing me to use :
    The message can be hidden using pseudo
    comment      "#EC CI_EXECSQL
    Now when I am using "#EC CI_EXECSQL in the abap like below :
    EXEC SQL. "#EC CI_EXECSQL
        CONNECT TO 'SURROUND_DB'
      ENDEXEC.
    It is giving syntax error
    The text literal ""#EC CI_EXECSQL        " is longer than 255
    characters.Check whether it ends correctly.
    Please provide the guideline to resolve this issue.
    Thanks & regards
    Saifur Rahaman.

    Hi Saifur,
    You can remove the warning using the following syntax:
    EXEC "#EC CI_EXECSQL
      SQL.
        CONNECT TO 'SURROUND_DB'
      ENDEXEC.
    At least, it worked fine for me when using OPEN CURSOR, SELECT, FETCH and so on statements.
    The way to use the pseudo comment is not very intuitive, but at least for my examples worked fine.
    I hope this may help you.
    Best regards,
    Edgardo G. König

  • EXEC SQL join in ABAP program

    Hi All,
    I am using EXEC SQL join in my ABAP report,but it is giving dump.could you please correct my following code?
    START-OF-SELECTION.
      CONCATENATE '%' pa_match '%' INTO tp_match.
      EXEC SQL.
        OPEN dbcur FOR
        SELECT  kunnr,name1, banks
               FROM  kna1 as a inner join
               knbk as b
               on akunnr = bkunnr
               WHERE a.kunnr = b.kunnr and
               upper(a~name1) LIKE :tp_match
      ENDEXEC.
      DO.
        EXEC SQL.
          FETCH NEXT dbcur INTO :wa_name1
        ENDEXEC.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND wa_name1 TO ta_name1.
        COLLECT wa_name1 INTO ta_name1.
      ENDDO.
      EXEC SQL.
        CLOSE dbcur
      ENDEXEC.

    Remove the 'As' from the statement
    EXEC SQL.
      OPEN dbcur FOR
      SELECT kunnr,name1, banks
      FROM kna1 a inner join        "Delete 'AS' here
      knbk b
      on a~kunnr = b~kunnr
      WHERE a.kunnr = b.kunnr and
      upper(a~name1) LIKE :tp_match
    ENDEXEC.

  • [sql performance] inline view , group by , max, join

    Hi. everyone.
    I have a question with regard to "group by" inline view ,
    max value, join, and sql performance.
    I will give you simple table definitions in order for you
    to understand my intention.
    Table A (parent)
    C1
    C2
    C3
    Table B (child)
    C1
    C2
    C3
    C4 number type(sequence number)
    1. c1, c2, c3 are the key columns of tabla A.
    2. c1, c2, c3, c4 are the key columns of table B.
    3. table A is the parent table of Table B.
    4. c4 column of table b is the serial number.
    (c4 increases from 1 by "1" regarding every (c1,c2,c3)
    the following is the simple example of the sql query.
    select .................................
    from table_a,
    (select c1, c2, c3, max(c4)
    from table_b
    group by c1, c2, c3) table_c
    where table_a.c1 = table_c.c1
    and table_a.c2 = table_c.c2
    and table_a.c3 = table_c.c3
    The real query is not simple as above. More tables come
    after "the from clause".
    Table A and table B are big tables, which have more than
    100,000,000 rows.
    The response time of this sql is very very slow
    as everyone can expect.
    Are there any solutions or sql-tips about the late response-time?
    I am considering adding a new column into "Table B" in
    order to identify the row, which has max serial number.
    At this point, I am not sure adding a column is a good
    thing in terms of every aspect.
    I will be waiting for your advice and every response
    will be appreciated even if it is not the solution.
    Have a good day.
    HO.
    Message was edited by:
    user507290

    For such big sources check that
    1) you use full scans, hash joins or at least merge joins
    2) you scan your source data as less as possible. In the best case each necessary table only once (for example not using exists clause to effectively scan all table via index scan).
    3) how much time you are spending on sorts and hash joins (either from v$session_longops directly or some tool that visualises this info). If you are using workarea_size_policy = auto, probably you can switch to manual for this particular select and adjust sort_area_size and hash_area_size big enough to do as less as possible sorts on disk
    4) if you have enough free resources i.e. big box probably you can consider using some parallelism
    5) if your full scans are taking big time check what is your db_file_multiblock_read_count, probably increasing it for this select will give some gain.
    6) run trace and check on what are you waiting for
    7) most probably your problem is IO bound so probably you can do something from OS side to make IO faster
    8) if your query now is optimized as much as you can, disks are running as mad and you are using all RAM then probably it is the most you can get out of your box :)
    9) if nothing helps then you can start thinking about precalculations either using your idea about derived column or some materialized views.
    10) I hope you have a test box and at least point (9) do firstly on it and see whether it helps.
    Gints Plivna
    http://www.gplivna.eu

  • Where can i set up connection in "exec sql"?

    i have code block like this:
    EXEC SQL.
        SET CONNECTION :'PA'
      ENDEXEC.
      IF SY-SUBRC <> 0.
      Connection not yet opened.
        EXEC SQL.
          CONNECT TO :'PA'
        ENDEXEC.
        IF SY-SUBRC <> 0.
          write: / sy-msgid ,sy-msgno,sy-msgty,sy-msgv1,sy-msgv2,sy-msgv3,sy-msgv4.
          write: / 'connect error'.
           RAISE EXCEPTION TYPE cx_sy_native_sql_error.
        ENDIF.
      ENDIF.
    where can i set up the 'PA'?thanks very much!!!!

    You set  up new databse connection for SAP to communincate with using 'DBCO' tcode.

Maybe you are looking for