Select query for single record

hi all,
i am working for script which is letter.
i had to extract the fields as shown in the code. from two tables i had to extract single record. and pass this values to script.i developed the code. wen i execute the code its going to dump. can any body help me.
TABLES : VBAK, KNA1.
PARAMETERS : p_vbeln LIKE vbak-vbeln.
Data : name like kna1-name1.
Data: begin of wa_vbak ,
     vbeln(10),
       netwr(15),
       bstdk(8),
       kunnr(10),
       smenr(8),
       end of wa_vbak.
Data: begin of wa_final,
       vbeln(10),
       netwr(15),
       bstdk(8),
       kunnr(10),
       smenr(8),
       name1(35),
       end of wa_final.
       Select single vbeln
                     netwr
                     bstdk
                     kunnr
                     smenr from vbak
                     into wa_vbak where vbeln = p_vbeln.
    If sy-subrc = 0.
       Select single name1 from kna1 into name  where kunnr  =  wa_vbak-kunnr.
    If sy-subrc = 0.
      Move wa_vbak-vbeln to wa_final-vbeln.
      Move wa_vbak-netwr to wa_final-netwr.
      Move wa_vbak-bstdk to wa_final-bstdk.
      Move wa_vbak-kunnr to wa_final-kunnr.
      Move wa_vbak-smenr to wa_final-smenr.
      Move name to wa_final-name1.
    endif.
    endif.
    write:/10 wa_final-vbeln, 20 wa_final-netwr.
thanks
venkat

Hai,
Make sure that field names(itab) are same as database tables.
And also INTO CORRESPONDING FIELDS OF TABLE .
The modified code is as below:
TABLES : VBAK, KNA1.
PARAMETERS : p_vbeln LIKE vbak-vbeln.
Data : name like kna1-name1.
Data: begin of wa_vbak ,
vbeln(10),
netwr(15),
bstdk(8),
kunnr(10),
smenr(8),
end of wa_vbak.
Data: begin of wa_final,
vbeln(10),
netwr(15),
bstdk(8),
kunnr(10),
smenr(8),
name1(35),
end of wa_final.
Data:
  T_wa_vbak like standard table of  wa_vbak.
Select single vbeln
netwr
bstdk
kunnr
smenr from vbak
into <b>CORRESPONDING FIELDS OF TABLE T_</b>wa_vbak where vbeln = p_vbeln.
If sy-subrc = 0.
Select single name1 from kna1 into name where kunnr = wa_vbak-kunnr.
If sy-subrc = 0.
Move wa_vbak-vbeln to wa_final-vbeln.
Move wa_vbak-netwr to wa_final-netwr.
Move wa_vbak-bstdk to wa_final-bstdk.
Move wa_vbak-kunnr to wa_final-kunnr.
Move wa_vbak-smenr to wa_final-smenr.
Move name to wa_final-name1.
endif.
endif.
write:/10 wa_final-vbeln, 20 wa_final-netwr.
Regards,
Rama chary.Pammi

