Check Index used in an oracle select query

Hi Friends,
I have partitioned an oracle table and created Local Index for the Partitioned table .
Now i want to make sure that the Local index is being used when i perform select query on the Table partition.
How do i confirm that ?
can i check the explain plan generted for the select query to confirm local index is being used ?
Please let me know.
Regards,
DB

Now i want to make sure that the Local index is being used when i perform select query on the Table partition.Why? Have you proven that using this local index is the "best" plan?
How do i confirm that ?
can i check the explain plan generted for the select query to confirm local index is being used ?When I asked Google "how to read an oracle explain plan," I found lots of information - what did you find?

Similar Messages

  • How can i use SUM aggregate in select query?

    HI,
    GURUS,
    How can i use SUM function in Select Query and i want to store that value into itab.
    for ex:
    TABLES: vbap.
    types: begin of ty_vbap,
           incluse type vbap,
           sum type string,
          end of ty_vbap.
    data: i_vbap type TABLE OF ty_vbap,
          w_vbap type ty_vbap.
    SELECT sum(posnr) FROM vbap into table i_vbap up to 5 rows.
                            (or)
    SELECT sum(posnr) FROM vbap into table i_vbap group by vbeln.
      loop at i_vbap into w_vbap
    " which variable have to use to display summed value.
      endloop.
    if above code is not understandable pleas give ome sample code on  above query.
    Thank u,
    shabeer ahmed.

    Hi,
    Check this sample code.
    TABLES SBOOK.
    DATA:  COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
    DATA:  CONNID LIKE SBOOK-CONNID.
    SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
           INTO (CONNID, COUNT, SUM, AVG)
           FROM SBOOK
           WHERE
             CARRID   = 'LH '      AND
             FLDATE   = '19950228'
           GROUP BY CONNID.
      WRITE: / CONNID, COUNT, SUM, AVG.
    ENDSELECT.
    Regards,
    Sravanthi

  • Using varchar record in SELECT query

    Hi, from a VARCHAR field I get the string ",1,2,3,4,5,6,".
    I wish to use it in a SELECT query like:
    SELECT * FROM TABLE WHERE ID IN (1,2,3,4,5,6)
    Is there a way to obtain this in a tsql query ?
    Thank you
    Stefano

    CREATE TABLE t1
     col1 INT NOT NULL PRIMARY KEY,
     col2 VARCHAR(50) NOT NULL
    INSERT INTO t1 VALUES (1,'10,11,12')
    INSERT INTO t1 VALUES (2,'13')
    INSERT INTO t1 VALUES (3,'14,15')
    CREATE TABLE t2
     col1 INT NOT NULL PRIMARY KEY,
     col2 VARCHAR(50) NOT NULL
    INSERT INTO t2 VALUES (10,'A')
    INSERT INTO t2 VALUES (11,'B')
    INSERT INTO t2 VALUES (12,'C')
    INSERT INTO t2 VALUES (13,'D')
    INSERT INTO t2 VALUES (14,'E')
    INSERT INTO t2 VALUES (15,'F')
    SELECT DISTINCT O.col1, O.col2
    FROM t1 T
       INNER JOIN t2 O
          ON (PATINDEX('%,' + CAST(O.col1 AS varchar(10)) + ',%',
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Using buffering option in select query

    Hi All,
           Can anybody give me a brief idea on , where we will use the buffering and how we will write it in coding part.Similarly please tell me what will happen if we use  by passing buffering  addition in select query. Please explain  it with steps of sample code if possible.
    Thanks in advance.
    Regards,
    Rakesh.

    Hi Sharma,
    Buffer is used to hold large amount of data.
    if internla table is unable to hold data.. Buffer is used..this is mainly used in copy data from PRD to Quality as a part testung.
    see the sample code how the buffer is used..
    FUNCTION zzrfc_get_zcpeg_fg_related.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(PL_VERSION) LIKE  ZCPEG_FG_RELATED-PL_VERSION OPTIONAL
    *"     VALUE(BYPASS_BUFFER) LIKE  SY-FTYPE DEFAULT SPACE
    *"     VALUE(FROM_KEY) LIKE  SY-ENTRY DEFAULT SPACE
    *"     VALUE(GEN_KEY) LIKE  SY-ENTRY DEFAULT SPACE
    *"     VALUE(MAX_ENTRIES) LIKE  SY-TABIX DEFAULT 0
    *"     VALUE(TABLE_NAME) LIKE  X030L-TABNAME
    *"     VALUE(TO_KEY) LIKE  SY-ENTRY DEFAULT SPACE
    *"  EXPORTING
    *"     VALUE(NUMBER_OF_ENTRIES) LIKE  SY-INDEX
    *"  TABLES
    *"      ENTRIES STRUCTURE  ZCPEG_FG_RELATED
    *"  EXCEPTIONS
    *"      INTERNAL_ERROR
    *"      TABLE_EMPTY
    *"      TABLE_NOT_FOUND
      TABLES dd02l.
      DATA: BEGIN OF buf OCCURS 100,
                line(4100),
            END OF buf.
      DATA keyln TYPE i.
      DATA: l_tabname LIKE dd25v-viewname.
      DATA: l_len     TYPE i.
      DATA : w_plversion TYPE /sapapo/vrsioex.   "PJONNALA
      w_plversion =  pl_version.                 "PJONNALA
      l_tabname = table_name.
      CALL FUNCTION 'VIEW_AUTHORITY_CHECK'
        EXPORTING
          view_action                = 'S'
          view_name                  = l_tabname
          no_warning_for_clientindep = 'X'
        EXCEPTIONS
          OTHERS                     = 6.
      IF sy-subrc <> 0.
        RAISE internal_error.
      ENDIF.
      IF bypass_buffer NE ' ' AND bypass_buffer NE 'N'.
        bypass_buffer = 'Y'.
      ENDIF.
      IF gen_key CA ' '. ENDIF.
      keyln = sy-fdpos.
    * read client dependant tables always with client
      SELECT SINGLE * FROM dd02l WHERE tabname = table_name
                                  AND as4local =  'A'.
      IF dd02l-clidep = 'X'.
    *l_len = strlen( sy-mandt ) * cl_abap_char_utilities=>charsize.
    *  " ecwg. unicode
    *    move gen_key to gen_key+l_len.
    *    move sy-mandt to gen_key(l_len).
    *    add l_len to keyln.
        CONCATENATE sy-mandt gen_key INTO gen_key.
        keyln = STRLEN( gen_key ) * cl_abap_char_utilities=>charsize.
      ENDIF.
    *  endselect.
      IF keyln NE 0 OR from_key = space.
        CALL 'C_GET_TABLE' ID 'TABLNAME'  FIELD table_name
                           ID 'INTTAB'    FIELD buf-*sys*
                           ID 'GENKEY'    FIELD gen_key
                           ID 'GENKEY_LN' FIELD keyln
                           ID 'DBCNT'     FIELD number_of_entries
                           ID 'BYPASS'    FIELD bypass_buffer.
      ELSE.
        CALL 'C_GET_TABLE' ID 'TABLNAME'  FIELD table_name
                           ID 'INTTAB'    FIELD buf-*sys*
                           ID 'FROM_KEY'  FIELD from_key
                           ID 'TO_KEY'    FIELD to_key
                           ID 'DBCNT'     FIELD number_of_entries
                           ID 'BYPASS'    FIELD bypass_buffer.
      ENDIF.
      CASE sy-subrc.
        WHEN 4.  RAISE table_empty.
        WHEN 8.  RAISE table_not_found.
        WHEN 12. RAISE internal_error.
      ENDCASE.
      DESCRIBE TABLE buf LINES number_of_entries.
    ENDFUNCTION.
    Regards,
    Prabhudas

  • Using DB Links - Improving SELECT query performance

    Hi there,
    I am using dblink in the following query:
    I would like to improve performance of the query by using hints as per described in the link: http://www.experts-exchange.com/Database/Oracle/9.x/Q_23640348.html. However, i am not sure how can i include this in my select query.
    Details are:
    Oracle - 9i Database Terminal Release .8
    DB Link: TCPROD
    Could someone please explain with an example how to use hints to get the query to select data on the remote database and then return the results to the target database?
    Many Thanks.
    SELECT ec.obid AS prObid,
                 ec.b2ProgramName AS program,
                 ec.projectName AS project,
                 ec.wbsID AS prNo,
                 ec.wbsName AS title,
                 ec.revision AS revision,
                 ec.superseded AS revisionSuperseded,
                 ec.lifeCycleState AS lifeCycleState,
                 ec.b2ChangeType AS type,
                 ec.b2Complexity AS subType,
                 ec.r1SsiCode AS ssi,
                 ec.b2disposition as disposition,
                 ec.wbsOriginator AS requestor,
                 ec.wbsAdministrator AS administrator,
                 ec.changepriority as priority,
                 ec.r1tsc as tsc,
                 ec.t1comments as tenixComments,
                 ec.b2securityclass as securityClassification,
                 ec.t1changesafety as safety,
                 ec.t1actionofficer as actionOfficer,
                 ec.t1changereason as changeReason,
                 ec.t1wbsextchangenumber as extChangeNo,
                 ec.creator as creator,
                 to_date(substr(ec.creationdate,
                                0,
                                instr(ec.creationdate, ':', 1, 3) - 1),
                         'YYYY/MM/DD-HH24:MI:SS') as creationdate,
                 to_date(ec.originatorassigndate, 'YYYY/MM/DD') as originatorassigndate,
                 zbd.description as description,
                 zbc.comments as comments
            FROM (SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM awdbt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM mart1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM mpsdt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM nondt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rnast1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rnlht1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rnolt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rzptt1m4.cmPrRpIt@TCPROD

    it's the tablename in the hint, not the column name
    something like
    SELECT ec.obid AS prObid,
                 ec.b2ProgramName AS program,
                 ec.projectName AS project,
                 ec.wbsID AS prNo,
                 ec.wbsName AS title,
                 ec.revision AS revision,
                 ec.superseded AS revisionSuperseded,
                 ec.lifeCycleState AS lifeCycleState,
                 ec.b2ChangeType AS type,
                 ec.b2Complexity AS subType,
                 ec.r1SsiCode AS ssi,
                 ec.b2disposition as disposition,
                 ec.wbsOriginator AS requestor,
                 ec.wbsAdministrator AS administrator,
                 ec.changepriority as priority,
                 ec.r1tsc as tsc,
                 ec.t1comments as tenixComments,
                 ec.b2securityclass as securityClassification,
                 ec.t1changesafety as safety,
                 ec.t1actionofficer as actionOfficer,
                 ec.t1changereason as changeReason,
                 ec.t1wbsextchangenumber as extChangeNo,
                 ec.creator as creator,
                 to_date(substr(ec.creationdate,
                                0,
                                instr(ec.creationdate, ':', 1, 3) - 1),
                         'YYYY/MM/DD-HH24:MI:SS') as creationdate,
                 to_date(ec.originatorassigndate, 'YYYY/MM/DD') as originatorassigndate
            FROM (SELECT /*+ DRIVING_SITE(awdbt1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM awdbt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(mart1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM mart1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(mpsdt1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM mpsdt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(nondt1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM nondt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(rnast1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rnast1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(rnlht1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rnlht1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(rnolt1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rnolt1m4.cmPrRpIt@TCPROD
                  UNION
                  SELECT /*+ DRIVING_SITE(rzptt1m4.cmPrRpIt) */ obid,
                         b2ProgramName,
                         projectName,
                         wbsID,
                         wbsName,
                         revision,
                         superseded,
                         lifeCycleState,
                         b2ChangeType,
                         b2Complexity,
                         r1SsiCode,
                         b2disposition,
                         wbsOriginator,
                         wbsAdministrator,
                         changepriority,
                         r1tsc,
                         t1comments,
                         b2securityclass,
                         t1changesafety,
                         t1actionofficer,
                         t1changereason,
                         t1wbsextchangenumber,
                         creator,
                         creationdate,
                         originatorassigndate
                    FROM rzptt1m4.cmPrRpIt@TCPROD) ec(not tested, of course)

  • Logical operators in Oracle select query

    Hello all,
    Can i use logical operators in oracle select queries?
    for 1 and 0 =0 ; 1 or 0 =0
    if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.
    Is there any way to use select col1 or col2 from table? where or is a logical operator?
    Regards,

    Hi,
    NB wrote:
    Hello all,
    Can i use logical operators in oracle select queries?Sure; Oracle has the logical operators AND, NOT and OR. All the comparison operators, including >, >=, = !=, EXISTS, IN, IS NULL, LIKE and REGEXP_LIKE are really logical operators, since they return logical values. You can use them in SELECT statements, and other places, too.
    for 1 and 0 =0 ; 1 or 0 =0
    if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.It's unclear what you want. Maybe you'd be interested in the BITAND function:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions014.htm#sthref1080
    BITAND is the only logical function that I know of. Many other functions, especially numberical fucntions such as MOD, have applications in logic.
    Is there any way to use select col1 or col2 from table? where or is a logical operator?Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements), and also post the results you want from that data.
    Explain how you get those results from that data.
    Always say which version of Oracle you're using.

  • Sample XML format that can be used to write a SELECT query

    Hello,
    I want to use and XML file in the scenario FILE to JDBC where i use the operation as SELECT in which i want to embbed an sql statemnet which is equivalent to
    SELECT EMPNO, NAME FROM EMPLOYEE WHERE EMPNO>1
    as in the form of XML format like,
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_JDBC_SELECT_JDBC_REQ xmlns:ns0="http://JDBC_SELECT">
    <STATEMENT>
    <TABLENAME ACTION="SELECT">
    <TABLE>EMPTEST</TABLE>
    <ACCESS>
    <EMPNO></EMPNO>
    <NAME></NAME>
    </ACCESS>
    <KEY>
    <EMPNO compareOperation="GT">1</EMPNO>
    </KEY>
    </TABLENAME>
    </STATEMENT>
    </ns0:MT_JDBC_SELECT_JDBC_REQ>
    Can i do like this?
    PLease help me out in using various conditions in the XML file formats like the above.
    Thanks,
    Soorya.

    Hello raj,
    I would like to write the query in that format where i mentioned as,
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_JDBC_SELECT_JDBC_REQ xmlns:ns0="http://JDBC_SELECT">
    <STATEMENT>
    <TABLENAME ACTION="SELECT">
    <TABLE>EMPTEST</TABLE>
    <ACCESS>
    <EMPNO></EMPNO>
    <NAME></NAME>
    </ACCESS>
    <KEY>
    <EMPNO compareOperation="GT">1</EMPNO>
    </KEY>
    </TABLENAME>
    </STATEMENT>
    </ns0:MT_JDBC_SELECT_JDBC_REQ>
    without giving clear SQL statement as you mentioned here like,
    <ns0:MT_JDBC_SELECT_JDBC_REQ xmlns:ns0="http://JDBC_SELECT">
    <STATEMENT>
    <TABLENAME ACTION="SQL_QUERY">
    <ACCESS>SELECT EMPNO, NAME FROM EMPLOYEE WHERE EMPNO > '$EMPNO$’</ACCESS>
    <KEY>
    <EMPNO>1</EMPNO>
    </KEY>
    </TABLENAME>
    </STATEMENT>
    </ns0:MT_JDBC_SELECT_JDBC_REQ>
    Thanks,
    Soorya

  • How can i use param in my select query ( see code)

    Hi ,
    I need to use the param instead of hardcoding the value in the select query , when i did that it is working .
    I think the limit of args is only till the end of main and my select query is in a method called Load() .
    How can i use the param in my select query .
    public static void main(String[] args){
    name = args[0];
    class= args[1];
    new Load();
    }//end of main
    public Load()
              try {
                   Class.forName(JDBC_DRIVER);
                   connection = DriverManager.getConnection(DATABASE_URL,"username","pw");
                   statement = connection.createStatement();
                   //First Query : pin and ticket number
                   ResultSet resultSet = statement.executeQuery("SELECT pin , ticketnumber from airport ,year where "+                                                                      "year.year_name= Here i need to use the param (instead of hardcoding) and year.class_year= Here too i need to use param");
    }// end of method Load()Edited by: 1sai on Sep 24, 2008 7:34 AM
    Edited by: 1sai on Sep 24, 2008 7:35 AM

    Might I suggest you change the structure of your program to the following:
    public class Load {
      private Connection conn;
      private PreparedStatement statement;
      public Load(String sql) {
        init(sql);
      protected void init(String sql) throws Exception {
        Class.forName(JDBC_DRIVER);
        conn = DriverManager.getConnection(DATABASE_URL, "username", "pw");
        statement = conn.prepareStatement(sql);
      public ResultSet execute(String p1, String p2) throws Exception {
        statement.setString(1, p1);
        statement.setString(2, p2);
        return statement.executeQuery();
      public void close() throws Exception {
        if (statement != null)
          statement.close();
        statement = null;
        if (conn != null)
          conn.close();
        conn = null;
      public static void main(String[] args) throws Exception {
        String sql = args[0];
        String param1 = args[1];
        String param2 = args[2];
        Load load = new Load(sql);
        ResultSet rs = load.execute(param1, param2);
        while (rs.next())
          System.out.println(rs.get(0));
        rs.close();
        load.close();
    }This allows you to use the same "Load" object for multiple queries with different parameters.
    I do not recommend you actually use the code above in any sort of production application. You should really take a look at Spring Framework along with an ORM tool like Hibernate or Ibatis to simplify your DAO layer.
    Hope this helps,
    David

  • Is there a way to use owa_opt_lock.checksum in Select query that returns multiple records?

    Trying to do something as data would be uploaded and edited in grid. At present I am using Ora_Hash.
    SELECT
            e.ROWID, e.Employee_Id,e.First_Name,e.Last_Name,e.Email,e.Phone_Number,e.Hire_Date,
            e.Job_Id,e.Salary,e.Manager_Id,e.Department_Id,
            owa_opt_lock.checksum('HR','EMPLOYEES', e.rowid) As HashForThisRow
    FROM EMPLOYEES e;
    Thx

    No you can't.
    owa_opt_lock.checksum is a function which is used for optimist locking. It locks the row(probably by using Select FOR Update mechanism) which you select and which you are trying to update. As a result, what you are eventually trying to do is that inside a Select query you are using a function that is locking the rows, which is not allowed. And thus your query will fail with the below mentioned error.
    ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "SYS.DBMS_SQL", line 1575
    ORA-06512: at "SYS.OWA_OPT_LOCK", line 172
    14551. 00000 -  "cannot perform a DML operation inside a query "
    *Cause:    DML operation like insert, update, delete or select-for-update
               cannot be performed inside a query or under a PDML slave.
    *Action:   Ensure that the offending DML operation is not performed or
               use an autonomous transaction to perform the DML operation within
               the query or PDML slave.
    Thanks,
    Ishan

  • 2 set of conditions to use in a Single Select query in procedure

    Good day
    I have one procedure, want to use one 2 set of conditions in Where clause
    like
    where condition1 < value
    AND condition 2 > value
    AND condition 3 = value
    where condition 1 > value
    AND condition 2 < value
    AND condition 4 = value
    How we should combine in a single select statement where cluase.
    Please accept my sincere thanks first and looking your advice asap.
    Regards
    M.K.Thamaraiselvan

    Hi,
    While we use this procdure to run at that time it is not picking up any values also it is not running in it, taking very long time.What is not picking the value? Where clause is not picking the value, or
    where clause is picking the value but you are not getting the output.
    If it is you are not getting the output.
    I suggest to run the sql query individually without pl/sql and check if the records actually exist.
    Since it is taking very long time, I feel the sql query is actually being executed in the database but could be you are not getting the records (check if records actualy exist or if you are correctly passing the where clause)
    Regards
    Anurag
    PS:
    v_sql_string := 'SELECT table/viewname.colomn_name,'||v_order_by||','||v_report_line ||','||
    v_output_line||',table/viewname.check_amount'||v_from_clause||v_where_clause||' ORDER BY '||v_order_by;So you are using dynamic sql, can you add an extra line
    dbms_output.put_line(v_sql_string);
    and check what the actual query is formed by pl/sql, if you are satisified the query is correct run it through sql plus and check why oracle does not give the result. MAy be there is no records satisfiying this condition. And I am sure you meant either table or viewname in (table/viewname.colomn_name) and not something like what you posted.
    Edited by: Anurag Tibrewal on Oct 8, 2009 9:15 AM

  • Index used or not for selecting data from ODS in a start routine

    Dear friends,
    In the start routine of the update rules to a cube, I am reading some data of an ODS in to an internal table .
    The ODS is indexed. But, I am not sure if the index is at all used in the Select statement (that gets the data from ODS to the internal table in the start routine) while loading data to the cube.
    Any help is highly appreciated.
    regards,
    atlaj

    Hi Atlaj
    You can findout this is display execution plan for SQL statement in DB02.
    Goto DB02. and under diagnostic, you find explain. Select that and enter your query. Make sure that everything here is in capital format. Below is a sample query which I have entered.
    SELECT "CRM_SALORG" "SALESORG" FROM "/BI0/QORGUNIT"
    WHERE "SALESORG" = ? AND "OBJVERS" = ? AND "DATETO" >= ?
    AND "DATEFROM" <= ?
    The select parameters should be inside qoutes and in caps and even the from table. Once you enter your query in this format, click on explain. It will show the index scan if the index is present. the output for my query will be something like
    0 SELECT STATEMENT ( Estimated Costs =  1,348E+01 [timerons] )
            1 (COOR) RETURN
                2 (    0) TQ
                    3 (    0) FETCH /BI0/QORGUNIT
                        4 (    0) IXSCAN /BI0/QORGUNIT~Z1
    Where my last statement (line 4) is showing index scan and the name of index read is Z1.
    Hope this helps.
    Please let me know if you have any problems entering the query in the specified format and u get any error.
    Regards
    Sriram

  • Using parameters in a select query sometimes not working

    I use parameters throughout my code - usually without problem, but for some reason in one case it does not return a result. When I modify the querystring to contain the value instead of using parameters it works. Is it because I'm secting a clob? or is it because I'm using a 9i ODP.net dll against a 10g database? this is c# 2.0
    here's the source code that does not work for me - REQUEST_DATA is a clob:
        public String loadRequest(String PSRNumber)
            String returnVal = null;
            ConnectionStringSettings connectionInfo = System.Configuration.ConfigurationManager.ConnectionStrings["Scribe"];
            OracleConnection myConnection = new OracleConnection();
            String strSQL = "select PSR, REQUEST_DATA from stats.request where PSR = :PSR";
            try
                myConnection.ConnectionString = connectionInfo.ConnectionString;
                OracleCommand cmd = new OracleCommand(strSQL, myConnection);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("PSR", OracleDbType.Varchar2).Value = PSRNumber;
                myConnection.Open();
                OracleDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                    returnVal = dr.GetOracleString(dr.GetOrdinal("REQUEST_DATA")).ToString();
                else
                    returnVal = null;
                dr.Dispose();
                cmd.Dispose();
            catch (OracleException ex)
                printError(ex.Message);
            finally
                myConnection.Close();
                myConnection.Dispose();
            return returnVal;
        }when I replace the line generating the sql, and remove the lines pertaining to parameters it works:
    String strSQL = String.Format("select PSR, REQUEST_DATA from stats.request where PSR = {0}", PSRNumber);
    I'm fine just using this as a workaround, but I need an explanation why the other does not work - I prefer to use parameters.
    Message was edited by:
    user633546

    I figured it out. thank you for your help in pointing me in the right direction.
    the problem was there was a trailing space in the data.
    when the data for that table is numeric for every record, the query allows me to leave out the single quotes. Trailing spaces do not seem to cause the database to see it as non-numeric - leaving out the quote still finds the record even if there is a trailing space.
    but when I put in the quote, it is not an exact string match, so it could not find the record. sometimes this flexibility gets me into trouble :\

  • Using command button to select query - WAD 7.0

    Hello all
    Can anyone please tell me how to configure a command button (button group) to display a particular query in WAD 7.0?
    Here's what I mean -
    I have a web template with three queries. I have inserted 3 command buttons on the template. I want to assign one button to one query, so that the users can select which of the three they want to view. Which Command do I select in the command wizard to do this? Also, is it possible to hide the other two queries, when one is selected?
    Thanks
    Karen

    Hi,
    Here is one approach - Keep three analysis items in the WT. Assign three different data providers to all three analysis items. If you do not want to show any query when the WT first loads, don't assign any query to the data providers. When a button is pushed, you can use the command SET_DATA_PROVIDER_PARAMATERS to assign a query to a DP so that that query will show up.
    Other commands that will help you would be SET_ITEM_PARAMETERS using which you can hide analysis items and also, you can use the command BACK_TO_INITIAL_DP_STATE on data providers so that they do not show up if they were blank at the start.
    Another way to hide a query is to assign the analysis item to a data provider which is blank.
    For your requirements, you will have to put multiple commands behind each button - you can decide which of the above commands suit you best.

  • Runtime error using range table in select query

    I have to select tcodes from table tstc, based on the entries in ust12,
    the entries in ust12-von and ust12-bis, these contains wild charcters also,  and i have to selct all the tcodes  from von to bis.
    so ia m preparing a range table for the entries in ust12, and querying table tstc, then i am getting a runtime error with following description.
    'If the problem occurred because an excessively large table was used
    in an IN itab construct, you can use FOR ALL ENTRIES instead.'
    but how can i use FOR ALL ENTRIES here, because if von = A* and bis = AB*,then i ahve to read all the entries from AAAA till ABZZ (may be something like this),
    is there any way to write this query, with out runtime error.
    there are total 15000 entries in ust12, i am preparing range table for 3000 entries each and querying tstc.
    Thanks in advance
    Best Regards
    Amarender Reddy B

    Hi,
    first write a select on ust12 based on ust12-von and ust12-bis.
    eg: select von bis from ust12 into table gt_ust12
                               where von LIKE 'A%'
                                   and bis LIKE 'AB%'.
    now write another select for tstc for all entries in gt_ust12...
    Hope it helps
    Regards,
    Pavan

  • Using this (~) symbol in select query ?what does this mean?

    Suppose
    SELECT   mapl~vbeln INTO IT_TAB mean what? also is this obsolete practice or still existing?
    Thank you for your time and answers in advance !

    It is used when alias name is used instead of actual table name. You don't have to use join in order to use alias.
    See ABAP Keyword Documentation and this:
    DATA lv_cityfrom TYPE spfli-cityfrom.
    SELECT SINGLE cityfrom FROM spfli AS a 
      INTO lv_cityfrom WHERE a~carrid EQ 'AA'.
    IF sy-subrc EQ 0.
      WRITE lv_cityfrom.
    ENDIF.

Maybe you are looking for

  • Devices with Removable Storage - not being read or recognized.

    Good morning: My PC is HP Pavilion m7640n. Specifically LITE-ON DVDRW SHM-165H6S is not reading DVDs or CDs. Tried to download driver but there are instructions I do not understand involving a required CD. Any thoughts about why the "Devices with Rem

  • How to assigne transaction Variant to Report

    Dear Hcm Gurus: i have to develop a report by using infoset query and also assigned transaction via se93 Report is alv-based. so when i access report through t-code "ZHR_STAFF" and  save variant /default then this variant not outcome with desired res

  • How do I handle this in .htaccess?

    Hi guys, How would I go about setting up a .htaccess file that forwards all requests to the root of the .com to another url, while maintaining all the beyond-the-root urls right where they are? Example : test.com -> forwarded to target.com test.com/h

  • Software Design best Practices

    Background: I have an existing J2EE web application in place with an Oracle 11 db and a WebSphere app server. The database is about 400 GB, has about 500 tables, and is usually processing about 35 db transactions per second. The average “web transact

  • Network - Windows 7 PC can see Windows 8.1 laptop - but not vice versa

    Laptop (Windows 8.1) & PC (Windows 7) When I bought the laptop, I hooked up the Network/Homegroup and everything was fine.  Two weeks ago my Laptop suddenly stopped seeing my PC (but my PC still sees the laptop fine). After scouring the internet, per