ExecuteUpdate instead of executeQuery for select statements

We can execute a select query using executeQuery. But the select query can
also be executed using executeUpdate. What is the difference in using the 2.
Why dont we use executeUpdate itself in place of executeQuery

We can execute a select query using executeQuery. But
the select query can
also be executed using executeUpdate. What is the
difference in using the 2.
Why dont we use executeUpdate itself in place of
executeQuery
There is also an execute() method available. As suggested, read the API documentation.

Similar Messages

  • Timesten create a lock for select statement through sqldev

    When use ttisql connect to TimesTen Release 7.0.6.15.0 at autocommit=1, there is no lock for select statement.
    but when I use sql developer (driver is ttjdbc5.jar, regardless of version) to connect, even with autocommit=1, there will be locks for select statement.
    Is it a bug? How can I achieve the same no locks for select statement through sql developer?Thanks.

    -your update tells me that you are connected to a remote timesten data store using the client driver
    -the ttXactAdmin output indicates that SqlNavigator has a shared lock on the database itself: this will not interfere with anybody else' read operations, and I believe that until such time as you actually attempt some kind of DML against the data store that th IX lock on the database lock will not interfere with any other DML either.
    -a shared database lock will always be acquired for any transaction in TimesTen. You can test this for yourself from ttisql: set autocommit off, perform a simple update and do not commit the transaction. Then open a separate session and execute ttxactadmin - you will the IX database lock as well as the various locks on tables and indexes.
    -I believe this pretty much proves my original thinking: that sqlDeveloper attaches to TimesTen in transaction mode. However, the IX lock on the database will not interfere with anybody else's work and should not be a problem.

  • Performance Tuning -To find the execution time for Select Statement

    Hi,
    There is a program that takes 10 hrs to execute. I need tune its performance. The program is basically reading few tables like KNA1,ANLA,ANLU,ADRC etc and updates to Custom table. I did my analysis and found few performance techniques for ABAP coding.
    Now my problem is, to get this object approved I need to submit the execution statistics to client.I checked both ST05 and SE30. I heard of a Tcode where we can execute a select statement and note its time, then modify and find its improved Performance. Can anybody suggest me on this.
    Thanks,
    Rajani.

    Hi,
    This is documentation regarding performance analysis. Hope this will be useful
    It is a general practice to use           Select  *  from <database>…     This statement populates all the values of the structure in the database.
    The effect is many fold:-
    •     It increases the time to retrieve data from database
    •     There is large amount of unused data in memory
    •     It increases the processing time from work area or internal tables
    It is always a good practice to retrieve only the required fields. Always use the syntax      Select f1  f2  …  fn  from <database>…      
    e.g.     Do not use the following statement:-
         Data: i_mara like mara occurs 0 with header line.
         Data: i_marc like marc occurs 0 with header line.
         Select * from mara
              Into table i_mara
              Where matnr in s_matnr.
         Select * from marc
              Into table i_marc
              For all entries in i_mara
              Where matnr eq i_mara-matnr.
         Instead use the following statement:-
                                       Data: begin of i_mara occurs 0,
                                            Matnr like mara-matnr,
                                                  End of i_mara.
         Data: begin of i_marc occurs 0,
              Matnr like marc-matnr,
                                            Werks like marc-werks,
                                                 End of i_marc.
         Select matnr from mara
              Into table i_mara
              Where matnr in s_matnr.

  • Dynamic sql for select statement

    Hi,
    Please help me with the below code:
    It is updating null if the select statment returns one values. If it fetches multiple values then it throughs the below error msg when running the program.
    Please let me know how to modify the below code. Or let me know is there anyother way to write this code.
    Logic for development:
    * View name should be passed as dynamic.
    CREATE OR REPLACE
    PROCEDURE "PKEP_LOAD_SO_EU" (p_var1 IN VARCHAR2)
    IS
    lv_sql VARCHAR2 (4000);
    lv_name VARCHAR2 (20);
    BEGIN
    lv_sql :=
    ' SELECT DISTINCT LEVEL2
    FROM BIIO_SALES_OB_IMPORT_'|| p_var1;
    EXECUTE IMMEDIATE lv_sql
    INTO lv_name;
    BEGIN
    UPDATE BIIO_SALES_OB_IMPORT_NA2 --table name for updation
    SET SOB_1 = NULL,
    SOB_DATE_1 = NULL
    WHERE level2 = lv_name; -- validation ( eg. Select distinct level2 from biio_sales_ob_import_'||p_var1)
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line (SQLERRM);
    NULL;
    END;
    END;
    BEGIN
    PKEP_LOAD_SO_EU ('NA1');
    end;
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "DEMANTRA.PKEP_LOAD_SO_EU", line 11
    ORA-06512: at line 2
    01422. 00000 - "exact fetch returns more than requested number of rows"
    *Cause:    The number specified in exact fetch is less than the rows returned.
    *Action:   Rewrite the query or change number of rows requested
    Thanks.
    Padma

    Padu wrote:
    Please let me know whether is anyother way to write this code as im a beginner for SQl.You dont need to have a seperate SELECT statement. Just a single UPDATE will do the job for you.
    create or replace procedure pkep_load_so_eu
       p_var1 in varchar2
    as
    begin
       lSql := ' update biio_sales_ob_import_na2               ' ||
               '    set sob_1      = null                    ' ||
            '      , sob_date_1 = null                    ' ||
            '  where level2 in (                         ' ||
            '                    select level2               ' ||
            '                      from biio_sales_ob_import_'       || p_var1 ||
       execute immediate lSql;
    end;

  • Need to Improve  pefromance for select statement using MSEG table

    Hi all,
    We are using a select statement using MSEG table
    which takes a very long time to run the program which is scheduled in back ground.
    Please see the history below.;
    1) Previously this program was using SELECT-ENDSELECT statement inside the loop i.e.
    LOOP AT I_MCHB.
    To get Material Doc. Details
          SELECT MBLNR
                 MJAHR
                 ZEILE INTO (MSEG-MBLNR,MSEG-MJAHR,MSEG-ZEILE)
                 UP TO 1 ROWS
                 FROM MSEG
                WHERE CHARG EQ I_MCHB-CHARG
                 AND  MATNR EQ I_MCHB-MATNR
                 AND  WERKS EQ I_MCHB-WERKS
                 AND  LGORT EQ I_MCHB-LGORT.
          ENDSELECT.
    Endloop.
    The program was taking 1 hr  for  20 k data
    2)The above statement was replaced by ALL ENTRIES to remove the SELECT-ENDSELECT from the loop.
    ***GET MATERIAL DOC NUMBER AND FINANCIAL YEAR DETAILS FROM MSEG TABLE
        SELECT MBLNR
               MJAHR
               ZEILE
               MATNR
               CHARG
               WERKS
               LGORT
                   INTO TABLE I_MSEG
                   FROM   MSEG
                   FOR ALL ENTRIES IN I_MCHB
                   WHERE CHARG EQ I_MCHB-CHARG
                   AND   MATNR EQ I_MCHB-MATNR
                   AND   WERKS EQ I_MCHB-WERKS
                   AND   LGORT EQ I_MCHB-LGORT.
    3)After getting the further technical analysis from BASIS team , And with the suggestion to optimize the program by changing the INDEX RANGE SCAN to
           MSEG~M.
    SELECT MBLNR
               MJAHR
               ZEILE
               MATNR
               CHARG
               WERKS
               LGORT
                   INTO TABLE  I_MSEG
                   FROM   MSEG
                   FOR ALL ENTRIES IN I_MCHB
                   WHERE MATNR EQ I_MCHB-MATNR
                   AND   WERKS EQ I_MCHB-WERKS
                   AND   LGORT EQ I_MCHB-LGORT.
    At present the program is taking 3 to 4 hrs in back ground .
    The table is complete table scan using index
    MSEG~M.
    Please suggest to improve the performance of this
    many many thanks
    deepak

    The benchmark should be the join, and I can not see how any of your solutions can be faster than the join
    SELECT   .....
                  INTO TABLE  ....
                  UP TO 1 ROWS
                  FROM mchb as a
                  INNER JOIN mseg as b
                  ON    amatnr EQ bmatnr
                  AND  awerks  EQ bwerks
                  AND  algort    EQ blgort
                  And   acharg  EQ bcharg
                  WHERE a~ ....
    The WHERE condition must come from the select on MCHB, the field list from the total results
    you want.
    If you want to compare, must compare your solutions plus the select to fill I_MCHB.
    Siegfried
    Edited by: Siegfried Boes  on Dec 20, 2007 2:28 PM

  • Performance tunning for select statements using likp lips and vbrp

    Dear all,
      I have a report where i am using select statements using first on likp the for all entries of likp  i am taking data from lips and then for all entries in lips i am taking data from vbrp by matching VGBEL and VGPOS. Now the problem is that when it fetches data from vbrp it is taking lot of time around 13mins. to fetch data from vbrp. How can i overcome the problem.
    regards
    Amit

    Hi,
    there is also no secondary index for preceding document in VBFA table.
    You will also have to create it here.
    Regards,
    Przemysław

  • Runtime error for SELECT statement

    Hi All,
    I have written a SELECT statement as follows in my code.
    select budat pernr aufnr vornr from AFRU
    into corresponding fields of table it_vornr
    for all entries in it_cats_tmp
    where budat = it_cats_tmp-workdate
    and pernr = it_cats_tmp-pernr
    and aufnr = it_cats_tmp-rnplnr.
    The table IT-CATS_TMP is having around 3000+ lines.
    When control moves to this statement, the system is throwing Runtime error or its taking around 30 minutes time to execute.
    If i query the same table (AFRU) in SE11 for the same set of conditions, the table displays relevent data immediately.
    What might be the reason for this delay/Runtime Error?
    Shall i need to change the syntax for better performance?
    Your guidelines are highly appreciated......
    Regards
    Pavan

    Hi
    1. Try to put WHERE conditions for KEY FIELDS.
    Solution: Create a RANGE for the key fields & put that in SELECT Query.
    DATA: gr_rueck TYPE RANGES OF afru-rueck.
    SELECT .. WHERE rueck IN gr_rueck.
    2. Avoid using CORRESPONDING FIELDS OF TABLE in SELECT.
    Solution: Change internal table fields ORDER.
    TYPES:
    BEGIN OF TY_VORNR,
      budat TYPE ..
      pernr TYPE ..
      aufnr TYPE ..
      vornr TYPE ..
      ... " Other fields
    END OF TY_VORNR.
    SELECT .. INTO TABLE IT_VORNR ...

  • Menu Module v2 support for selected state?

    I can't figure out if menu module v2 supports the selected state. I remember reading somewhere that it was slated in the future, but it seems the file /ModuleTemplates/Menu/Default/container.html has accommodations for it.
    A resource if so, would be highly appreciated.

    By default I does, the JavaScript is there in the layouts and no different to the normal version in that regard.

  • Build SVG graphic for Select statement

    I asked an earlier question and need to refine it or even ask it differently.. So here goes..
    I have a report, that is built using a select statement.. In this report I need to have an item that is a barcode printed.
    I have a function that is from a member here, that will produce a svg bar code, in an HTML region, using an application process.. I wish to modify this and make it return an SVG string to be used in the select statement..
    Is this possible?
    Thank you,
    Tony Miller
    UTMB/EHN

    The answer is in the last frame of you cartoon. Read it again.
    If you are letting users type if values that will be used unfiltered, you have a lot bigger problems on your hands than SQL insertion.
    Why are you letting operators type in their name? Never let operators type in their own name. In fact don't let users type at all except as a last resort.
    Likewise, lot number or id or whatever should not be typed. Selected, yes. Scanned, yes. But not typed.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Query for select statement

    Dear all
    is there any option in select statement to automatically generate serial number respect of data.
    for eg.
    1 101100110  shetal trade
    2 1110001178 CHEMICAL SOAP WORKS
    3..
    4..
    i don't  want to use loop (sy-tabix) ..
    thanks,
    Abhi

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • Create object type from multiple tables for select statement

    Hi there,
    I have 3 tables as given below and I wish to create an object type to group selected columns as 'attribute' from multiple tables. 
    I need to create 2 input parameters to pass in - 'attribute' and 'attribute value'  in PL/SQL and these 2 parameters will be
    passing in with 'column name' and 'column value'.  e.g. 'configuration' - the column name, 'eval' - the column value.
    Then, the PL/SQL will execute the select statement with the column and column value provided to output the record. 
    Pls advise and thank you.
    table ccitemnumber
    name                           null     type                                                                                                   
    ccitemnumber                   not null varchar2(20)                                                                                                                                                                                    
    configuration                           varchar2(20)
    item_type                               varchar2(30)
    table productmodel
    productmodelnumber             not null varchar2(6)                                                                                            
    description                             varchar2(60)  
    accesstimems                            number                                                                                                 
    numberofheads                           varchar2(2)
    generation                              varchar2(10)
    numberofdiscs                           varchar2(2)
    factoryapplication                      varchar2(150)
    table topmodel
    stmodelnumber                  not null varchar2(30)                                                                                           
    productfamily                           varchar2(60
    formfactor                              varchar2(10)                                                                                           
    modelheight                             varchar2(10)                                                                                           
    formattedcapacity                       number                                                                                                 
    formattedcapacity_uom                   varchar2(20)
    object type in database
    configuration                           varchar2(20)
    item_type                               varchar2(30)
    numberofheads                           varchar2(2)
    generation                              varchar2(10)
    numberofdiscs                           varchar2(2)
    factoryapplication                      varchar2(150)
    modelheight                             varchar2(10)
    formattedcapacity                       number                                                                                                 
    formattedcapac

    user12043838 wrote:
    Reason to do this as these fields are required to be grouped together as they are created in different tables. They are treated as 'attribute' (consists of many columns) of the part number. So, the PL/SQL is requested to design in a way able for user to pass in the column name and column value or part number, then the select statement should be able to query for the records. Another reason is a new column can be added easily without keep modifying those effected programs. Reuseable too.This basically equates to ... hard to code, hard to maintain, and poor performance.
    Are you really sure you want to do this? This isn't going to be easy-street as you seem to think it is, but it's a one way street to a poorly performing system with security vulnerabilities (google SQL Injection).
    I would highly recommend you reconsider your design decision here.

  • Special requirement for selection statement

    Hello expert,
    I have a table as follows:
    a b c d
    1 2 3 9
    5 2 3 9
    7 2 3 9
    1 3 4 1
    2 3 4 1
    5 3 4 1
    I want to get the result as follows:
    a b c d
    1 2 3 9
    5 2 3 0
    7 2 3 0
    1 3 4 1
    2 3 4 0
    5 3 4 0
    you can see for columns b/c/d, they duplicated, I want to compile a select statement to keep the first row for duplication, for other duplicaton, set the third column d as 0. please help me to implement it, appreciate very much.

    something like this maybe;
    with t as (
    select 1 a, 2 b, 3 c, 9 d from dual union all
    select 5, 2, 3, 9 from dual union all
    select 7, 2, 3, 9 from dual union all
    select 1, 3, 4, 1 from dual union all
    select 2, 3, 4, 1 from dual union all
    select 5, 3, 4, 1 from dual
    select a
          ,b
          ,c
          ,case when lag(d) over (partition by b,c order by d) = d then 0 else d end d
    from t
    /Edited by: bluefrog on Sep 9, 2011 5:48 PM

  • Restrict number of characters in table field for select statement.

    SELECT * FROM table
                    WHERE  column1  = z-column.
    The field column1 is of  type char and size 20
    The field z-column is of type char size 10.
    how do we perform this select?
    Anyone can guide me?
    Edited by: Hadesfx on Sep 11, 2009 3:56 PM
    Edited by: Hadesfx on Sep 11, 2009 3:59 PM

    Hello,
    In your OP did you mention this? Please be specific when you post the next time.
    Can you please post your code?
    I think you have to try a work around:
    DATA:
    RS_STOCKID TYPE SELOPT,
    RT_STOCKID TYPE STANDARD TABLE OF SELOPT.
    LOOP AT GT_ZB1PUT_STOCKTMP.
    RS_STOCKID-SIGN = 'I'.
    RS_STOCKID-OPTION = 'EQ'.
    RS_STOCKID-LOW = GT_ZB1PUT_STOCKTMP-STOCKID.
    APPEND RS_STOCKID TO RT_STOCKID.
    CLEAR RS_STOCKID.
    ENDLOOP.
    You can use this RANGE table to SELECT data from the table.
    SELECT * FROM zb1xxt_param
                FOR ALL ENTRIES IN gt_zb1put_stocktmp[]
                WHERE zzcode    = 'DEV036'
                AND   zzdomain  = 'SD'
                AND   zzdata    = 'INBOUND'
                AND   zzinput1  = 'STOCKID'
                AND   zzinput2  IN RT_STOCKID. "Use RT_STOCKID for SELECT'ing data
    BR,
    Suhas

  • Start new task for select statements

    Hi,
    I have question,
    I am trying to select documents from BKPF depending on selection screen,
    selection-screen:
    s_bukrs ____
    s_budat ____      ____
    s_monat ____      ____
    s_gjahr ____      ____
    for a particular CC for one month there are huge no or records, because of that its taking hrs and hrs to run. I am following the Indices and fields order , no into corresponding fields ...everything...its just because of no of records its taking time.. for those no of records I need to select item data from BSEG table which is more time consuming.....
    my question is
    I want to divide the 1 mon period into 4 weeks and select 4 times at a time in background task so that 4 work processers are used instead of 1.
    eg: if I give for 1 mon 01/01/2006 - 01/31/2006
    I want to split it into
    01/01/2006  01/08/2006
    01/09/2006  01/16/2006
    .           01/31/2006.
    select individually for these dates at a time into 4 Internal tables, I hope any one understood what I mean. Is that Possible ?
    Am I asking too much ?
    please let me know the solution.

    Hello,
    Note : write this program into separate include.
    If you want to divide 4 tasks here is the logic.
    1) Create 4 rangeas and fill dates i mean each range contains 1 week dates.
    do 4 times.
    2) *job open
      call function 'JOB_OPEN'
        exporting
          jobname  = p_job
        importing
          jobcount = l_jobcount.
    3) submit <b>zprogram_name</b> with s_date in  r_datum
                                   with s_kunnr in r_kunnr
                                via job p_job
                                number l_jobcount
                                and return.
    4) *job close
      call function 'JOB_CLOSE'
        exporting
          jobcount  = l_jobcount
          jobname   = p_job
          strtimmed = 'X'.
    enddo.
    Just execute new include in background it will create 4 back ground jobs (for 4 weeks) with in 5secs. Each job execute paralally offcourse depends on processes availablity.
    ********Poorna********

  • Why does plsql give compilation error for select statement?

    When I run following plsql program, it gives compilation error. Could somebody please point me out what could be wrong here? I am running it from system user.
    create or replace procedure drop_user_proc (iname in varchar2) is
    uname varchar2(100);
    begin
    select username into uname from dba_users where username = upper(iname);
    end drop_user_proc;
    select username from dba_users where username = upper('newuser');
    When I run it, I get following error. dba_users is there that is the reason it works outside plsql block, but it doesn't from inside block.
    SQL> @t4
    Warning: Procedure created with compilation errors.
    USERNAME
    NEWUSER
    SQL> show err
    Errors for PROCEDURE DROP_USER_PROC:
    LINE/COL ERROR
    4/3 PL/SQL: SQL Statement ignored
    4/35 PL/SQL: ORA-00942: table or view does not exist

    Role based grants are not available within the stored procedures.
    Only explicit grants are recognized when compiling stored code.
    You need to grant select on that table to the user where you are creating this procedure.

Maybe you are looking for

  • Which table I can get sales order no from delivery numbar.

    Hi, I want sales order no from delivery no. right now I am using table VBFA where I am passing VBELN and POSNN and geting sales order no. but performance of select query is very poor bcouse I am not passing first two key fields in the select query. I

  • A picture is worth a thousand words and all I want is a screen shot of the basic in-box

    I just want to see what a typical inbox will look like, eg date, sender, message, options like delete, folders, sent, etc

  • Direct question to Kappy,  OR others #2

    _Now ThiS is odd (to me), while waitng for the last little nudge needed on getting Deja Vu activated __(see hours old ignored post), i checked a coup'la folders in the clone, and it's already mirroring up~to~the~minute !, seemingly. I've specified no

  • Table creating error

    Hi All. I am working on an issue....there is one ztable named as zemp with the following fields: MANDT     MANDT     CLNT     3     0     Client ZNUM     ZNUM     CHAR     6     0     Employee number ZDATE     ZDATE     DATS     8     0              

  • Vlan Select & Layer 2 Multicast optimization

    I am going to implement this vlan select feature in my campus network. We are running on 7.3 & planning to move into 7.4 WLC code as well. I use below reference document for this task. WLC 7.2 VLAN Select and Multicast Optimization Features Deploymen