Is possible to connect the 2 SELECTS statements into 1 for my stored procdr

ELSE IF(@number = 2)
BEGIN
SELECT COUNT([outlet #])
FROM OM
WHERE [address] LIKE '%' + @address + '%';
SELECT [outlet #], [name], address, [city/town], [postal code], telephone
FROM OM
WHERE address LIKE '%' + @address + '%'
END
Would it be possible to obtain the # of records and records in one shot
Thank u for your time

I suppose it depends on what you are really talking about, and what database and driver you are using.
A statement can return more than one result set - see Statement.getMoreResults().

Similar Messages

  • How to use the select statement in for loop

    Hi All,
    my question is can we use select statement in for loop like as follows .
    for key in select key from one_table.
    when i am using this am getting an error like Found select invalid i identifier
    how to make use of select statement in for loop
    please suggest me .
    Thanks
    Sree

    SQL>set serveroutput on;
    SQL> DECLARE
         BEGIN
         FOR Cur_Rec IN (SELECT dname FROM dept) LOOP
          DBMS_OUTPUT.PUT_LINE(Cur_Rec.dname);
         END LOOP;
         END;
    SQL>
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONSAs per your requirement always filter the Query beforehand
    Like
    FOR Cur_Rec IN (SELECT key FROM <table> WHERE key=1) LOOP
    END LOOP;Edited by: Lokanath Giri on १ दिसंबर, २०११ ३:५६ अपराह्न

  • Is it possible to convert only select statement into procedure in Oracle

    Hi, Just i wanted to convert the below query in to procedure.Procedure input is 'P.Column1'
    SELECT
    P.Column1 AS PRODUCT,
    D.Column2 AS Column2N,
    D.Column3 AS LongColumn2iption,
    P.Column4 AS PRODUCICE,
    D.Column5 AS BilliuctID,
    E.Column6 As Impaenue,
    C.Column7 AS EffecDATE,
    FROM Table1 P, Table2 D,Table3 E,Table4 C
    WHERE
    P.Column1=D.Column1 and
    P.Column1=C.PROD_COMPONENT_ID and
    P.SETID=D.SETID and
    D.Setid =E.Setid and
    P.Setid =E.Setid and
    P.Setid =C.Setid and
    D.Column1=E.Column1 and
    P.Column1=E.Column1 and
    C.Column1<>'CONSUMER TARIFFS' and
    P.Column1 in('')

    Something like:
    SQL> var my_Data refcursor
    -- Anonymous block
    SQL> begin
      2  open :my_data for select 1,2 from dual;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print :my_Data
             1          2
             1          2You can then convert the above anonymous block in to a procedure.

  • Is it not possible to give the select single field without an into clause

    Hi,
    i have to check whether my input value( only one filed) is available in the table.
    for eg i need to check whether company code is available in the table t001.
    then i will give .
    data lv_bukrs type t001-bukrs.
    lv_bukrs = 1010.
    select single bukrs from t001 where bukrs = lv_bukrs.
    here its asking for me to give a vaible to store the bukrs that is
    select single bukrs into dummyvalue from t001 where bukrs = lv_bukrs.
    Is it not possible to give the select single fieldname without an into clause

    Its Possible by declaring the tables statement
    <b>tables : AFKO.
    select single * from AFKO where <condition>.</b>
    If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used. The addition ORDER BY can also not be used.
    An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
    Notes
    When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
    If accessing tables for which SAP buffering is planned for single records, the SAP buffer is bypassed if the addition SINGLE is not specified. This behavior depends on the current implementation of the database interface and may change in future releases. In particular, it should not be used to bypass the SAP buffer. You should use the explicit addition BYPASSING BUFFER for this instead.
    The addition SINLGE is not permitted in a subquery.
    Regards
    - Gopi

  • How to find the select statement has written all selected values into text

    Hi,
    I am using form6i. i am selecting a set of values from database tables based upon some user parameters and writing into the text file using Text_io.put_line . In this case how we can make sure that the text fille contains all the data what we are selected from selected statement. somebody told that there might be chances of aborting of data while writing into the text file. is there any way to fild out the selected statements has written all the selected fields and corresponding output into the .txt file.
    Please suggest me.

    somebody told that there might be chances of aborting of data while writing into the text fileWhat kind of "chance" does that somebody refer to?
    If you want to verify if the number of records (lines) in the file matches the number of records from the cursor, you could re-open the written file in read-mode and count the number of lines by reading one by one, then compare the number of lines with the number of records from the cursor.

  • Class not getting called by the Select Statement

    Dear All,
    I have created a new class "Z1_EXIT_VARIABLES" in my Dev system and coded for a new Exit Variable for InfoObject "0FISCPER3" in this class.
    But on debugging the Function module "EXIT_SAPLRRS0_001" (INCLUDE ZXRSRU01), I could find that the Select statement
    <i>select CLSNAME
    into  l_clsname
    from VSEOIMPLEM
    where REFCLSNAME = 'ZBWIF_VAR_EXIT'.
    </i>
    calls ALL the classes mentioned in the table "VSEOIMPLEM" with    REFCLSNAME = ZBWIF_VAR_EXIT, EXCEPT the class "Z1_EXIT_VARIABLES". Therefore, the code written by me is not getting executed.
    Also, after debugging the same function module in Quality system, I could find that not all of the classes mentioned in the table "VSEOIMPLEM"are getting called by the select statement.
    (I do not have authorization for CMOD in my Dev system)
    Can anyone suggest a possible solution to the problem ?
    Regards
    Shalabh Jain

    Hi,
    Still waiting for response.
    The issue is not with finding control and performing action on it.
    The coded UI automation script is able to find the control and performing click on that, and after that is is supposed to display the results, which is not happening.
    I am not able to find out why the results are not displaying with coded UI but it's working as expected with SELENIUM web driver.
    I have to do it with CODED UI VS2013, So i request you to give me some solution for this issue, I have done automation earlier for some similar web applications, but never faced this situation.
    Studio: VS2013
    Scripting Language: C#
    HtmlHyperlink performSearchLink = new HtmlHyperlink(inventoryWindow);
     performSearchLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Search");
                Mouse.Click(performSearchLink);
    this code is working fine, it's clicking on search but not displaying the results.
    someone reply asap.
    Thanks
    Adrusta

  • Issue with Past Month data in the Select Statement

    Hi,
    I written the following query,
    SELECT   /*+NO_MERGE(A)*/
                CASE
                   WHEN snap_shot_date > a.q3
                   AND snap_shot_date <= a.q4
                      THEN q4char
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN q3char
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN q2char
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN q1char              
                END snap_shot_date,
                CASE
                   WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
                      THEN 1
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN 2
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN 3
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN 4
                END sort_by,
                pillar3_exposure_class_code, pd_band_description,
                ROUND (SUM (p3.ead_post_sec_post_crm)),
                ROUND (SUM (notional_principle)),
                DECODE (SUM (notional_principle),
                        0, 0,
                        ROUND (  SUM (DECODE (exposure_type,
                                              'UNDRAW', ead_post_sec_post_crm,
                                              0
                               / SUM (notional_principle),
                               4
                DECODE (SUM (p3.ead_post_sec_post_crm),
                        0, 0,
                        ROUND (  SUM (pd_value * p3.ead_post_sec_post_crm)
                               / SUM (p3.ead_post_sec_post_crm),
                               2
                DECODE (SUM (p3.ead_post_sec_post_crm),
                        0, 0,
                        ROUND (SUM (rwa) / SUM (p3.ead_post_sec_post_crm), 4)
                DECODE (SUM (p3.ead_post_sec_post_crm),
                        0, 0,
                        ROUND (  SUM (lgd_rate * p3.ead_post_sec_post_crm)
                               / SUM (p3.ead_post_sec_post_crm),
                               2
                TO_CHAR (MAX (a.max_date), 'FMMonth DD, YYYY')
           FROM summary.pillar3 p3,
                (SELECT DISTINCT (month_end_date) max_date,
                                 LAST_DAY (month_end_date) q4,
                                 TO_CHAR (LAST_DAY (month_end_date),
                                          'MON YYYY'
                                         ) q4char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -3) q3,
                                 TO_CHAR
                                    (ADD_MONTHS (LAST_DAY (month_end_date), -3),
                                     'MON YYYY'
                                    ) q3char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -6) q2,
                                 TO_CHAR
                                    (ADD_MONTHS (LAST_DAY (month_end_date), -6),
                                     'MON YYYY'
                                    ) q2char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -9) q1,
                                 TO_CHAR
                                    (ADD_MONTHS (LAST_DAY (month_end_date), -9),
                                     'MON YYYY'
                                    ) q1char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -12) q0
                            FROM rcdwstg.stg_bcar_detail) a
          WHERE snap_shot_date BETWEEN ADD_MONTHS (a.max_date, -12) AND a.max_date
       GROUP BY CASE
                   WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
                      THEN q4char
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN q3char
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN q2char
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN q1char
                END,
                CASE
                   WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
                      THEN 1
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN 2
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN 3
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN 4
                END,
                pillar3_exposure_class_code,
                pd_band_description
       ORDER BY 2 DESC;I have written the query to get the latest 12 months data from a table and split that into 4 quarter to show in the Cognos Report. But when the table having 13th or the past months data, the select statement is showing Empty values in the first two columns and fetching the 13 month data too.
    Can anyone help me in this to avoid the problem.
    Thanks
    Radha K

    WHERE snap_shot_date BETWEEN ADD_MONTHS(TRUNC(a.max_date, 'MM'), -11) AND  a.max_date
    ....

  • How can I call a Page Process from the Select statement for Report Page

    I'm able to call a javascript using the below:
    img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
    But Now,
    I'd like to accomplish (2) New things:
    1. instead of using,....... onClick="javascript:add_connect1,
    I'd like to call a Page Process, onClick=
    2. I'd like to be able to call two different processes onClick.
    a. onClick="javascript:passBack('||ID||')"
    b. onClick= <Please see my question #1 above>
    Can someone please help me with the syntax for this,
    If indeed it can even be done?
    Thanks- Gary

    Greg.
    It seems that my situation is the one you describe in you second paragraph, where you mention:
    you could then add the ID column value as a parameter to the javascript functionBut,
    I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
    If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
    Here's what I've got so far:
    A. In the select statement I identify the javascript as:
    onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
    B. In my javascript I have this:
    <script language="JavaScript" type="text/javascript">
    function connect_port(ID)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
    gReturn = get.get();
    get = null;
    </script>
    C. In my on demand function I have this:
    BEGIN
    INSERT INTO CCONNECTIONS_B
    BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
    ) VALUES
    :P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
    END;
    You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
    If you can help me out with this one, Then I can imitate it for the rest.
    -Gary
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:45 AM
    Edited by: garyNboston on Apr 3, 2009 6:47 AM

  • Case sensitive statement in the select-statement

    Hi All,
    i have a table in the abap-dictionary filled with names...when i try to select them with the select-statement with condition:
    table-name_column like 'some_name'
    I have encountered some problems...the inquiry is case-sensitive. What i want to do is to read the value from the abap-dictionary table uppercase or lowercase and compare it with the needed value also translated in uppercase or lowercase.
    The only idea i have is to select all values of the dictionary table into an internal table and to translate the values there in uppercase or lowercase and then to loop trough it. But this approach would cost a lot of performance.
    Do someone has an other proposal?

    check...
    Select statement
    It would be difficult , because it is based on how data is stored in the data base , now consider the scenario of the system i am using , we can material description as 'test' or 'TEST' , 'Test' .
    If in your system there are only stored in either caps or small the you can perform the select twice .
    But i myself dont find it to be such a good solution , but you can give it a try
    There is one more solution specific to material description ,and that is in the table MAKT there is a field MAKTG , which stored the description in uppercase , so for this you can first convert the description to uppercase and then perform select on this field

  • How to test the select statement.

    Hi All,
    How to test the select statement.
    Is there any Oracle sqlplus  or toad kind of tool to  test the query.
    thanks
    siva

    Use SQL Trace (ST05) and choose 'Explain one SQL Request'. Enter your SQL command as it should be executed in the underlying database. e.g. if the db is Oracle, the statement should be entered as:
    SELECT matnr,werks,lvorm,dispo
    FROM marc
    WHERE mandt = :a AND
                 matnr = :b AND
                 werks = :c
    In the above :a, :b and :c are place holders for the actual comparison values. You dont have to enter those values. When you choose 'Explain' button, you will find the 'Execution Plan'. The important parameter which denotes the efficiency of the SQL statement is the 'Cost'. The cost should be as low as possible. The table access should be through INDEX UNIQUE SCAN. If you get a FULL TABLE SCAN and higher cost, you need to fine-tune your statement by modifying the where clause.
    If you dont know Oracle SQL statements, execute the program in trace mode and go to the trace and you will find the underlying SQL statements issued to the database.
    Regards
    Suresh Radhakrishnan

  • Need a help in the Select statement

    How to use the table name dynamically in the Select Statement in Oracle 9.i ?

    This?
    sql>
    select *
    from &table
    old 2: from &table
    new 2: from dual
    D

    Or this..?
    sql>
    declare
    tab varchar2(31) := 'dual';
    v varchar2(10);
    begin
    execute immediate 'select * from '||tab into v;
    dbms_output.put_line(v);
    end;
    X
    PL/SQL procedure successfully completed
    jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Restricting records in the select statement

    Hi,
    I have one requirement where in i need to restrict my select statement to get only 250 records in the output table.
    Here are the select statements i am using....
        SELECT a~ebeln
                     a~lifnr
                     a~ekgrp
                     b~werks
                     b~matnr
               FROM ekko AS a INNER JOIN ekpo AS b
               ON aebeln = bebeln
               INTO TABLE i_ekko
               WHERE a~ebeln IN r_ebeln AND
                            a~lifnr IN r_lifnr AND
                            a~ekgrp IN r_ekgrp AND
                            b~werks IN r_ewerk AND
                            b~matnr IN r_matnr AND
                            a~bstyp = 'F'.
                IF NOT i_ekko[] IS INITIAL.
    Select Vendor name
               SELECT lifnr
                            name1
                      FROM lfa1
                      INTO TABLE i_lfa1
                      FOR ALL ENTRIES IN i_ekko
                      WHERE lifnr = i_ekko-lifnr.      
    Here if i restrict the first select statement to get only 250 records then i am not getting the desired record in the second select statement.
    Could anyone let me know how to write the select statement.
    Regards,
    Ramesh

    restric the first select using up to 250.
    sort the i_ekko by vendor name.
    ex: sort i_ekko by lifnr.
    use second select statement here.

  • Database adapter and column aliases in the select statement (10.1.3.1)

    Hi,
    Is it possible to use column aliases in the select statement for a database adapter to return an xml element name which is different to the column in the queried table?
    I have tried using
    SELECT EMPLOYEE_ID, FIRST_NAME AS MYNAME, LAST_NAME, SALARY, DEPARTMENT_ID, PHONE_NUMBER, EMAIL, HIRE_DATE FROM HR.EMPLOYEES WHERE (DEPARTMENT_ID = #DEPT_ID)
    but I get the following XML fragment returned
    <Employees>
    <employeeId>100</employeeId>
    <firstName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    <lastName>King</lastName>
    <salary>24000</salary>
    Any pointers appreciated.
    Joel.

    That is really interesting.
    When I use the "custom sql" option in the DB adapter wizard, it used the aliases just fine in the return schema.
    Marc

  • Problem in the select statement

    I have to select the values of the fields BEZEI  depending on tha sales order number vbeln. HOw can i write the select statement what will be the tables associated?

    Hi,
    tables: vbak.
    types: begin of ty_vbak,
               vbeln type vbeln,
               kokrs type kokrs,
              end of ty_vbak,
              begin of ty_it_tka01,
                kokrs type kokrs,
                bezei type bezei,
              end of ty_tka01.
    data: it_vbak type table of ty_vbak,
            wa_vbak type ty_vbak,
            it_tka01 type table of ty_tka01,
            wa_tka01 type ty_tka01.
    Select-options: s_vbeln for vbak-vbeln.
    Select VBELN KOKRS from VBAK into table it_VBAK where vbeln in s_vbeln.
    if sy-subrc = 0.
    select KOKRS BEZEI from TKA01 into it_tka01 for all entries in it_vbak where kokrs = it_vbak-kokrs.
    endif.
    Loop at it_vbak into wa_vbak.
    read table it_tka01 into wa_tka01 with key kokrs = wa_vbak-kokrs.
    if sy-subrc = 0.
    * Move data to final internal table.
    endif.
    endloop.
    Regards,
    Satish

  • Break the SELECT statement.

    Hi,
    My requirement is to break the Select statement and get the fields in where clause in one internal table.
    For eg: Select VBELN
                          POSNR
                          MATNR  from VBAP into wa_vbap where VBELN = '0000000001'
                                                                              and   POSNR = '000010'.
    Here i need to put fields VBELN, POSNR, MATNR in one internal table, table name VBAP in second internal table  and where clause fields  VBELN, POSNR in third internal table.
    Please let me know if anyone has any solution for this.
    Thanks in advance.
    Sunanda.

    Hi
    *& Report  YSELECT                                                     *
    REPORT  YSELECT                                 .
    *Select VBELN
    *POSNR
    *MATNR from VBAP into wa_vbap where VBELN = '0000000001'
    *and POSNR = '000010'.
    *Here i need to put fields VBELN, POSNR, MATNR in one internal table,
    *table name VBAP in second internal table and where clause fields VBELN,
    * POSNR in third internal table.
    TABLES: VBAP.
    TYPES: BEGIN OF STRUCT1,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          MATNR LIKE VBAP-MATNR,
           END OF STRUCT1.
    TYPES: BEGIN OF STRUCT2,
            TBLNAME(10),
           END OF STRUCT2.
    TYPES: BEGIN OF STRUCT3,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          END OF STRUCT3.
    DATA: ITAB1 TYPE TABLE OF STRUCT1 WITH HEADER LINE,
          ITAB2 TYPE TABLE OF STRUCT2 WITH HEADER LINE,
          ITAB3 TYPE TABLE OF STRUCT3 WITH HEADER LINE,
          V_TBLNAME(10).
    ITAB3-VBELN = '0000000001'.
    ITAB3-POSNR = '000010'.
    APPEND ITAB3.
    LOOP AT ITAB3.
        SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB1 WHERE VBELN EQ
    ITAB3-VBELN AND POSNR EQ ITAB3-POSNR.
          WRITE ITAB1-VBELN.
    ENDLOOP.
    WRITE: 'SUBRC=', SY-SUBRC.
    I am unable to find out how to satisfy your second internal table requirement.
    Hope this helps
    Regards,
    Jayanthi.K

  • Is it possible to debug the selection screen???

    Hi Frdz,
    Is it possible to debug the selection screen.
    eg: if i want to know what is happening in PBO and PAI modules of the selection screen i am not able to debug that.
    Even in code if i click on MODULES present in PBO and PAI modules it is saying MODULE doesnot exist!!!!. So i can't put the break point. even if i press /h it will go to Report events like INITIALIZATION, AT SELECTION-SCREEN but not PBO and PAI modules!.
    Also what is the meaning of exclamatory mark here(Before select option name)
    MODULE !SO_UDATE.
    MODULE !SO_UNAME.
    Thanks,
    Vinod.

    Hi Vinod,
    Double click on the module and then put the break point for the first statement of it. It will work.
    Reward points if useful.
    Thanks,
    Khan.

Maybe you are looking for