How can I use an IF statement in the SELECT

Hi People,
I have a procedure called ENQUEUE_PROC which takes 3 parameters.
and I am trying to use an if statement in the select. I appreciate the help with this task.
here is my code.
Please have a look at my Select statement. What I have does not compile, however it might give you an idea of what i need.
PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
                       P_EVENT         VARCHAR2,
                            CASE_TYPE_CODE NUMBER;
                       ) AS
     XMLDATA XMLTYPE;
     enqueue_options     dbms_aq.enqueue_options_t;
     message_properties  dbms_aq.message_properties_t;
     message_handle      RAW(16);
     message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
          SELECT      
                    XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
                                                      'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
                         XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
                                                                                               'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
                                                                                               'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
                                   XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
                            XMLELEMENT("defendentDetails",
                                                            XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
                                                            XMLELEMENT("personDetails",
                                                                           // Here is where I want my IF statement, *********************************
                                                                           IF CASE_TYPE_CODE = 10 THEN
                                                                                     XMLELEMENT("personNameDetails",
                                                                                                         XMLELEMENT("firstName", SMD.FIRST_NAME),
                                                                                                         XMLELEMENT("middleName", SMD.MIDDLE_NAME),
                                                                                                         XMLELEMENT("lastName", SMD.LAST_NAME)
                                                                                               ), -- personNameDetails
                                                                           ELSE
                                                                                XMLELEMENT("personNameDetails",
                                                                                               XMLELEMENT("corpname", SMD.CORPNAME),
                                                                                     ), -- personNameDetails
                                                                           XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)          
                                                                      ) -- personDetails
                                        ), -- defendentDetails
                                        XMLELEMENT("documentStatusDetails",
                                                  XMLELEMENT("otherStatus",
                                                                 XMLELEMENT("intCode", NULL),
                                                                 XMLELEMENT("description", NULL)
                                                            ) -- otherStatus
                                        ), -- documentStatusDetails
                                        XMLELEMENT("uploadOtherDetails",
                                                       XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
                                                       XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
                                                       XMLELEMENT("submissionMethod",
                                                            XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
                                                            XMLELEMENT("description", SM.DESCRIP)
                                                       ), -- submissionMethod
                                                       XMLELEMENT("submissionReason",
                        XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
                                                            XMLELEMENT("description", SR.DESCRIP)
                                                       ), -- submissionReason
                                                       XMLELEMENT("district",
                                                            XMLELEMENT("intCode", SMD.DIST_ID),
                                                            XMLELEMENT("description", D.DISTRICT_NAME)
                                                       ), -- district
                                                       XMLELEMENT("caseFileType",
                                                            XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
                                                            XMLELEMENT("description", C.DESCRIP)
                                                       ), -- caseFileType
                                                       XMLELEMENT("primaryDocketInfo",
                                                            XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
                                                            XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
                                                            XMLELEMENT("defendentNumber", SMD.DEF_NUM)
                                                       ), -- primaryDocketInfo
                                                       XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
                                                       XMLELEMENT("AOJudgeId",
                                                            XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
                                                            XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
                                                       ), -- AOJudgeId
                                                       XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
                                                       XMLELEMENT("creator",
                                                            XMLELEMENT("firstName", NULL),
                                                            XMLELEMENT("lastName", NULL),
                                                            XMLELEMENT("email", SUB.CREATOR_ID),
                                                            XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
                                                       ), -- creator
                                                       XMLELEMENT("lastModifier",
                                                            XMLELEMENT("firstName", NULL),
                                                            XMLELEMENT("lastName", NULL),
                                                            XMLELEMENT("email", H.USER_ID),
                                                            XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
                                                       ) -- lastModifier
                                        ) -- uploadOtherDetails
                         ) -- caseFileUploadEvent
                    ) -- caseFileEvent
          INTO      XMLDATA
          FROM      USSC_CASES.SUBMISSION SUB,
          USSC_CASES.SUBMISSION_METADATA SMD,
          USSC_CASES.CASE_HISTORY H,
          LOOKUP.CASE_SUB_MTHD SM,
          LOOKUP.CASE_SUB_TYPE SR,
          LOOKUP.DISTRICTS D,
          LOOKUP.JUDGES J,
          LOOKUP.CASE_TYPES C
          WHERE      SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
          AND        SUB.SUBMISSION_ID = H.SUBMISSION_ID
          AND        SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
          AND        SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
          AND        SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
          AND        SMD.DIST_ID = D.USSC_DISTRICT_ID
          AND        SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
          AND        H.ACTION_DATE IN (SELECT MAX(A.ACTION_DATE)
                              FROM USSC_CASES.CASE_HISTORY A
                              WHERE A.SUBMISSION_ID = P_SUBMISSION_ID)
          AND        SUB.SUBMISSION_ID = P_SUBMISSION_ID;
    --dbms_output.put_line('queue start '|| xmldata.getclobval());
    --insert into test1 values(xmldata);
    message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
    message.set_text(xmldata.getStringVal());
    DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue',  -- aqadm.cases_queue             
    enqueue_options    => enqueue_options,       
    message_properties => message_properties,     
    payload  => message,             
    msgid   => message_handle);
     COMMIT;
