Alternative for EXEC command(Native SQL)

Hi Friends,
         While Using the EXEC command in native sql it is showing the obselete Error  , Can  any one help  with giving the alternative for the commands for native SQl.
       Immediate

In a Native SQL statement, data is passed between the ABAP program and the database using host variables. A host variable is an ABAP variable that is identified as such in the Native SQL statement by a preceding colon (:).
Example
Displaying an extract from the table AVERI_CLNT:
DATA: F1(3), F2(3), F3(3).
F3 = ' 1 '.
EXEC SQL.
  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
         WHERE ARG2 = :F3
ENDEXEC.
WRITE: / F1, F2.
To simplify the form of the INTO lists in the SELECT statement, you can, as in Open SQL, specify a single structure as the target area.
Example
Displaying an Extract from the Table AVERI_CLNT:
DATA: BEGIN OF WA,
        CLIENT(3), ARG1(3), ARG2(3),
      END OF WA.
DATA  F3(3).
F3 = ' 1 '.
EXEC SQL.
  SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT
         WHERE ARG2 = :F3
ENDEXEC.
WRITE: / WA-CLIENT, WA-ARG1.
Native SQL supports the directly-executable commands of your underlying database system. There are other special commands that you can use after the EXEC SQL statement for cursor handling, stored procedures (procedures stored in the database), and connections to other databases.
Cursor Processing