Similar Messages

  • Select Query for smart form-invoice

    Hi Folks,
    I have to fetch the following fields as per the requirement for desiging a invoice smartform.I had copied lb_bill_invoice smartform into z format.
    Can anyone here please give me the select query for the same.
    fields to fetched are as follows:-
    1.vbrp-arktx,
    2.vbrp-fkimg,
    3.konv-kbetr with respect to vbrk-knumv
    4.konv-kwert.
    And also what all I have to give in format interface and global definitions of the smartform.
    please help  me in this regard.
    Points will be given.
    K.Kiran.

    Hi,
    declare the variables V_arktx(40) and v_Qty like vbrp-fkimp  and other varaibles for Kbetr, kwert, knumv on the global definitions.
    select  single arktx fkimg into (v_arktx, v_qty) from vbrp
    where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
    select single knumv into v_knumv from vbrk where where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
    this select has to fire in the item level and in the loop.
    so have to write in the correct place.
    select kbetr kwert into (v_kbetr, v_kwert) from konv
    where where knumv = v_knumv and kposn = LBBIL_IT_REFPURORD-ITM_NUMBER.
    regards,
    anji

  • Can any one send select query for this?

    Hi,
    can any one plese send select query for the following query.please send as early as possible.
    Loop through the I_BSID internal table to fill records in I_OUTPUT.Combine data from I_BSID, I_KNKK, I_KNKK_KNKLI, I_KNA1 and I_KNVV into I_OUTPUT based on the linking conditions .Field Description Source are
    I_OUTPUT-BUKRS     Company code     I_BSID-BUKRS
    I_OUTPUT-KUNNR     Customer number     I_BSID-KUNNR
    I_OUTPUT-NAME1     Customer Name     I_KNA1-NAME1
    I_OUTPUT-KNKLI     Credit account     I_KNKK-KNKLI
    I_OUTPUT-KDGRP     Customer Group     I_KNKK-KDGRP
    I_OUTPUT-KLIMK     Credit Limit     I_KNKK_KNKLI-KLIMK
    I_OUTPUT-KVGR1     Business Unit     I_KNVV-KVGR1
    I_OUTPUT-REBZG     Invoice Number     I_BSID-REBZG
    I_OUTPUT-BLDAT     Invoice Date     I_BSID-BLDAT
    I_OUTPUT-WAERS     Document Currency     I_BSID-WAERS
    I_OUTPUT-DUE_DATE     Due Date     Based on below
    Calculation
      Get the Payment terms days combining I_BSID and I_T052 based on the linking conditions mentioned above.    Note : a) Baseline Date : If baseline date I_BSID-ZFBDT is blank , use the Document Date.b) Payment Term Days :If I_BSID-ZBD3T is not blank, take this as Payment Term Days for Due date calculation.
                       If I_BSID-ZBD3T is Blank, then get payment term days from I_T052 based on I_BSID-ZTERM. If there are more than one record in I_T052 for the given Payment term, get the day part from baseline date and select the first record where the day limit I_T052-ZTAGG is greater than the day part.If I_BSID-ZBD3T is blank and I_BSID-ZTERM is also blank, then take Y000 (Due Immediately) as Payment term and proceed with the above logic. Set the payment term field blank while printing.
    Calculate Due date : For Debits, Determine Due Date = Baseline Date + Payment term Days(not discount days)                                                          For  Credits  Due date = Baseline date.Then, move the amount I_BSID-DMBTR to respective buckets (Not yet Due, Current Due, Past due 1-30, Past Due 31-60 etc.)  Based on the due date.
    Thanks&Regards,
    praveen kumar.A

    HI,
    To get Open Items you can use Function module:
    data:i_items TYPE STANDARD TABLE OF rfpos.
    CALL FUNCTION 'CUSTOMER_OPEN_ITEMS'
    EXPORTING
    bukrs = p_bukrs
    kunnr = wa_customer-kunnr
    TABLES
    t_postab = i_items
    EXCEPTIONS
    no_open_items = 1
    OTHERS = 2.
    Table I_items will have all the open items for that Customer in the given company code.
    Well for Clear Items: Try
    GET_CLEARED_ITEMS or FMITPOFM_CLEARED_ITEMS_GET.
    Hope it helps.
    Manish

  • Select query for fetching from 3 tables.

    Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
    from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
    Regards,
    Shashank.

    Hi,
    If you have kunnr field in all the 3 tables then it is possible. use inner join as below
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    SELECT c~carrname p~connid f~fldate
           INTO CORRESPONDING FIELDS OF TABLE itab
           FROM ( ( scarr AS c
             INNER JOIN spfli AS p ON p~carrid   = c~carrid
                                  AND p~cityfrom = p_cityfr
                                  AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON f~carrid = p~carrid
                                    AND f~connid = p~connid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    <b>Reward Points if this helps,</b>
    Satish

  • Query  for getting records  max  reported  timestamp and 2nd max report

    query for getting records in between
    max reported timestamp and 2nd max reported timestamp
    HERE IS ALL RESULT SET
    TIME DOMAIN
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    QUERY RESULT TO COME
    TIME DOMAIN
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    Message was edited by:
    user517983

    Hi,
    can we write query like this.
    1 select pd_user,PD_REPORTED_TIMESTAMP
    2 from sp_process_detail_current spdc
    3 where host_id='DSCP02469'and pd_user='TOMCAT'
    4 and exists(
    5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
    6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
    SQL> /
    PD_USER PD_REPORTED_TIMESTAM
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45

  • How to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

  • Select query for every 1000 records

    Hi all ,
             Please help me in the issue . I am using select query Select * from table up to 1000 rows for acheving the records but i want this process to retrigger once the process of 1000 records is compleded again it needs to fetch the next 1000 records and process the same . I am changing the status of the processed records once it is processed . Can can one tell me how to retrigger the select query once the 1000 records are processes.
    Thanks in advance,

    Hi Eric,
                  After selecting the 1000 records, find the key value of the last record. Build up the range as GT. Again use the select query.
    For example,
    Select * into table lt_data from ztab
    where key in r_key
    up to 1000 rows.
    regards,
    Niyaz

  • Lock record on query for single user

    Is there any way to use the on-lock trigger to lock a particular record as it is simply queried, instead of after a change has been made to it. For instance, if user A is viewing a queried record, and user b attempts to query the same record, then we would display a message to user b stating that the record is unavailable, or simply just skip it. I know that if a field in the current record is altered, forms recognizes the status of the record as 'CHANGED' and will then by default proceed to lock the record until a commit or rollback is issued. However, this is not what we are looking for. I have read a little about this, and I have seen an example through a datablock based upon a stored procedure, a ref cursor select for update statement. (NOTE: we are not basing our datablock on a stored procedure though)
    We have two scenarios that require this type of locking capability. The first simply queries one distinct record, and the second queries a distinct result of records.
    A select for update statement would suffice for the first scenario, i.e. if another user tries to query the same record, their query is denied; however, for the second scenario when two users perform the same query, user a is viewing record #1, and user b's program sees that record #1 is 'locked' and thus proceeds to the next record in the result .
    Any suggestions? Thanks in advance.
    Eric M Weiss

    You don't need to override on-lock you can just call the LOCK_RECORD built-in in POST-QUERY or whatever.

  • Select Query Fetching same records multiple time

    Hi ABAPers,
    I have an issue where the select query is fetching the same records more than one time for particular sale order.
    Kindly help to solve the issue.
    Thanks in advance..
    Here is the Select Query:-
    SELECT  VBAK~VKORG VBAK~VTWEG VBAK~VBELN VBAK~KUNNR
                   VBAK~ERDAT VBAK~LIFSK VBKD~INCO1 VBKD~INCO2
                   VBAP~MATNR VBAP~ARKTX VBAP~MATKL VBAK~BSTNK
                   VBAK~BSTDK VBAK~KNUMV VBAP~UEPOS VBAP~POSNR
                   VBAP~KWMENG VBAK~VDATU VBAP~VRKME VBAK~ERNAM VBAK~WAERK
      INTO CORRESPONDING FIELDS OF TABLE IT_PENDING FROM VBAK
      INNER JOIN VBAP ON VBAK~VBELN = VBAP~VBELN
      INNER JOIN VBKD ON VBAK~VBELN = VBKD~VBELN
      WHERE
      VBAK~VBELN IN SO_VBELN AND
      VBAK~ERDAT IN SO_ERDAT AND
      ( AUART EQ 'OR' OR AUART EQ 'ZEO' OR AUART EQ 'TA' OR AUART EQ 'LP' OR AUART EQ 'ZFOC' ) AND
      VKORG IN SO_VKORG AND
      VTWEG IN SO_VTWEG AND
      SPART IN SO_SPART AND
      KUNNR IN SO_KUNNR AND
      MATNR IN SO_MATNR AND
      MATKL IN SO_MATKL AND
      ABGRU EQ '' AND LIFSK <> '35'.
    Edited by: Suhas Saha on Jan 14, 2012 3:42 PM

    Hello Suhale,
    On retrospection, I found the query in my above response STILL HAS ONE ISSUE. When we are making a left outer join on vbkdposnr = vbapposnr we are only fetching vbkdinco1 and vbkdinco2 values where item level entries exist in VBKD which match with vbkdposnr = vbapposnr.
    Actually we should bring inco1 and inco2 from vbkd when a matching entry exists in vbkd where vbkdposnr = vbapposnr and if there is no entry matching vbkdposnr = vbapposnr, then we should fetch inc01 and inco2 from VBKD where posnr = '000000' (i.e., from header).
    This is how SAP behaves when you open an item in VA03 and look at inco1 and inco2. They come from the item if an entry corresponding to that item exists in VBKD otherwise they come from VBKD header record (where vbkd~posnr = '000000')
    We can't use VBKD in the joins and still be able to do the above. So we need to fetch inco1, inco2 from VBKD separately like below.
    FIELD-SYMBOLS: <fs_pending> LIKE LINE OF it_pending.
    SELECT vbak~vkorg vbak~vtweg vbak~vbeln vbak~kunnr
           vbak~erdat vbak~lifsk "vbkd~inco1 vbkd~inco2
           vbap~matnr vbap~arktx vbap~matkl vbak~bstnk
           vbak~bstdk vbak~knumv vbap~uepos vbap~posnr
           vbap~kwmeng vbak~vdatu vbap~vrkme vbak~ernam vbak~waerk
      INTO CORRESPONDING FIELDS OF TABLE it_pending
        FROM vbak INNER JOIN vbap
          ON vbak~vbeln = vbap~vbeln
            WHERE vbak~vbeln IN so_vbeln AND
                  vbak~erdat IN so_erdat AND
                ( vbak~auart EQ 'OR' OR vbak~auart EQ 'ZEO' OR
                  vbak~auart EQ 'TA' OR vbak~auart EQ 'LP' OR
                  vbak~auart EQ 'ZFOC' ) AND
                  vbak~vkorg IN so_vkorg AND
                  vbak~vtweg IN so_vtweg AND
                  vbak~spart IN so_spart AND
                  vbak~kunnr IN so_kunnr AND
                  vbap~matnr IN so_matnr AND
                  vbap~matkl IN so_matkl AND
                  vbap~abgru EQ '' AND
                  vbak~lifsk NE '35'.
      LOOP AT it_pending ASSIGNING <fs_pending>.
        SELECT SINGLE inco1 inco2
          FROM vbkd
            INTO (<fs_pending>-inco1,<fs_pending>-inco2)
              WHERE vbkd~vbeln = <fs_pending>-vbeln AND
                    vbkd~posnr = <fs_pending>-posnr.
        IF sy-subrc NE 0.
          SELECT SINGLE inco1 inco2
            FROM vbkd
              INTO (<fs_pending>-inco1, <fs_pending>-inco2)
                WHERE vbkd~vbeln = <fs_pending>-vbeln AND
                      vbkd~posnr = '000000'.
        ENDIF.
      ENDLOOP.
    Best regards,
    Vishnu Tallapragada.

  • Performance optimization on select query for all entries

    Hi All,
          I want to optimize the select query in my Program.
         The select query is taking lot of time to search the records for the given condition in the where clause
         and more interestingly there are no records fetched from the database as the where condition does not matches. 
         It is taking more than 30 min to search the record and the result is no record found.
         Below is my select query. I have also created the secondary Index for the same.
         In My opinion FOR ALL ENTRIES is taking lot of time. Because there are more than 1200 records in internal table t_ajot     
          select banfn  bnfpo     bsart      txz01   matnr   Werks   lgort     matkl    reswk   menge     meins   flief      ekorg  
              INTO CORRESPONDING FIELDS OF TABLE t_req
              FROM eban
                FOR ALL ENTRIES IN t_ajot
              WHERE matkl >= t_ajot-matkl_low
                AND matkl <= t_ajot-matkl_high
                AND werks = t_ajot-werks
                AND loekz = ' '
                AND badat IN s_badat
                AND bsart = 'NB'.  
        Please suggest.

    Hi,
    that,
    FOR ALL ENTRIES IN t_ajot
    WHERE matkl >= t_ajot-matkl_low
    AND matkl <= t_ajot-matkl_high
    AND werks = t_ajot-werks
    AND loekz = ' '
    AND badat IN s_badat
    AND bsart = 'NB'.
    looks strange.
    However:
    How does your index look like?
    What executoin plan do you get?
    How do the statistics look like?
    Whats the content of the variables t_ajot-... and s_badata?
    Kind regards,
    Hermann

  • Issue with select query for secondary index

    Hi all,
    I have created a secondary index A on mara table with fields Mandt and Packaging Material Type VHART.
    Now i am trying to write a report
    Tables : mara.
    data : begin of itab occurs 0.
    include structure mara.
    data  : end of itab.
    *select * from mara into table itab*
    CLIENT SPECIFIED where
      MANDT = SY-MANDT and
      VHART = 'WER'.
    I'm getting an error
    Unable to interpret "CLIENT". Possible causes of error: Incorrect spelling or comma error.          
    if i change to my select query     to
    *select * from mara into table itab*
      where
      MANDT = SY-MANDT and
      VHART = 'WER'.
    I'm getting an error
    Without the addition "CLIENT SPECIFIED", you cannot specify the client     field "MANDT" in the WHERE condition.
    Let me know if iam wrong and we are at 4.6c
    Thanks

    Like I already said, even if you have added the mandt field in the secondary index, there is no need the use it in the select statement.
    Let me elaborate on my reply before. If you have created a UNIQUE index, which I don't think you have, then you should include CLIENT in the index. A unique index for a client-dependent table must contain the client field.
    Additional info:
    The accessing speed does not depend on whether or not an index is defined as a unique index. A unique index is simply a means of defining that certain field combinations of data records in a table are unique.
    Even if you have defined a secondary index, this does not automatically mean, that this index is used. This also depends on the database optimizer. The optimizer will determine which index is best and use it. So before transporting this index, you should make sure that the index is used. How to check this, have a look at the link:
    [check if index is used|http://help.sap.com/saphelp_nw70/helpdata/EN/cf/21eb3a446011d189700000e8322d00/content.htm]
    Edited by: Micky Oestreich on May 13, 2008 10:09 PM

  • Select query for dates

    Hi All,
    Could you please help with a SELECT query to retrieve the following dates ...
    sysdate - 1
    sysdate,
    sysdate + 1
    Sorry for the miscommunication .. I wanted these dates in a single column as given below
    21-May-2012
    22-May-2012
    23-May-2012
    Regards,
    Jitesh Gurnani
    Edited by: Jitesh Gurnani on May 22, 2012 2:53 AM

    >
    Sorry for the miscommunication .. I wanted these dates in a single column as given below
    21-May-2012
    22-May-2012
    23-May-2012
    >
    select sysdate - level + 2
      from dual
    connect by level <= 3
    order by 1Edited by: Paul Horth on 22-May-2012 02:59

  • Select query 'for all entries'

    Hello Friends,
           SELECT emp_id emp_name
           INTO corresponding fields of table itab_emp
           FROM employee
           for all entries in itab_dept
           WHERE emp_id = itab_dept_emp_id.
    In the above select query we are using 'for all entries' for the internal table itab_dept.What will happen if the join fails?Will we get any data in the output table?
    What is the prerequisites for using 'for all entries'.
    Please advice me on this.
    Regards
    Ashish.

    Hi
    In this case all the records available in employee table are extracted into internal table itab_emp.
    It is safe to check whether itab_dept is initial or not.
    If it is initial then stop the select query.
    Check the following program u will get an idea.
    Also try this program by removing comment to 'REFRESH IT_LFA1'.
    REPORT  ZBM_PG                                  .
    TABLES: LFA1, EKKO.
    DATA:
         IT_LFA1 TYPE TABLE OF LFA1 WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,
          IT_LFA1 TYPE TABLE OF LFA1 WITH HEADER LINE,
          IT_EKKO TYPE TABLE OF EKKO WITH HEADER LINE.
    SELECT * FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR EQ '0000001000' OR LIFNR EQ '0000001500'.
    SELECT * FROM LFA1 INTO TABLE IT_LFA1 UP TO 1 ROWS.
    refresh it_lfa1.
    SELECT * FROM EKKO INTO TABLE IT_EKKO FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.
    LOOP AT IT_EKKO.
      WRITE: / IT_EKKO-LIFNR, IT_EKKO-EBELN.
    ENDLOOP.
    Reward me if it is useful

  • How  to write select query for this

    Hi,
    I had a html form and in the for i had drop down box and it needs to select multiple values from the drop down box. When i select multiple values then i have to write the SQL select statement  query .
    When i try to write the select statement and trying to run i am getting error.
    select * from Table
    where emo_no = '1,2,3'
    this is how i write query please suggest me how  to write query for selecting multiple values from the drop down box.
    Thanks

    select * from Table
    where emo_no in ( 1,2,3)
    for integer values
    select * from Table
    where emo_no in ('1','2','3')
    for characters
    If we talk about large scale applications that may have millions of records, I would suggest this.
    declare @t table (v int)
    insert into t (v) values (1)
    insert into t (v) valves (2)
    insert into t (v) values (3)
    select *
    from table
         inner join @t t on table.emo_no = t.v
    Using "in" for a where clause is not so bad for filtering on a few values, but if you are filtering a lot of rows and a lot of values (emo_no) the performance degrades quickly for some reasons beyond the scope of this.
    This is just one solution, I'll through this out as well, instead of an in memory (@t) table, doing a disk based temp table (#t) and creating an index on the column "v".
    create table #t (v int)
    insert into #t (v) values (1)
    insert into #t (v) valves (2)
    insert into #t (v) values (3)
    create index ix_t on #t (v)
    select *
    from table
         inner join #t t on table.emo_no = t.v
    drop table #t
    Pardon any syntax errors and careful using a drop statement.
    Sometimes in memory tables work better than disk temp tables, it takes some testing and trial and error depending on your datasets to determine the best solution.
    Probably too much info  ;-)
    Byron Mann
    [email protected]
    [email protected]
    Software Architect
    hosting.com | hostmysite.com
    http://www.hostmysite.com/?utm_source=bb

  • Writing OR query for fetching records

    Hi,
    I have dowloaded a custom wsdl and generated a java client from it using Jdeveloper.
    I have a method named customObject1QueryPage(QueryInputObj) which is used to query the CRM oD to fetch records.
    I have successfully queried using the above method for one condition:-
    QueryInputObj param= new QueryInputObj();
    QueryType q = new QueryType();
    q.set_value("='" + "ABC'");
    //q.set_value("LIKE 'A*'");
    param.setAccountName(q);
    customObject1QueryPage(param);
    But now I want to query using "OR" condition with multiple names in the condition and I don't know how to
    write query for that.
    SQL query would be like "Select * from table where name='ABC' OR name='PQR' OR name ='XYZ' ";
    I want to execute same query for CRM oD but have no idea how to write it.
    Can somebody please help me as soon as possible.
    Thanks.

    Hi,
    If your intent to Use OR Condition on a field with multiple Values
    say, AccountName = 'xyz' OR AccountName= 'abc' the syntax would be *(='xyz') OR (='abc')*
    say, AccountName = 'xyz' OR AccountName= 'abc' OR AccountName = 'pqr' the syntax would be *((='xyz') OR (='abc'))OR(='pqr')*
    You can find similar example under On Demand Web Service Documentation
    Regards
    Deepak H Andeli

Maybe you are looking for