END ENQUEUE_PROC;

thanks for the help,
I believe I almost got it to compilw, however I am getting Error(29,19): PL/SQL: ORA-00918: column ambiguously defined.
Of course CASE_TYPE_CODE is ambiguously because its passed in, is there a way around this.
Here is what i have so far.
PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
                       P_EVENT         VARCHAR2,
                       CASE_TYPE_CODE NUMBER    // passed in field
                       ) AS
     XMLDATA XMLTYPE;
     enqueue_options     dbms_aq.enqueue_options_t;
     message_properties  dbms_aq.message_properties_t;
     message_handle      RAW(16);
     message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
          SELECT      
                    XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
                                                      'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
                         XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
                                                                                               'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
                                                                                               'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
                                   XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
                                        XMLELEMENT("defendentDetails",
                                                            XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
                                                            CASE
                                                                 WHEN CASE_TYPE_CODE = 10 THEN
                                                                       XMLELEMENT("personDetails",
                                                                                     XMLELEMENT("personNameDetails",
                                                                                                         XMLELEMENT("firstName", SMD.FIRST_NAME),
                                                                                                         XMLELEMENT("middleName", SMD.MIDDLE_NAME),
                                                                                                         XMLELEMENT("lastName", SMD.LAST_NAME)
                                                                                               ), -- personNameDetails 
                                                                                     XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)          
                                                                                ) -- personDetails
                                                                 ELSE
                                                                      XMLELEMENT("corporationDetails",
                                                                                     XMLELEMENT("organizationName", SMD.CORP_NAME)
                                                                                ) -- corporationDetails          
                                                            END
                                        ), -- defendentDetails
                                        XMLELEMENT("documentStatusDetails",
                                                  XMLELEMENT("otherStatus",
                                                                 XMLELEMENT("intCode", NULL),
                                                                 XMLELEMENT("description", NULL)
                                                            ) -- otherStatus
                                        ), -- documentStatusDetails
                                        XMLELEMENT("uploadOtherDetails",
                                                       XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
                                                       XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
                                                       XMLELEMENT("submissionMethod",
                                                            XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
                                                            XMLELEMENT("description", SM.DESCRIP)
                                                       ), -- submissionMethod
                                                       XMLELEMENT("submissionReason",
                                                            XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
                                                            XMLELEMENT("description", SR.DESCRIP)
                                                       ), -- submissionReason
                                                       XMLELEMENT("district",
                                                            XMLELEMENT("intCode", SMD.DIST_ID),
                                                            XMLELEMENT("description", D.DISTRICT_NAME)
                                                       ), -- district
                                                       XMLELEMENT("caseFileType",
                                                            XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
                                                            XMLELEMENT("description", C.DESCRIP)
                                                       ), -- caseFileType
                                                       XMLELEMENT("primaryDocketInfo",
                                                            XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
                                                            XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
                                                            XMLELEMENT("defendentNumber", SMD.DEF_NUM)
                                                       ), -- primaryDocketInfo
                                                       XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
                                                       XMLELEMENT("AOJudgeId",
                                                            XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
                                                            XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
                                                       ), -- AOJudgeId
                                                       XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
                                                       XMLELEMENT("creator",
                                                            XMLELEMENT("firstName", NULL),
                                                            XMLELEMENT("lastName", NULL),
                                                            XMLELEMENT("email", SUB.CREATOR_ID),
                                                            XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
                                                       ), -- creator
                                                       XMLELEMENT("lastModifier",
                                                            XMLELEMENT("firstName", NULL),
                                                            XMLELEMENT("lastName", NULL),
                                                            XMLELEMENT("email", H.USER_ID),
                                                            XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
                                                       ) -- lastModifier
                                        ) -- uploadOtherDetails
                         ) -- caseFileUploadEvent
                    ) -- caseFileEvent
          INTO      XMLDATA
          FROM      USSC_CASES.SUBMISSION SUB,
          USSC_CASES.SUBMISSION_METADATA SMD,
          USSC_CASES.CASE_HISTORY H,
          LOOKUP.CASE_SUB_MTHD SM,
          LOOKUP.CASE_SUB_TYPE SR,
          LOOKUP.DISTRICTS D,
          LOOKUP.JUDGES J,
          LOOKUP.CASE_TYPES C
          WHERE      SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
          AND        SUB.SUBMISSION_ID = H.SUBMISSION_ID
          AND        SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
          AND        SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
          AND        SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
          AND        SMD.DIST_ID = D.USSC_DISTRICT_ID
          AND        SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
          AND        H.ACTION_DATE IN (SELECT      MAX(A.ACTION_DATE)
                                             FROM      USSC_CASES.CASE_HISTORY A
                                             WHERE      A.SUBMISSION_ID = P_SUBMISSION_ID)
          AND        SUB.SUBMISSION_ID = P_SUBMISSION_ID;
    --dbms_output.put_line('queue start '|| xmldata.getclobval());
    --insert into test1 values(xmldata);
    message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
    message.set_text(xmldata.getStringVal());
    DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue',  -- aqadm.cases_queue             
    enqueue_options    => enqueue_options,       
    message_properties => message_properties,     
    payload  => message,             
    msgid   => message_handle);
     COMMIT;