Similar Messages

  • Return code for EXECUTE PROCEDURE (native SQL)

    Hi Experts,
    I've seen in the Note 364707 that the field %_ERRCODE is no longer supported since WAS 6.10 for stored procedures like this:
    EXEC SQL.
      EXECUTE PROCEDURE proc [(parameter list)] %_ERRCODE INTO :rc
    ENDEXEC.
    So an Upgrade to WAS 7.00 gives this programms an error.
    Has anybody an idea for an alternative?
    Regards,
    Stefan

    Hello Peluka,
    i have seen you have worked with 'execute procedure'.
    I want to execute a procedure with two Parameters and one structure. Example:
    EXECUTE PROCEDURE test.p_getdata ( in :i_ls_nr , in :vdatum , out :vtest ).
    vtest has the simple structure with field lieferscheinnr (char25).
    When i execute the procedure, i get the error <b>wrong number or types of arguments in call</b>.
    Do you know, whether execute procedure with structures is not possible?
    Thank you in advance.

  • Alternative for Open , Fetch cursor command

    Hi Experts,
    I am populating data from glpca table using Open Cursor statement with hold as shown below:
      OPEN CURSOR WITH HOLD cur1 FOR
    Select data from the purchase order header table.
      SELECT runit rprctr sprctr                               
             racct rfarea hsl msl kostl aufnr ps_psp_pnr
              FROM glpca
             WHERE docnr  IN s_docnr
               AND rbukrs =  p_rbukrs
               AND rprctr IN s_rprctr
               AND sprctr IN s_sprctr                          
               AND rfarea IN s_rfarea
               AND budat  IN s_budat
               AND kostl  IN s_kostl
               AND aufnr  IN s_aufnr.
    Now when i try to Fetch the cursor even restricting it with PACKAGE SIZE command ( value 998), my program get struck over here for 20-30 mins or more den that & session gets out for the user at client end coz of large data. I checked the value of cursor , it was around 670-700 approx.
    The query is shown below:
    DO.
    fetch rows from cursor depending on package size
        FETCH NEXT CURSOR cur1 INTO TABLE t_glpca
           PACKAGE SIZE p_size.
        IF sy-subrc NE 0.
          CLOSE CURSOR cur1.
          EXIT.
        ENDIF.
    The program get struck at above fetch next cursor command.
    Kindly suggest me some other way to handle or populate the data or any alternative for Cursor command.
    Thanks for your consideration.
    Regards
    Mudit

    Siegfried Boes  wrote:
    > there is a reason why OPEN CURSOR WITH HOLD is usually used.
    >
    > Siegfried
    Sorry for hijacking this thread and asking here. I am here in the forums on daily basis just reading and learning.
    This got me curious and I googled and read SAP tutorial about cursors:
    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm
    also read an answer from Thomas after searching forum:
    The combination with OPEN CURSOR ... WITH HOLD allows package processing of tasks that require a database commit inside the loop. A normal SELECT loop without holding the cursor would be interrupted by a commit -> short dump.
    MY TWO QUESTIONs
    1. In SAP tutorial it states that
    "WITH HOLD addition in the OPEN CURSOR statement allows you to prevent a cursor from being closed when a database commit occurs in Native SQL"
    If I don't specify any commit statements in my abap code and user cursor without the addition with hold.
    Can a commit be executed anyway and I get an unwanted commit and thus an unwanted close of my cursor?
    Or do they mean that "if you specify commit in native sql"?
    2. Thomas says a normal select loop without the cursor holding would be interrupted. Interrupted by who? Again, it seems like there is an "unwanted" commit here? Again, can there be any commits and unwanted interrupts if I dont specify it somewhere in my code?
    regards
    Baran
    Edited by: Baran Sölen on Feb 25, 2009 11:39 AM

  • Using Native SQL in Web Dynpro for ABAP

    Hi folks,
    I am trying to access an oracle database in web dynpro for ABAP via Native SQL.
    I am able to read row by row from the database into a work area, but I am unable to read the whole table from the database into an internal table.
    Please advise as to how I can do this, and thanks for reading.
    PS: Thomas, I wasn't off-topic on the previous thread; I forgot to mention that I was trying to do this under Web Dynpro for ABAP.

    Hello,
    it doesn't matter if you try this with Web Dynpro ABAP, BSP or any other framework, this is a general ABAP question and not related to this forum.
    Regards,
    Rainer

  • Alternative for describe

    Will u please tell, what are the alternative commands for "Describe" command in sql(defining the structure of the table) .

    You can query on
    SELECT * FROM USER_TAB_COLS where table_name ='&Table_Name'Thanx.. Ratan

  • UpdateAllQuery and Native SQL

    Hi,
    I have below three update statements, and need to be in one transaction. How can I accomplish it using UpdateAllQuery? Finance_Management is a child table of Org mapped through org_id; Org_Finance is a child table of Finance_Management linked by finance_management_id.
    Update Org
    Set Account_Balance = Account_Balance + 25, Update_User = 'Jeff_Org', Update_Date = Systimestamp
    Where Org_Id = 10226;
    Update Finance_Management
    Set Account_Balance = (Select Account_Balance From Org Where Org_Id = 10226),
    Transaction_Amount = 25, Transaction_Date = Systimestamp
    where finance_management_id = 1701152;
    Update Org_Finance
    Set Check_Mo_Number = 5432, Payment_Type = 'C'
    where Finance_Management_Id = 1701152;
    Alternatively, when I tried native SQL with executeNonSelectingCall within unit of work like below, it appears that even through the second SQLCall failed, the first one still committed to the database. How can I ensure the three SQLCalls are in one transaction?
    UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
    uow.executeNonSelectingCall(new SQLCall(orgSql));
    uow.executeNonSelectingCall(new SQLCall(fmSql));
    uow.executeNonSelectingCall(new SQLCall(orgFnSql));
    uow.commit();
    Thanks for your help!
    Jeffrey

    I think I have figured it out.
    For using UpdateAllQuery, three different UpdateAllQueries need to be constructed. One critical piece is that, use beginEarlyTransaction() before execute the three queries inside UOW. Same is true when using native SQLs.
    Few questions though that I need some experts to clear my mind:
    - so all database Queries can run inside unit of work, become part of the single transaction within UOW by using beginEarlyTransaction(), is this correct?
    - How about insert? InsertObjectQuery and WriteObjectQuery don't seem allow to use expression, which I need for populating a field like "Account_Balance = (Select Account_Balance From Org Where Org_Id = 10226)". Any suggestions on what API call I should use without using native SQL?
    Thanks,
    Jeffrey

  • Executing Native SQL query for oracle

    Hi,
    I want to run following native sql query but it is giving me error ora:933,
    DATA: BEGIN OF WA,
          TSP_NAME(255) TYPE C,
          PER_USAGE(10) TYPE C,
          END OF WA.
    EXEC SQL PERFORMING loop_output.
    select t.tablespace_name,'(' || TO_CHAR(ROUND(100*(NVL(b.bytes,0)/NVL(a
    .bytes,0)))) || '%)' "TSUsed%" from dba_tablespaces t,
    ( select tablespace_name, sum(bytes)/1024/1024 bytes
    from dba_data_files group by tablespace_name) a,
    ( select e.tablespace_name, sum(e.bytes)/1024/1024 bytes
    from dba_extents e group by e.tablespace_name ) b,
    ( select f.tablespace_name, sum(f.bytes)/1024/1024 bytes
    from dba_free_space f group by f.tablespace_name ) c
    where t.tablespace_name = a.tablespace_name(+) and
    t.tablespace_name = b.tablespace_name(+) and
    t.tablespace_name = c.tablespace_name(+) into :wa.
    ENDEXEC.
    Please provide me the soln
    Regards,
    Bharat Mistry

    ORA-00933: SQL command not properly ended.
    Try:
    EXEC SQL PERFORMING loop_output.
    select
    into :wa
    ENDEXEC.
    (No "." at the end). If that doesn't work, try ending it with a ";"
    Rob

  • Using native sql for update

    Hello ,
    I have a reqaust to update a db table declared "outside" our R3 db.
    I mennage to select the data using native sql with a connection to the db.
    Now i need to modify the data on the db.
    Is there a similliar command like "fetch next" ' for update?
    Mybe i need to build a procedure in th "host" db and use its own commands to update?
    Thanks,
    koby

    Hello Kobi,
    Which release of SAP are you woking on?
    If you're on ECC6.0, instead you using Native SQL to call the stored procs of external DBs you can use the [ADBC APIs |http://help.sap.com/abapdocu_702/en/abenadbc_procedure.htm](CL_SQL* classes).
    BR,
    Suhas

  • Adpatch: Error running SQL and EXEC commands in parallel

    Hi
    I am applying R12 RUP2 to an instance at the moment. I had an OS crash (I'm running R12 on Linux on VMWARE) and on reboot attempted to restart the patch.
    I now get an error as follows:
    Error running SQL and EXEC commands in parallel
    I must admit, I'm not a DBA, so if anyone has any ideas or has seen this before then it would be most appreciated!
    Thanks
    Chris

    Hi Adith
    The patch is 5484000, RUP 2 for E-Business Suite R12
    Here's the adpatch output:
    Start date: Wed Sep 12 2007 15:15:14
    0 "left over" javaupdates.txt files uploaded to DB: Wed Sep 12 2007 15:15:14
    0 patches uploaded from the ADPSV format patch history files: Wed Sep 12 2007 15:15:14
    Uploading information about files copied during the previous runs ...
    0 "left over" filescopied_<session_id>.txt files uploaded to DB: Wed Sep 12 2007 15:15:14
    ****************** E N D O F U P L O A D ******************
    End date: Wed Sep 12 2007 15:15:14
    Already asked for the name of the patch directory.
    (The answer was: /oracle/patches/5484000)
    Already asked for the name of the patch driver file.
    (The answer was: /oracle/patches/5484000/u5484000.drv)
    Reading release list save file...
    Done reading release list save file
    Log and Info File sync point:
    Wed Sep 12 2007 15:15:15
    Turning off actions that reference unrecognized products.
    Log and Info File sync point:
    Wed Sep 12 2007 15:15:15
    End of unrecognized products checking.
    (The number of parallel workers is: " 2 ")
    AutoPatch will run in parallel mode.
    Did not need to apply new applterr.txt.
    Skipping...
    Determine directories to create for Specified driver
    since no such action is present for this driver file
    Skipping...
    Determine Oracle Reports libraries to generate for Specified driver
    since no such action is present for this driver file
    Skipping...
    Determine if need to generate message files for Specified driver
    since no such action is present for this driver file
    Skipping...
    Create Directories for Specified driver
    since no such action is present for this driver file
    Number of invalid objects: 31057
    Running SQL scripts and EXEC commands...
    Determining which SQL and EXEC commands to run...
    Validating PL/SQL direct execute exceptions file ...
    Done validating PL/SQL direct execute exceptions file.
    SERVICE_NAME/INSTANCE_NAME : [VIS]
    connect_string : [(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ebusr12.chriseebee.me.uk)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=VIS)))]
    Done determining which SQL and EXEC commands to run.
    Running SQL and EXEC commands in parallel...
    Creating the AD_UTIL_PARAMS table...
    Table AD_UTIL_PARAMS already exists, so dropping the table and recreating it.
    Creating FND_INSTALL_PROCESSES table...
    Already created fnd_install_processes table
    Already created FND_INSTALL_PROCESSES_U1 index.
    Already created AD_DEFERRED_JOBS table
    Already created AD_DEFERRED_JOBS_U1 index.
    Writing dependencies of jobs to run to appldep.txt file...
    There are now 7569 jobs remaining (current phase=A0):
    0 running, 5 ready to run and 7564 waiting.
    Reading completed jobs from restart file (if any).
    There are now 3474 jobs remaining (current phase=A18):
    0 running, 1 ready to run and 3473 waiting.
    Determining which java executables are supported by adJavaWorker...
    Starting worker processes.
    Worker process 1 started.
    Worker process 2 started.
    Checking if all jobs have their actual and symbolic arguments in sync....
    Done.
    Writing jobs to run to restart file.
    Reading jobs from FND_INSTALL_PROCESSES table ...
    Running: file adobjcmp.sql on worker 1 for product ad username APPLSYS.
    AutoPatch error:
    The worker should not have status 'Running' or 'Restarted' at this point.
    Telling workers to quit...
    ************* Start of AD Worker session *************
    AD Worker version: 12.0.0
    AD Worker started at: Wed Sep 12 2007 15:15:34
    APPL_TOP is set to /oracle/VIS/apps/apps_st/appl
    ************* Start of AD Worker session *************
    AD Worker version: 12.0.0
    AD Worker started at: Wed Sep 12 2007 15:15:34
    APPL_TOP is set to /oracle/VIS/apps/apps_st/appl
    All workers have quit.
    AutoPatch error:
    Error running SQL and EXEC commands in parallel
    You should check the file
    /oracle/VIS/apps/apps_st/appl/admin/VIS/log/adpatch.log
    for errors.

  • Error running SQL and EXEC commands in parallel when adpatch

    Hi,
    AutoPatch error:
    aiprfp: product 'cle' not in release 'R120'
    AutoPatch error:
    Error running SQL and EXEC commands in parallel
    Freeing includes hash table
    Freeing fixes hash table
    Freeing basedons hash table
    Freeing entities hash table
    You should check the file
    /a02/prod/apps/apps_st/appl/admin/PROD/log/adpatch_7305220_1.log
    for errors.
    How to resolve this errror while applying patch 7305220.
    Regards,

    Hi,
    Please check logfile */a02/prod/apps/apps_st/appl/admin/PROD/log/adpatch_7305220_1.log* for any errors recoded.
    Post error messages from this logfile.This is the main patch log file and it should show the same error "aiprfp: product 'cle' not in release 'R120'".
    Thanks,
    Hussein

  • Error running SQL and EXEC commands in parallel

    Dear Gurus,
    We are applying 3480000 and in process as soon as workers start it come out of adpatch session and give su the following error:
    ************* Start of AD Worker session *************
    AD Worker version: 11.5.0
    AD Worker started at: Sun Sep 02 2007 23:11:01
    APPL_TOP is set to /sgmtemp/prodappl
    Worker process 4 started.
    Checking if all jobs have their actual and symbolic arguments in sync....
    Done.
    Writing jobs to run to restart file.
    Reading jobs from FND_INSTALL_PROCESSES table ...
    Done reading jobs from FND_INSTALL_PROCESSES table ...
    Telling workers to read 'todo' restart file.
    Done.
    Starting phase 0 (A0): first
    There are now 98197 jobs remaining (current phase=A0):
    0 running, 123 ready to run and 98074 waiting.
    Assigned: file adsysapp2.sql on worker 1 for product admin username APPLSYS.
    Assigned: file cssruwq1.sql on worker 2 for product cs username CS.
    Connecting to CSD......Unable to connect.
    AutoPatch error:
    The following ORACLE error:
    ORA-01017: invalid username/password; logon denied
    occurred while executing the SQL statement:
    CONNECT CSD/*****
    AutoPatch error:
    Error while evaluating "Check Object"
    Telling workers to quit...
    3 workers have quit. Waiting for 1 more.
    All workers have quit.
    Error running SQL and EXEC commands in parallel
    You should check the file
    /sgmtemp/prodappl/admin/msbep004/log/3480000_sbm3.log
    for errors.
    applmgr@21:/sgmtemp/Oglupgr/3480000>
    What could be the issue, i tried to connect CSD/CSD in sql and it connected.
    Thanks in Advance
    Regards
    Kiran Rana

    Hi Gurus,
    Even i tried to recreate the FND_GLOBAL by performing the following, but still no luck:
    output for scripts hearder value in FND_TOP:
    applmgr@21:/sgmtemp/prodcomn/temp> cd $FND_TOP/patch/115/sql
    applmgr@21:/sgmtemp/prodappl/fnd/11.5.0/patch/115/sql> grep Header AFSCGBL*
    AFSCGBLB.pls:/* $Header: AFSCGBLB.pls 115.78 2005/03/21 11:40:02 vbalakri ship $ */
    AFSCGBLS.pls:/* $Header: AFSCGBLS.pls 115.33 2004/06/30 05:00:18 rsheh ship $ */
    Output for script header value in Database:
    SQL> select text from dba_source where name='FND_GLOBAL' and line <5;
    TEXT
    package FND_GLOBAL as
    /* $Header: AFSCGBLS.pls 115.33 2004/06/30 05:00:18 rsheh ship $ */
    package body FND_GLOBAL as
    /* $Header: AFSCGBLB.pls 115.78 2005/03/21 11:40:02 vbalakri ship $ */
    8 rows selected.
    We tried to re-apply 4 hours back when one of the support personnal ask use to run those
    scripts. one of them went with out any errors but second one went with errors
    as follows:
    First Script @AFSCGBLS.pls
    applmgr@21:/sgmtemp/prodappl/fnd/11.5.0/patch/115/sql> sapps @AFSCGBLS.pls
    SQL*Plus: Release 8.0.6.0.0 - Production on Mon Sep 3 03:24:10 2007
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    With the Partitioning and Oracle Data Mining options
    JServer Release 9.2.0.7.0 - Production
    DOC> | Copyright (c) 1993 Oracle Corporation Redwood Shores, California, USA|
    DOC> | All rights reserved. |
    DOC> +=======================================================================+
    DOC> | FILENAME
    DOC> | AFSCGBLS.pls
    DOC> |
    DOC> | DESCRIPTION
    DOC> | PL/SQL specification for package: FND_GLOBAL
    DOC> |
    DOC> | NOTES
    DOC> | This module is called by AutoInstall (afplss.drv) on install and
    DOC> | upgrade. The WHENEVER SQLERROR and EXIT (at bottom) are required.
    DOC> |
    DOC> | HISTORY
    DOC> | June, 1999 - Added function AUDIT_ACTIVE, bug 879630. Jan Smith.
    DOC> | 11/19/01 MSkees - Added DBDrv line and 'SET VERIFY OFF' for ARU auto
    DOC> | generation bug 2047263 build
    DOC> |
    DOC> *=======================================================================*/
    Package created.
    Commit complete.
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    With the Partitioning and Oracle Data Mining options
    JServer Release 9.2.0.7.0 - Production
    Second Script AFSCGBLB.pls:
    applmgr@21:/sgmtemp/prodappl/fnd/11.5.0/patch/115/sql> sapps @AFSCGBLB.pls <
    SQL*Plus: Release 8.0.6.0.0 - Production on Mon Sep 3 03:27:15 2007
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    With the Partitioning and Oracle Data Mining options
    JServer Release 9.2.0.7.0 - Production
    Warning: Package Body created with compilation errors.
    Commit complete.
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    With the Partitioning and Oracle Data Mining options
    JServer Release 9.2.0.7.0 -
    Production
    applmgr@21:/sgmtemp/prodappl/fnd/11.5.0/patch/115/sql>
    The second script (AFSCGBLB.pls) run's out with errors and changes status of almost 15000 objects as INVALID in database.
    Regards
    Kiran Rana

  • Performance for join 9 custom table with native SQL ?

    Hi Expert,
    I need your opinion regarding performance to join 9 tables with native sql. Recently i have to tunning some customize extraction cost  report. This report extract about 10 million cost of material everyday.
    The current program actually, try to populate the condition data and insert into customize table and join all the table to get data using native sql.
    SELECT /*+ ordered use_hash(mst,pg,rg,ps,rs,dpg,drg,dps,drs) */
                mst.werks, ....................................
    FROM
                sapsr3.zab_info mst,
                sapsr3.zab_pc pg,
                sapsr3.zab_rc rg,
                sapsr3.zab_pc ps,
                sapsr3.zab_rc rs,
                sapsr3.zab_g_pc dpg,
                sapsr3.zab_g_rc drg,
                sapsr3.zab_s_pc dps,
                sapsr3.zab_s_rc drs
            WHERE mst.zseq_no = :p_rep_run_id
            AND mst.werks = :p_werks
            AND mst.mandt = rg.mandt(+)
            AND mst.ekorg = rg.ekorg(+)
            AND mst.lifnr = rg.lifnr(+)
            AND mst.matnr = rg.matnr(+)
            ...............................................   unitl all table (9 tables)
            AND ps.mandt = dps.mandt(+)
            AND ps.knumh = dps.knumh(+)
            AND ps.zseq_no = dps.zseq_no(+)
            AND COALESCE (dps.kbetr, drs.kbetr, dpg.kbetr, drg.kbetr) <> 0
    It seems the query ask for database to using hashed table. would that be it will burden the database ? and impacted to others sap process ?
    Please advise
    Thank You and Best Regards

    you can only argue coming from measurements and that is not the case.
    Coming from the code, I see only that you do not understand it at all, so better leave it as it is. It is not a hash table, but a hash join on these table.

  • Using Native SQL in ABAP for DB2 database

    Dear Friends,
           I have 500K records in ITAB(Internal table) which needs to insert in 'Z' transparent table. Currently it is taking hours of time for insertion and commit. 
    Does using Native SQL helps in performance or any suggestions? If so please send the code. Our database is DB2.
    Your immediate reply is appreciated. Thanks in advance.

    Hi Rama,
    Using array inserts and commit after each Insert, set up your array size as a parameter and try  different array sizes.
    I would start with 2000 and increment by 1000 or 2000 and see what the optimal array size is.
    I would think more commits are desirable, as the array gets bigger it takes longer for the system to prepare in the event of a rollback.
    Just remember to commit after each insert. And are you enqueueing the table first?
    Hope this helps.
    Filler

  • Error handling in Native SQL for ORACLE

    Hi,
    I have the next code:
    DATA instr TYPE char4.
    EXEC SQL.
        SELECT INSTRUMENTO INTO instr FROM DATOSMAESTROS
    END EXEC.
    And I want to control if the select has no results. Is it possible with the statement EXCEPTION inside EXEC SQL? Something like that:
    DATA instr TYPE char4.
    EXEC SQL.
        SELECT INSTRUMENTO INTO instr FROM DATOSMAESTROS WHERE id_inst = '01'
        EXCEPTION
             WHEN NO_DATA_FOUND THEN
                      :err = SQLCODE
                      INSERT INTO error( field, code_err) VALUES ( 'instrumento',:err)
    END EXEC.
    Is this a correct code? If not, how can I do it?
    Thank you all,
    Cris.

    Hello,
    Take a look on this: http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm
    Try this:
    DATA instr TYPE char4.
    EXEC SQL.
    SELECT INSTRUMENTO INTO :instr FROM DATOSMAESTROS
    ENDEXEC.
    Look that I put : inside the native SQL before the intr.
    To catch if no data was recovered try this:
    DATA instr TYPE char4.
    EXEC SQL PERFORMING no_data.
    SELECT INSTRUMENTO INTO :instr FROM DATOSMAESTROS
    ENDEXEC.
    FORM no_data.
      IF instr IS INITIAL.
        MESSAGE ...
      ENDIF.
    ENDFORM.
    Regards.

  • Alternative for Cursor in SQL Server 2012

    Hi all,
      I keen to know Alternative for Cursor in SQL Server 2012. Why everyone telling Cursor have performance impact. Any other alternative for row by row comparison like Array in SQL 2012 ?
    Thanks

    It is not the cursor that kills you - it is the loop as such. I've seen more than one example of a poor man's cursor, where they have selected TOP 1 from a #temp ORDER BY, and several operations on the temp table - which is completely void of indexes,
    making the operations for the loop control the slowest in the batch. So you use cursor when you need to iterate.
    But in many cases, you should work and think set-based instead.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for