END ENQUEUE_PROC;Edited by: Rooney on Jan 31, 2012 1:55 PM

Similar Messages

  • How can I use a READ statement for the checking date =sydatum?

    Hello,
         I need use a READ statement on an internal table ITAB (with feild var1) and check whether feild var1<= sydatum(i.e. var1 greater than or equal to sy-datum)....how can I implement this??
    Regards,
    Shashank.

    Hi,
    try this short example.
    DATA: BEGIN OF ITAB OCCURS 0,
            DATE LIKE SY-DATUM,
          END   OF ITAB.
    ITAB-DATE = '20000101'. APPEND ITAB.
    ITAB-DATE = '20010101'. APPEND ITAB.
    ITAB-DATE = '20020101'. APPEND ITAB.
    ITAB-DATE = '20030101'. APPEND ITAB.
    ITAB-DATE = '20040101'. APPEND ITAB.
    ITAB-DATE = '20050101'. APPEND ITAB.
    ITAB-DATE = '20060101'. APPEND ITAB.
    ITAB-DATE = '20070101'. APPEND ITAB.
    ITAB-DATE = SY-DATUM.   APPEND ITAB.
    ITAB-DATE = '20080101'. APPEND ITAB.
    LOOP AT ITAB WHERE DATE < SY-DATUM.
      WRITE: / 'before', ITAB-DATE.
    ENDLOOP.
    LOOP AT ITAB WHERE DATE = SY-DATUM.
      WRITE: / 'equal ', ITAB-DATE.
    ENDLOOP.
    LOOP AT ITAB WHERE DATE > SY-DATUM.
      WRITE: / 'after ', ITAB-DATE.
    ENDLOOP.
    Regards, Dieter

  • How can i use one SQL statement to solve problem?

    How can i use one SQL statement to solve the question below?
    For a Table named A, there is a column named F(char type).
    Now select all the records where F like '%00' and update their F value to '%01'
    Just one SQL statement.Do not use PL/SQL block.
    How to do that?
    Thanks.

    What is the data volume for this table?
    Do you expect lots of rows to have '%00' as their value?
    Following two statements come to mind. Other experts would be able to provide better alternatives:
    If you have index on SUBSTR(f, 2):
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) || '01'
    WHERE  substr(f,
                  -2) = '00';If most of the rows have pattern '%00':
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) ||
               DECODE(SUBSTR(f,
                             -2),
                      '00',
                      '01',
                      SUBSTR(f,
                             -2));

  • How can i use my apple ID with the itune store over my windows laptop

    how can i use my apple ID with the itune store over my windows laptop

    If you don't have iTunes installed on your laptop then you can download and install it from here : http://www.apple.com/itunes/download/
    You can then log into your account on it via the Store > Sign In menu option (on iTunes 11 on a PC you can get the menus to show via control-B) :
    And you can then select the Store on the left-hand sidebar (you can enable the sidebar via control-S), and then browse items in the store and buy them by clickin on their price.

  • Hi, we have two iphones with two accounts.  The apple tv automatically syncs with one account to play music from the iphone to apple tv.  How can I use my iphone to do the same?

    Hi, we have two iphones with two accounts.  The apple tv automatically syncs with one account to play music from the iphone to apple tv.  How can I use my iphone to do the same?

    Our experience is a little different, we have different iTunes accounts for different family members, each family member has their own iTunes library on their own mac, each mac uses my Apple ID for homesharing and we are able to play purchased content from each library on the Apple TV.

  • How can I use apple gift card in the Philippines . It says it's only applicable in US storefront

    How can I use my gift card in the Philippines  when it says for US Storefront only

    You cannot use that card. iTunes gift cards are only valid in the country of original purchase.

  • How can i use offline & online database in the same time?

    how can i use offline & online database in the same time?
    my database in another server when the connection true it connect
    but if not does not work
    i wanna make offline database if the server not connected it connect offline then the server is on it alter all data from the offline to the server.

    User, please tell us your Jdev version!
    There is no such functionality build into the framework. The offline data base is only for designing the db, not to have a backup db.
    If you can't connect to the db the application will not work.
    Timo

  • TS4148 I have an apple 4 given to me by my cousin from japan but the phone is lock by japan sotfbank, how can i use this phone here in the Philippines network provider? thanks

    I have an apple 4 given to me by my cousin from japan but the phone is lock by japan sotfbank, how can i use this phone here in the Philippines network provider? thanks

    Only the carrier an iPhone was sold as carrier locked with can officially unlock the iPhone. It is my understanding that Softbank in Japan does not unlock iPhones.

  • [HELP],875P LSR ,HOW Can I USE 3 Optical Drives in the MoBO?

    I have 1 SATA HDD Drive (Seagate 160G) installed and Have 3  Optical Drives ,Pioneer DVD and Liton CDRW in IDE2 , Plextor CDRW in IDE3 ,but MOBO can't recgnize the PLextor CDRW,WHY???
    NEED HELP!!!!!HOW can I USE these 3  Optical Drives the same time?THANK's LOT!

    Thanks Everybody!
    I changed another IDE Cable and set IDE mode in BIOS : Native , SATA only ,Keep PATA, both channels
    then,
    Everything is OK!
    How silly I am ! I used a bad 80 pin IDE CABLE!

  • How can I use SQL to check if the receipt is accounted?

    Dear all:
    How can I use SQL to check if the AR receipt is accounted ? Because there is so many receipts to check, I cannot open it to see the detail one by one.
    My environment is :11.5.9
    database : Oracle 9.2.0.8

    Duplicate post.
    How can I use SQL to check if the receipt is accounted?
    Re: How can I use SQL to check if the receipt is accounted?

  • How can I use excel and word on the IPAD2

    How can I use excel and word documents on my Ipad 2

    There are apps such as Documents To Go which support reading/editting/creating those sorts of documents :
    standard version  -  http://itunes.apple.com/us/app/documents-to-go-office-suite/id317117961?mt=8
    premium version  -  http://itunes.apple.com/us/app/documents-to-go-premium-office/id317107309?mt=8

  • How can I use "write to spreadsheet" during the data is taking but not the end of all the loops

    Hi,
    I have to run an experiment on Labview 6 or 5. I don't have Labview 7 on that computer for some reason. My experiment is talking about 1000 hours, and I have a probelm on storing the data. Right now I am using "Write to spread sheet" and I set the "append" to false. And the data is installed at the end of the experiment, that means after 1000 hours. In the mean time if somthing oges wrong like power cut or what, I will lose all the data. So what I want to do is to save the data evertime when the data is took. I tired to set the "append" to true, but it does not let me to choose the "file path"--- when I choose this and select write on new or excisting file, it said" you may not be able to save on a exciting file" and it does not let me create a new file either. If anyone have the lidea like how can I use the "wrtie to spreadsheet" function and at the same time can install the data everytime inside the look, please let me know. Thanks alot.
    KL

    KL,
    It sounds like you want to periodically save your data so it is in smaller files. (great idea) For this operation you will not want to append the data...if something happens to your system while the file is open it could become corrupt and ruin all the data. You need to write the new block of data to a new file every time. Now...this depends on how big your data is...if you only have like 500k of data to write in a block you should probably write several blocks before starting a new file. I don't know enough about how much data you are acquiring. In either case...the write to spreadsheet file.vi will need a different name each time it is called and you will not want to append. Append = false.
    -Brett

  • HOW CAN I  USE MULTIPLE INNERJOINS IN A SINGLE SELECT STATEMENT?

    HI,
    I AM SHABEER AHMED,
    I AM GETTING AN ERROR WHILE I ATTEMPT TO EXECUTE A SELECT STATEMENT WITH MULTIPLE INNER JOINS . BECOZ I WANT TO FETCH ITEM DATA, PARTNER DATA  BASED ON HEADER DATA .
    THEN OF COURSE I HAVE FETCH DATA FROM VBAK VBAP VBKD SO LZ SEND ME THE SOLUTION.
    BYE

    Hi,
    1.Just see this:
    SELECT * INTO CORRESPONDING FIELD OF TABLE itab
    FROM t1 INNER JOIN t2 ON t1f4 EQ t2f4
    INNER JOIN t3 ON t2f5 EQ t3f5 AND
    t2f6 EQ t3f6 AND
    t2f7 EQ t3f7.
    2.But better to use for all entries.It increases the performance.
    FOR ALL ENTRIES
    Tabular Conditions
    The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
    SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
    <cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
    The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
    You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
    Example for ALL ENTRIES
    DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
    TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
    WITH UNIQUE KEY TABLE LINE,
    WA LIKE LINE OF TAB_SFLIGHT.
    SELECT CARRID CONNID
    INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
    FROM SPFLI
    WHERE CITYFROM = 'NEW YORK'.
    SELECT CARRID CONNID FLDATE
    INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
    FROM SFLIGHT
    FOR ALL ENTRIES IN TAB_SPFLI
    WHERE CARRID = TAB_SPFLI-CARRID AND
    CONNID = TAB_SPFLI-CONNID.
    LOOP AT TAB_SFLIGHT INTO WA.
    AT NEW CONNID.
    WRITE: / WA-CARRID, WA-CONNID.
    ENDAT.
    WRITE: / WA-FLDATE.
    ENDLOOP.
    INNER JOINS
    In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
    SELECT...
    FROM <tab> INNER JOIN <dbtab> AS <alias> ON <cond> <options>
    where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
    A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
    The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
    The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
    Example for INNER JOINS
    REPORT demo_select_inner_join.
    DATA: BEGIN OF wa,
    carrid TYPE spfli-carrid,
    connid TYPE spfli-connid,
    fldate TYPE sflight-fldate,
    bookid TYPE sbook-bookid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY carrid connid fldate bookid.
    SELECT pcarrid pconnid ffldate bbookid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( spfli AS p
    INNER JOIN sflight AS f ON pcarrid = fcarrid AND
    pconnid = fconnid )
    INNER JOIN sbook AS b ON bcarrid = fcarrid AND
    bconnid = fconnid AND
    bfldate = ffldate )
    WHERE p~cityfrom = 'FRANKFURT' AND
    p~cityto = 'NEW YORK' AND
    fseatsmax > fseatsocc.
    LOOP AT itab INTO wa.
    AT NEW fldate.
    WRITE: / wa-carrid, wa-connid, wa-fldate.
    ENDAT.
    WRITE / wa-bookid.
    ENDLOOP.
    Regards,
    Shiva Kumar(Reward if helpful).

  • How can I use control break statement in my requirement

    Hi ABAPers,
    In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
    internal table fields :
    audat  prdha  ipnum  netwr
    02      abc     1      100
    02      abc     2      200
    02      xyz     3      300
    03      abc     4      100
    03      xyz     5      300
    03      xyz     6      200
    i need output like this:
    audat  prdha  ipnum  netwr
    02      abc     1,2      300
    02      xyz     3         300
    03      abc     4         100
    03      xyz     5,6      500
    Can anyone suggest me logic for this by using control break statements
    Thanks in advance,
    Ankita
    Moderator Message: Duplciate Post.
    Edited by: kishan P on Apr 14, 2011 3:03 PM

    Hi ABAPers,
    In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
    internal table fields :
    audat  prdha  ipnum  netwr
    02      abc     1      100
    02      abc     2      200
    02      xyz     3      300
    03      abc     4      100
    03      xyz     5      300
    03      xyz     6      200
    i need output like this:
    audat  prdha  ipnum  netwr
    02      abc     1,2      300
    02      xyz     3         300
    03      abc     4         100
    03      xyz     5,6      500
    Can anyone suggest me logic for this by using control break statements
    Thanks in advance,
    Ankita
    Moderator Message: Duplciate Post.
    Edited by: kishan P on Apr 14, 2011 3:03 PM

  • 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

Maybe you are looking for