Cfmail loop query

can some one help me with this query please
i have a cfmail running off a query
i want to be able to send mail to a list of recipietns from
my database
the query below works but only sends emails to the first
contact in the list
what can i do to my query to change this?
<CFQUERY datasource="#application.ds#" Name="GetSch">
SELECT cc.Code, gg.PlayerPhone, dd.Message, cc.Club_Abbrev
FROM appoint_table dd, SMS_Players_Table gg, SMS_Clubs_Table
cc
WHERE ServerSMS <= #CreateODBCDateTime(Now())# AND
dd.App_ClientID = gg.PlayerID AND dd.LoginID = cc.ClubID
AND ServerSMS <> ''
</cfquery>
<cfmail to = "[email protected]" query="GetSch"
from = "test"
subject="">
to:#Code##PlayerPhone#
text:#Message#
from:#Club_Abbrev#
</cfmail>

ok thank i just realised what i need
just to go to one email as the cfmail is at the min
but i need to loop through the mail output so it send 30
emails to the same email
with the different
to:#Code##PlayerPhone#
text:#Message#
from:#Club_Abbrev#
for each record retreved form the query

Similar Messages

  • Loop query

    i have a simple loop query. I want to get same data from 3 different tables into a single internal table like
    if tab1 data is not available then tab2 then tab3.
    now when i use my internal table how do i fill data into my internal table and what will be my loop condition.
    i have already written select statement.
    a sample code will be of great help

    Hi,
    The above said code I think it doesn't work properly because in the select statement from table name placed after the internal table and also no need of append statement.
    Use like this...(itab-Internal table name)
    Select * from tab1 into table itab
        where (condition).
    if sy-subrc <> 0.
      Select * from tab2 into table itab
         where(condition).
      if sy-subrc <> 0.
        Select * from tab3 into table itab
           where (condition).
      endif.
    endif.
    Now you will get value in the internal table itab.Three different tables where tab1,tab2,tab3.
    Thanks,
    Sakthi C
    *Rewards if useful--*

  • Cfmail loops back to original form document yet not sending email.

    I had produced a form to be emailed. after one finishes the form and press submit it loops back top the form again, yet i do not get an email. Doen anyone know why this is happening? Below is the code for the original form and below that is code to my action page... Any suggestions would be welcomed..
    FORM ORIGINAL CODE
    <cfquery name="select_ministry" datasource="ministry9">
    SELECT ministry.ministry
    FROM ministry
    ORDER BY ministry.ministry
    </cfquery>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    @import url("CSS/event_Req_Label.css");
    -->
    </style>
    </head>
    <body>
    <!--- Begin ColdFusion Form --->
    <cfform name="Event_Request" action="EventRequestSend.cfm" method="post" >
    <strong>Event Contact</strong><br />
    <br />
      <span class="eventReq_label">First Name:</span>
                        <cfinput
                        type="text"
                        name="First_Name"
                        message="Please enter your First Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Last Name:</span>
                          <cfinput
                        type="text"
                        name="Last_Name"
                        message="Please enter your Last Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Phone:</span>
                          <cfinput
                        type="text"
                        name="Phone"
                        message="Please enter your Phone Number..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Email:</span>
                          <cfinput
                        type="text"
                        name="Email_Address"
                        message="Please enter your Email Address..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        </span><br />
                          <br />
                        <br />
                          <strong>About Event/Program</strong><br />
                        <br />
                          <span class="eventReq_label">Event Title:</span>
                          <cfinput
                        type="text"
                        name="Event_Title"
                        message="Please enter the Name of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <br />
                          <span class="eventReq_label">Ministry: </span>
                               <select name="select_ministry" size="1" class="event_Request_Box">
                                 <cfoutput query="select_ministry">
                                   <option value= "#select_ministry.Ministry#" <cfif (isDefined("select_ministry.Ministry") AND select_ministry.Ministry EQ select_ministry.Ministry)>selected</cfif>>#select_ministry.Ministry#</option>
                                 </cfoutput>
                                 </select>
                               <br />
                          <span class="eventReq_label">Event Description:</span>
                          <cftextarea name="Event_Description" cols="40" rows="10" label="Event_Description" required="yes" class="event_Request_Box" id="Event_Description" message="Please Enter a description for the event." tooltip="Please Describe the event in 75 words or less." enabled="no" value="Event_Description" maxlenght="75"></cftextarea>
                          <br />
                          <span class="eventReq_label">Event Date:</span>
                          <cfinput
                        type="text"
                        name="Event_Date"
                        message="Please enter the Date of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Event Time:</span>
                          <cfinput
                        type="text"
                        name="Event_Time"
                        message="Please enter the Time of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Address:</span>
             <cfinput
                        type="text"
                        name="Event_address"
                        message="Please enter the Address of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        <br />
                          <span class="eventReq_label">Address 2:</span>
                          <cfinput
                        type="text"
                        name="Event_address_2"
                        message="Please enter the Address of the Event..."
                        required="no" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">City:</span>
                          <cfinput
                        type="text"
                        name="Event_City"
                        message="Please enter the City of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">State:</span>
                          <cfinput
                        type="text"
                        name="Event_State"
                        message="Please enter the State of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Zipcode:</span>
                          <cfinput
                        type="text"
                        name="Event_Zip_code"
                        message="Please enter the Zip Code of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Admission Cost:</span>
                          <cfinput
                        type="text"
                        name="admission_Cost"
                        message="Please enter the cost of admission for the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                        <br />
                        <input type="submit" name="Submit" class="submit" value="Submit">
                        <br />
                        <br />
             <!--- End ColdFusion Form --->
                        </cfform>
    </body>
    </html>
    FORM ACTION PAGE CODE
    <!--- Add cfparams to prevent errors on the page --->
    <cfparam name="Event_Request.First_Name" default="">
    <cfparam name="Event_Request.Last_Name" default="">
    <cfparam name="Event_Request.Phone" default="">
    <cfparam name="Event_Request.Email_address" default="">
    <cfparam name="Event_Request.Event_title" default="">
    <cfparam name="Event_Request.select_ministry" default="">
    <cfparam name="Event_Request.Event_Description" default="">
    <cfparam name="Event_Request.Event_Date" default="">
    <cfparam name="Event_Request.Event_Time" default="">
    <cfparam name="Event_Request.Event_address" default="">
    <cfparam name="Event_Request.Event_address_2" default="">
    <cfparam name="Event_Request.Event_City" default="">
    <cfparam name="Event_Request.Event_State" default="">
    <cfparam name="Event_Request.Event_Zip_code" default="">
    <cfparam name="Event_Request.admission_Cost" default="">
    <!--- Create an empty error string --->
    <cfset strError = "">
    <!--- If the form is submitted --->
    <cfif isDefined("Event_Request.Submit")>
    <!--- If the First Name field is empty --->
        <cfif Len(Trim(Event_Request.First_Name)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your First Name...<br>">
        </cfif>
    <!--- If the Last Name field is empty --->
        <cfif Len(Trim(Event_Request.Last_Name)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your Last Name...<br>">
        </cfif>
        <!--- If the Phone field is empty --->
        <cfif Len(Trim(Event_Request.Phone)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your Phone Number...<br>">
        </cfif>
        <!--- If the Email field is empty --->
        <cfif Len(Trim(Event_Request.Email_address)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your Email Address...<br>">
        </cfif>
        <!--- If the Event_title field is empty --->
        <cfif Len(Trim(Event_Request.Event_title)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the Name of the Event...<br>">
        </cfif>
    <!--- If the select_ministry is empty --->
        <cfif Len(Trim(Event_Request.select_ministry)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please select the ministry...<br>">
        </cfif>
    <!--- If the Event_Description is empty --->
        <cfif Len(Trim(Event_Request.Event_Description)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "please include your description...<br>">
        </cfif>
    <!--- If the Event_Date is empty --->
        <cfif Len(Trim(Event_Request.Event_Date)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the date of your program...<br>">
        </cfif>
    <!--- If the Event_Time is empty --->
        <cfif Len(Trim(Event_Request.Event_Time)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the Time of your program...<br>">
        </cfif>
    <!--- If the Event_address is empty --->
        <cfif Len(Trim(Event_Request.Event_address)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the address of your program...<br>">
        </cfif>
    <!--- If the Event_City is empty --->
        <cfif Len(Trim(Event_Request.Event_City)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the city of your program...<br>">
        </cfif>
    <!--- If the Event_State is empty --->
        <cfif Len(Trim(Event_Request.Event_State)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the state of your program...<br>">
        </cfif>
    <!--- If the Event_Zip_code is empty --->
        <cfif Len(Trim(Event_Request.Event_Zip_code)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the zipcode of your program...<br>">
        </cfif>
    <!--- If the admission_Cost is empty --->
        <cfif Len(Trim(Event_Request.admission_Cost)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the Admission Cost of your program...<br>">
        </cfif>
    <!--- If the form was not submitted --->
    <cfelse>
        <!--- Send the user to the form page --->
        <cflocation addtoken="no" url="Event_Request.cfm">
    </cfif>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Response Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    @import url("CSS/event_Req_Label.css");
    -->
    </style>
    </head>
    <body>
    <!--- If the error string is still empty show the results --->
    <cfif strError EQ "">
        <p>Thank you for submitting the Event Request form.</p>
        <p>You submitted the following information:</p>
        <cfoutput>
            <p>    First Name:     #Trim(EVENT_REQUEST.First_Name)#<br><br>
                Last Name:     #Trim(EVENT_REQUEST.Last_Name)#<br><br>
                      Phone:         #Trim(EVENT_REQUEST.Phone)#<br><br>
                Email:         #Trim(EVENT_REQUEST.Email_Address)#<br><br><br><br>
                Event Title:     #Trim(EVENT_REQUEST.Event_Title)#<br><br>
                Ministry:     #Trim(EVENT_REQUEST.select_ministry)#<br><br>
                Description:     #Trim(EVENT_REQUEST.Event_Description)#<br><br>
                Event Date:     #Trim(EVENT_REQUEST.Event_Date)#<br><br>
                Event Time:     #Trim(EVENT_REQUEST.Event_Time)#<br><br>
                Event Address:     #Trim(EVENT_REQUEST.Event_address)#<br><br>
                Event Address 2:#Trim(EVENT_REQUEST.Event_address_2)#<br><br>
                Event City:     #Trim(EVENT_REQUEST.Event_City)#<br><br>
                Event State:     #Trim(EVENT_REQUEST.Event_State)#<br><br>
                Zip code:     #Trim(EVENT_REQUEST.Event_Zip_code)#<br><br>
          Admission_Cost:    #Trim(EVENT_REQUEST.admission_Cost)#<br><br></p>
        </cfoutput>
        <p>Someone will contact you if necessary. </p>
    <!--- Send the email --->
    <cfmail from="#EVENT_REQUEST.Email_Address#"         to="[email protected]"
            subject="You have mail from"
            replyto="#EVENT_REQUEST.Email_Address#"
            server="mail.thehansonco.com">
    You Have an inquiry from:     #Trim(EVENT_REQUEST.First_Name)#
                                #Trim(EVENT_REQUEST.Last_Name)#<br><br>
                          Phone:     #Trim(EVENT_REQUEST.Phone)#<br><br>
                        Email:     #Trim(EVENT_REQUEST.Email_Address)#<br><br><br><br>
                        Event Title:     #Trim(EVENT_REQUEST.Event_Title)#<br><br>
                        Ministry:         #Trim(EVENT_REQUEST.select_ministry)#<br><br>
                        Description:     #Trim(EVENT_REQUEST.Event_Description)#<br><br>
                        Event Date:     #Trim(EVENT_REQUEST.Event_Date)#<br><br>
                        Event Time:     #Trim(EVENT_REQUEST.Event_Time)#<br><br>
                        Event Address:     #Trim(EVENT_REQUEST.Event_address)#<br><br>
                        Event Address 2:#Trim(EVENT_REQUEST.Event_address_2)#<br><br>
                        Event City:     #Trim(EVENT_REQUEST.Event_City)#<br><br>
                        Event State:     #Trim(EVENT_REQUEST.Event_State)#<br><br>
                        Zip code:         #Trim(EVENT_REQUEST.Event_Zip_code)#<br><br>
                        Admission_Cost:    #Trim(EVENT_REQUEST.admission_Cost)#<br><br>
        </cfmail>
    <!--- If the error string is not empty show the form again --->
        <cfelse>
        <!--- Begin ColdFusion Form --->
    <cfform name="Event_Request"  action="EventRequestSend.cfm" method="post" >
    <strong>Event Contact</strong><br />
    <br />
    <!--- Add table row to show error message --->
                    <cfoutput>#strError#</cfoutput>
      <span class="eventReq_label">First Name:</span>
                        <cfinput
                        type="text"
                        name="First_Name"
                        message="Please enter your First Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Last Name:</span>
                          <cfinput
                        type="text"
                        name="Last_Name"
                        message="Please enter your Last Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Phone:</span>
                          <cfinput
                        type="text"
                        name="Phone"
                        message="Please enter your Phone Number..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Email:</span>
                          <cfinput
                        type="text"
                        name="Email_Address"
                        message="Please enter your Email Address..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        </span><br />
                          <br />
                        <br />
                          <strong>About Event/Program</strong><br />
                        <br />
                          <span class="eventReq_label">Event Title:</span>
                          <cfinput
                        type="text"
                        name="Event_Title"
                        message="Please enter the Name of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <br />
                          <span class="eventReq_label">Ministry: </span>
                               <select name="select_ministry" size="1" class="event_Request_Box">
                                 <cfoutput query="select_ministry">
                                   <option value= "#select_ministry.Ministry#" <cfif (isDefined("select_ministry.Ministry") AND select_ministry.Ministry EQ select_ministry.Ministry)>selected</cfif>>#select_ministry.Ministry#</option>
                                 </cfoutput>
                                 </select>
                               <br />
                          <span class="eventReq_label">Event Description:</span>
                          <cftextarea name="Event_Description" cols="40" rows="10" label="Event_Description" required="yes" class="event_Request_Box" id="Event_Description" message="Please Enter a description for the event." tooltip="Please Describe the event in 75 words or less." enabled="no" value="Event_Description" maxlenght="75"></cftextarea>
                          <br />
                          <span class="eventReq_label">Event Date:</span>
                          <cfinput
                        type="text"
                        name="Event_Date"
                        message="Please enter the Date of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Event Time:</span>
                          <cfinput
                        type="text"
                        name="Event_Time"
                        message="Please enter the Time of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Address:</span>
             <cfinput
                        type="text"
                        name="Event_address"
                        message="Please enter the Address of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        <br />
                          <span class="eventReq_label">Address 2:</span>
                          <cfinput
                        type="text"
                        name="Event_address_2"
                        message="Please enter the Address of the Event..."
                        required="no" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">City:</span>
                          <cfinput
                        type="text"
                        name="Event_City"
                        message="Please enter the City of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
      <span class="eventReq_label">State:</span>
      <cfinput
                        type="text"
                        name="Event_State"
                        message="Please enter the State of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
    <br />
                          <span class="eventReq_label">Zipcode:</span>
                          <cfinput
                        type="text"
                        name="Event_Zip_code"
                        message="Please enter the Zip Code of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Admission Cost:</span>
                          <cfinput
                        type="text"
                        name="admission_Cost"
                        message="Please enter the cost of admission for the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                        <br />
                        <input type="submit" name="Submit" class="submit" value="Submit">
                        <br />
                        <br />
                        </cfform>
                        </cfif>
    </body>
    </html>

    When you submit a form, the name of it doesn't matter.  When you process it it's form.this and form.that, not name_of_form.this and name_of_form.that.  In your code, the structure event_request does not exist until the cfparam tags create it.  All of those tags will create variables with empty strings.  Later your code adds a bunch of error messages and doesn't send any mail because of your if/else logic.

  • CFMAIL Looping

    I have an application that I've written so that a user can
    send a group of people an email message. It is in two parts, the
    form and the action page that actually sends the email. The first
    page's code is as follows:
    <cfquery name="getEmail"
    datasource="#application.dsn#">
    SELECT *
    FROM tblEpolarityRPP_new
    ORDER BY EMAIL
    </cfquery>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <html>
    <head>
    <title>Email RPPs</title>
    <link rel="stylesheet" type="text/css"
    href="organized.css">
    </head>
    <body>
    <h2>Email RPPs</h2>
    <cfform action="rppemail_actiontest.cfm" method="post">
    <cfoutput query="getEmail">
    <!--- #getEmail.Email#<br> --->
    <input type="hidden" name="Email"
    value="#getEmail.Email#">
    </cfoutput>
    <p class="p5">Enter message here:<br>
    <textarea name="Message" rows="20"
    cols="50"></textarea><p>
    <input type="submit" value="Send
    Email">  <input type="reset" value="Clear
    Form">
    </cfform>
    </body>
    </html>
    The query retrieves about 710 email addresses from the table.
    When we submit, it apparently works okay, but according to the host
    of our web site, there are too many email addresses in the list and
    it doesn't send any because it hangs. I know that what the action
    page is doing is creating an email with 710 email addresses in the
    "TO" line. What I would like it to do is create 710 different
    emails, with one of the email addresses from the database in each
    message. According to the tech support person at the hosting site,
    this should fix the problem. The code on the action page is:
    <cfmail to="#Form.Email#"
    from="[email protected]" subject="ePolarity"
    type="html" server="mail.polarityinbalance.com">
    #Form.Message#
    </cfmail>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <html>
    <head>
    <title>Email RPP Results</title>
    </head>
    <body>
    Your email was successfully transmitted.<p>
    <a href="polarityadminindex.cfm">Click here</a>
    to return to the Administrator menu.
    </body>
    </html>
    Any suggestions on how to create a loop to insert one email
    address at a time into the email would be greatly appreciated.
    Thanks so much,
    Michelle Craig

    look into this document
    http://127.0.0.1:8500/cfdocs/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm

  • Exception statement for looping query

    Hi this is my query to date:
    declare   
        cursor curs is
         select name_id_no, incident_date
         from MICHAELC.Food_Nov_01_final t
         --where rownum < 6
         for update of cat_latest;
        w_cat_latest        number(4,0);
        w_cat_latest_date   date;
        w_cat_max           number(4,0);
        w_cat_max_date      date;
        w_cat_min           number(4,0);
        w_cat_min_date      date;
    begin
        for i in curs loop
            -- get latest cat date
            select max(cat_score_date) into w_cat_latest_date
            from rbn_cat
            where customer_no = i.name_id_no
            and   cat_score_date <= i.incident_date;
            -- get latest cat score
            select cat_score into w_cat_latest
            from rbn_cat
            where customer_no = i.name_id_no
            and cat_score_date = w_cat_latest_date
            and rownum = 1;
            --get maximum cat score
            select max(cat_score) into w_cat_max
            from rbn_cat
            where customer_no = i.name_id_no
            and   months_between(i.incident_date,cat_score_date) between 0 and 12;
            --get maximum cat date
            select cat_score_date into w_cat_max_date
            from rbn_cat
            where customer_no = i.name_id_no
            and   cat_score = w_cat_max
            and   months_between(i.incident_date,cat_score_date) between 0 and 12
            and   rownum = 1;
            --get minimum cat score
            select min(cat_score) into w_cat_min
            from rbn_cat
            where customer_no = i.name_id_no
            and   months_between(i.incident_date,cat_score_date) between 0 and 12;
            --get minimum cat date
            select cat_score_date into w_cat_min_date
            from rbn_cat
            where customer_no = i.name_id_no
            and   cat_score = w_cat_min
            and   months_between(i.incident_date,cat_score_date) between 0 and 12
            and   rownum = 1;
            update MICHAELC.Food_Nov_01_final
                set cat_latest = w_cat_latest
                   , cat_latest_date = w_cat_latest_date
                   , cat_max  = w_cat_max
                   , cat_max_date = w_cat_max_date
                   , cat_min    = w_cat_min
                   , cat_min_date = w_cat_min_date
            where current of curs;
        end loop;
    end;
    I receive the following error:
    Error report:
    ORA-01403: no data found
    ORA-06512: at line 37
    01403. 00000 - "no data found"
    *Cause:   
    *Action:
    I want to use an exception statement, something along the lines of
    exception when no_data_found then
                w_cat_latest_date     := NULL;
                w_cat_latest          := NULL;
                w_cat_max             := NULL;
                w_cat_max_date        := NULL;
                w_cat_min             := NULL;
                w_cat_min_date        := NULL;I'm just not really sure how to use the exception statement correctly and if it is the best way to handle this error. Thank-you for your time and help.
    Banner:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    Like this;-
    declare   
        cursor curs is
         select name_id_no, incident_date
         from MICHAELC.Food_Nov_01_final t
         --where rownum < 6
         for update of cat_latest;
        w_cat_latest        number(4,0);
        w_cat_latest_date   date;
        w_cat_max           number(4,0);
        w_cat_max_date      date;
        w_cat_min           number(4,0);
        w_cat_min_date      date;
    begin
        for i in curs loop
            -- get latest cat date
    BEGIN
            select max(cat_score_date) into w_cat_latest_date
            from rbn_cat
            where customer_no = i.name_id_no
            and   cat_score_date <= i.incident_date;
    EXCEPTION
    when no_data_found then
                w_cat_latest_date     := NULL;
    END;       
    BEGIN
            -- get latest cat score
            select cat_score into w_cat_latest
            from rbn_cat
            where customer_no = i.name_id_no
            and cat_score_date = w_cat_latest_date
            and rownum = 1;
    EXCEPTION
    when no_data_found then
                w_cat_latest
         w_cat_latest:= NULL;
    END;       
    /*   you get the idea
            --get maximum cat score
            select max(cat_score) into w_cat_max
            from rbn_cat
            where customer_no = i.name_id_no
            and   months_between(i.incident_date,cat_score_date) between 0 and 12;
            --get maximum cat date
            select cat_score_date into w_cat_max_date
            from rbn_cat
            where customer_no = i.name_id_no
            and   cat_score = w_cat_max
            and   months_between(i.incident_date,cat_score_date) between 0 and 12
            and   rownum = 1;
            --get minimum cat score
            select min(cat_score) into w_cat_min
            from rbn_cat
            where customer_no = i.name_id_no
            and   months_between(i.incident_date,cat_score_date) between 0 and 12;
            --get minimum cat date
            select cat_score_date into w_cat_min_date
            from rbn_cat
            where customer_no = i.name_id_no
            and   cat_score = w_cat_min
            and   months_between(i.incident_date,cat_score_date) between 0 and 12
            and   rownum = 1;
            update MICHAELC.Food_Nov_01_final
                set cat_latest = w_cat_latest
                   , cat_latest_date = w_cat_latest_date
                   , cat_max  = w_cat_max
                   , cat_max_date = w_cat_max_date
                   , cat_min    = w_cat_min
                   , cat_min_date = w_cat_min_date
            where current of curs;
        end loop;
    end;
    /

  • XSL Looping Query for Short Text PO Attachments

    I am using XML Publisher to revise a custom Purchase Order.
    This is a sample skeleton layout of the XML data:
    <PO_DATA>
    <LINES>
         <LINES_ROW>
              <LINE_NUM>1</LINE_NUM>
              <ITEM_DESCRIPTION>blah1.</ITEM_DESCRIPTION>
              <PO_HEADER_ID>535404</PO_HEADER_ID>
              <PO_LINE_ID>879135</PO_LINE_ID>
              <LINE_SHORT_TEXT>
                   <LINE_SHORT_TEXT_ROW>
                        <PO_LINE_ID>879135</PO_LINE_ID>
                        <SHORT_TEXT>Attachment for line 1</SHORT_TEXT>
                   </LINE_SHORT_TEXT_ROW>
                   <LINE_SHORT_TEXT_ROW>
                        <PO_LINE_ID>879135</PO_LINE_ID>
                        <SHORT_TEXT>Another Attachment for line 1</SHORT_TEXT>
                   </LINE_SHORT_TEXT_ROW>
                   <LINE_SHORT_TEXT_ROW>
                        <PO_LINE_ID>879135</PO_LINE_ID>
                        <SHORT_TEXT>Header Attachment</SHORT_TEXT>
                   </LINE_SHORT_TEXT_ROW>
              </LINE_SHORT_TEXT>
         </LINES_ROW>
         <LINES_ROW>
              <LINE_NUM>2</LINE_NUM>
              <ITEM_DESCRIPTION>Blah2</ITEM_DESCRIPTION>
              <PO_HEADER_ID>535404</PO_HEADER_ID>
              <PO_LINE_ID>879136</PO_LINE_ID>
              <LINE_SHORT_TEXT>
                   <LINE_SHORT_TEXT_ROW>
                        <PO_LINE_ID>879136</PO_LINE_ID>
                        <SHORT_TEXT>Attachment for line 2</SHORT_TEXT>
                   </LINE_SHORT_TEXT_ROW>
                   <LINE_SHORT_TEXT_ROW>
                        <PO_LINE_ID>879136</PO_LINE_ID>
                        <SHORT_TEXT>Header Attachment</SHORT_TEXT>
                   </LINE_SHORT_TEXT_ROW>
              </LINE_SHORT_TEXT>          
         </LINES_ROW>
    </LINES>
    </PO_DATA>I would like to be able to list the bold lines (text attachments) on the PO.
    I have been able to list the first <SHORT_TEXT> attachment for the 1st line, but then all of the other attachments are not listed, and I can't work out why.
    This is the xsl / codey bits from the rtf template:
    <xsl:variable name="lineID" select="../../PO_LINE_ID" />  
    <xsl:for-each select="/PO_DATA/LINES/LINES_ROW/LINE_SHORT_TEXT/LINE_SHORT_TEXT_ROW/PO_LINE_ID">
    <xsl:if test="$lineID = .">
    <xsl:variable name="lineID" select="position()" />
    <xsl:value-of select="/PO_DATA/LINES/LINES_ROW/LINE_SHORT_TEXT/LINE_SHORT_TEXT_ROW/SHORT_TEXT[$lineID]" />
    </xsl:if>
    </xsl:for-each>I don't understand why the attachment for line1 (Attachment for line 1) is listed, but then none of the others are. Presumably I'm doing something stupid, but I can't work out what.
    edit - I've printed some of the variables out as the loop is incremented - the problem seems to be that the PO_LINE_ID is not incremented for the line in bold above. It just stays the same - hence why it works for the first line, where the PO_LINE_ID matches, and not for any of the other lines. So the problem is how to get that bold line to increment the PO_LINE_ID?Thanks
    null

    Sorry to labour the point.
    When I used this code against the XML:
    <xsl:for-each select="/PO_DATA/LINES/LINES_ROW">
    <xsl:value-of select="PO_LINE_ID" />
    <xsl:for-each select="./LINE_SHORT_TEXT/LINE_SHORT_TEXT_ROW">
    <xsl:value-of select="SHORT_TEXT" />
    </xsl:for-each></xsl:for-each>
    It generated this against every line:
    879135
    Attachment for line 1
    Another Attachment for line 1
    Header Attachment
    879136
    Attachment for line 2
    Header Attachment
    879137
    Attachment for line 3
    Header Attachment
    This is my reasoning for the code that works:
    <xsl:variable name="bobby1" select="../../PO_LINE_ID" />
    Make up a variable name, and give it the value of the current lines PO_LINE_ID
    <xsl:for-each select="/PO_DATA/LINES/LINES_ROW/LINE_SHORT_TEXT/LINE_SHORT_TEXT_ROW">
    Loop through XML structure e.g.:
    <LINE_SHORT_TEXT>
         <LINE_SHORT_TEXT_ROW>
              <PO_LINE_ID>879135</PO_LINE_ID>
              <SHORT_TEXT>Attachment for line 1</SHORT_TEXT> 
         </LINE_SHORT_TEXT_ROW>
         <LINE_SHORT_TEXT_ROW>
              <PO_LINE_ID>879135</PO_LINE_ID>
              <SHORT_TEXT>Another Attachment for line 1</SHORT_TEXT> 
         </LINE_SHORT_TEXT_ROW>
         <LINE_SHORT_TEXT_ROW>
              <PO_LINE_ID>879135</PO_LINE_ID>
              <SHORT_TEXT>Header Attachment</SHORT_TEXT> 
         </LINE_SHORT_TEXT_ROW>
    </LINE_SHORT_TEXT><xsl:variable name="bobby2" select="PO_LINE_ID" />
    And each time through the loop, assign the 'bobby2' variable the value of the PO_LINE_ID.
    <xsl:if test="$bobby1=$bobby2">
    This condition is neeed - because lets say that the 'PO_LINE_ID' of the current line is 879135, and the value of the 'PO_LINE_ID' listed in the LINE_SHORT_TEXT_ROW is 879136, then I don't want to output the value of the 'SHORT_TEXT' because it doesn't relate to the PO_LINE_ID of the line currently being checked. In your shorter code version, there is no checking to see if the PO_LINE_ID in the LINE_SHORT_TEXT_ROW section matches the parent PO_LINE_ID, so it just lists all LINE_SHORT_TEXT_ROW data, regardless of whether it is related to the parent line or not.
    <xsl:value-of select="SHORT_TEXT" />
    </xsl:if>
    </xsl:for-each>
    I'd be happy to email you over the .rtf and .xml file so you can see what I'm talking about.
    Thanks again for your time and help with this. As I said, without your initial help with the for-each loop I would not have fixed it.

  • Loopie Query

    Oh save me please.
    I have two computers running Logic Pro X on both with Yosemite. One of them seems to have a more extensive drum loop collection than the other - there were vintage drum machine loops which I adored on my first computer (a tower) and unfortunately these are absent when I open up the loops from my more recent installation of LPX on my laptop. What should I do to "locate" these other loops which I assumed were factory presets. There are drum loops present just not all and the ones I found especially useful are the ones not on the second computer.
    Do I make any sense to you who might be way more knowledgeable?
    thanks
    nt

    I think you are getting a little confused....
    Kontakt (I assume thats what you meant by Contact?) isn't part of Logic Pro X nor it's content...
    It's a 3rd party plugin from Native Instruments that uses it's own libraries you must purchase unless they came free with Kontakt....
    So, download and install those libraries  the same way as they were installed on your other Mac.... from whatever source you got them from.
    Additional:
    If you mean the Drum Machine you see in the Additional Content in Logic.. highlighted in this screenshot
    That isn't a collection of loops.... its a plugin found by opening up Logic's Library.... and selecting it from there...

  • Looping Query logic Needed

    Hi Team
    I have requirement below , can you please help me with sql logic
    My input table is below
    INC_NUM
    FA_ADD
    HZ_ADD
    PARENT_INC_NUM
    ID
    A0001
    A
    A
    A0001-02
    A
    A
    A0001
    1
    A0001-04
    B
    C
    A0001
    1
    A0001-05
    B
    C
    A0001
    1
    A0001-09
    B
    S
    A0001
    1
    A0001-07
    D
    A
    A0001
    1
    B0001
    J
    K
    B0001-03
    L
    M
    B0001
    2
    B0001-04
    J
    K
    B0001
    2
    B0001-05
    A
    B
    B0001
    2
    B0001-06
    A
    B
    B0001
    2
    B0001-07
    A
    B
    B0001
    2
    C0001-02
    A
    B
    C0001-03
    A
    C
    C0001-02
    3
    C0001-05
    A
    B
    C0001-02
    3
    My output
    INC_NUM
    FA_ADD
    HZ_ADD
    PARENT_INC_NUM
    A0001
    A
    A
    A0001-02
    A
    A
    A0001
    A0001-04
    B
    C
    A0001-05
    B
    C
    A0001-09
    B
    S
    A0001-07
    D
    A
    B0001
    J
    K
    B0001-03
    L
    M
    B0001-04
    J
    K
    B0001
    B0001-05
    A
    B
    B0001-06
    A
    B
    B0001-07
    A
    B
    C0001-02
    A
    B
    C0001-03
    A
    C
    C0001-05
    A
    B
    C0001-02
    Here i n considering  null values of parent_inc_num or null values of ID as Parent record  ID
    And i m comparing this record  FA_ADD and HZ_ADD with its child records FA_ADD and HZ_ADD ,If they matches then i m assigning Parent_INC_NUM else null
    Let me take example of record C0001-02, it has null values of PARENT_INC_NUM (or null for ID)
    So C0001-02 is considered as base record ,
    Now i m comparing FA_ADD and HZ_ADD values of C0001-02 with its child records FA_ADD and HZ-ADD (ie C0001-03,C0001-05 )
    C0001-03 doesnt match so i m assigning null in target else i m assigning its base record ie C0001-02
    Below is table sample data
    could you please help
    with t as
    (select 'A0001' as INC_NUM,'A' as FA_ADD,'A' as HZ_ADD ,null as PARENT_INC_NUM ,null as ID from dual
    union all
    select 'A0001-02' as INC_NUM,'A' as FA_ADD,'A' as HZ_ADD ,'A0001' as PARENT_INC_NUM ,1 as ID from dual
    union all
    select 'A0001-04' as INC_NUM,'B' as FA_ADD,'C' as HZ_ADD ,'A0001' as PARENT_INC_NUM ,1 as ID from dual
    union all
    select 'A0001-05' as INC_NUM,'B' as FA_ADD,'C' as HZ_ADD ,'A0001' as PARENT_INC_NUM , 1 as ID from dual
    union all
    select 'A0001-09' as INC_NUM,'B' as FA_ADD,'S' as HZ_ADD ,'A0001' as PARENT_INC_NUM,1 as ID from dual
    union all
    select 'A0001-07' as INC_NUM,'D' as FA_ADD,'A' as HZ_ADD ,'A0001' as PARENT_INC_NUM,1 as ID from dual
    union all
    select 'B0001' as INC_NUM,'J' as FA_ADD,'K' as HZ_ADD ,null as PARENT_INC_NUM , null as ID from dual
    union all
    select 'B0001-03' as INC_NUM,'L' as FA_ADD,'M' as HZ_ADD ,'B0001' as PARENT_INC_NUM,2 as ID from dual
    union all
    select 'B0001-04' as INC_NUM,'J' as FA_ADD,'K' as HZ_ADD ,'B0001' as PARENT_INC_NUM ,2 as ID from dual
    union all
    select 'B0001-05' as INC_NUM,'A' as FA_ADD,'B' as HZ_ADD ,'B0001' as PARENT_INC_NUM,2 as ID from dual
    union all
    select 'B0001-06' as INC_NUM,'A' as FA_ADD,'B' as HZ_ADD ,'B0001' as PARENT_INC_NUM,2 as ID from dual
    union all
    select 'B0001-07' as INC_NUM,'A' as FA_ADD,'B' as HZ_ADD ,'B0001' as PARENT_INC_NUM,2 as ID  from dual
    union all
    select 'C0001-02' ,'A','B',null,null from dual
    union all
    select 'C0001-03','A','C','C0001-02',3 from dual
    union all
    select 'C0001-05','A','B','C0001-02',3 from dual
    select * from t
    I have 100 thousands of records of this  data ,so need to take care of performance as well
    Thank you
    Sumanth

    with t as
    (select 'A0001' INC_NUM,'A' FA_ADD,'A' HZ_ADD ,null as PARENT_INC_NUM ,null as ID from dual union all
    select 'A0001-02','A','A','A0001',1 from dual union all
    select 'A0001-04','B','C','A0001',1 from dual union all
    select 'A0001-05','B','C','A0001',1 from dual  union all
    select 'A0001-09','B','S','A0001',1 from dual union all
    select 'A0001-07','D','A','A0001',1 from dual union all
    select 'B0001','J','K',null,null from dual union all
    select 'B0001-03','L','M','B0001',2 from dual union all
    select 'B0001-04','J','K','B0001',2 from dual union all
    select 'B0001-05','A','B','B0001',2 from dual union all
    select 'B0001-06','A','B','B0001',2 from dual union all
    select 'B0001-07','A','B','B0001',2 from dual union all
    select 'C0001-03' ,'A','B',null,null from dual union all
    select 'C0001-02','A','C','C0001-03',3 from dual union all
    select 'C0001-05','A','B','C0001-03',3 from dual union all
    select 'C0001-06','A','B','C0001-03',3 from dual
    select INC_NUM,FA_ADD,HZ_ADD,
           case when fa_add = connect_by_root fa_add
                 and hz_add = connect_by_root hz_add
                then parent_inc_num
           end parent_inc_num
      from t
    start with parent_inc_num is null
    connect by prior inc_num = parent_inc_num
    INC_NUM
    FA_ADD
    HZ_ADD
    PARENT_INC_NUM
    A0001
    A
    A
    A0001-02
    A
    A
    A0001
    A0001-04
    B
    C
    A0001-05
    B
    C
    A0001-07
    D
    A
    A0001-09
    B
    S
    B0001
    J
    K
    B0001-03
    L
    M
    B0001-04
    J
    K
    B0001
    B0001-05
    A
    B
    B0001-06
    A
    B
    B0001-07
    A
    B
    C0001-03
    A
    B
    C0001-02
    A
    C
    C0001-05
    A
    B
    C0001-03
    C0001-06
    A
    B
    C0001-03
    Regards
    Etbin

  • Query or Loop

    Hi,
    I need help or suggestions in writing a pl/sql loop query against the data in Table A in order to get the output of Table B.
    Table A               
    id     type     valu     
    1     a     x     
    1     a     y     
    1     a     x     
    1     b     3     
    1     c     33     
    2     a     x     
    2     b     55     
    2     c     33     
    The output should be inserted in a new table.The expected output
    Table B output               
    id     list_a     List_B     List_C
    1     x,y,x     3     33
    2     x     55     33
    Thanks

    Try this
    SQL> with t
      2  as
      3  (
      4  select 1 id, 'a' type, 'x' value from dual union all
      5  select 1 id, 'a' type, 'y' value from dual union all
      6  select 1 id, 'a' type, 'x' value from dual union all
      7  select 1 id, 'b' type, '3' value from dual union all
      8  select 1 id, 'c' type, '33' value from dual union all
      9  select 2 id, 'a' type, 'x' value from dual union all
    10  select 2 id, 'b' type, '55' value from dual union all
    11  select 2 id, 'c' type, '33' value from dual
    12  )
    13  select id, max(decode(type, 'a', value)) list_a, max(decode(type, 'b', value)) list_b, max(decode(type, 'c', value)) list_c
    14    from (
    15            select id, type, max(value) value
    16              from (
    17                      select id, type, ltrim(sys_connect_by_path(value, ','),' ,') value
    18                        from (
    19                               select t.*, row_number() over(partition by id, type order by 1) rno
    20                                 from t
    21                             )
    22                       start with rno = 1
    23                      connect by rno = prior rno + 1
    24                         and id = prior id
    25                         and type = prior type
    26                   )
    27             group by id, type
    28         )
    29   group by id
    30  /
            ID LIST_A     LIST_B     LIST_C
             1 x,y,x      3          33
             2 x          55         33
    SQL>

  • CFMAIL Any Faster In CF8? How many mails per minute?

    Hi there,
    We are currently running CF 7.02 and are considering
    upgrading to 8.
    I've seen lots of articles extolling the speed increases in
    CF8 over 7 etc. but I wondered if there was much of a performance
    increase in regards to CFMAIL?
    We send out vast quantities of emails every day and at busy
    times CFMAIL struggles to keep up. Mails seem to be sent out quick
    enough to our mail server but it seems to be the physical process
    of creating the cfmail files ready for sending that is a little
    slow.
    I think I read somewhere that under CF7 CFMAIL could create
    about 600 CFMAIL files a minute. Does anyone know what the figure
    is for CFMAIL under CF8?
    Or does anyone have any real world experience of CFMAIL
    speeding up or slowing down following an upgrade from CF 7 to 8?
    If this is still slow does anyone have any experience of
    using third party, dedicated, products to do what CFMAIL does? The
    mails we send are stored as entries in our SQL DB and we currently
    use CFMAIL to query the DB and produce html and plain text emails
    from these entries. Is there anything that we coul use to do that
    and take CFMAIL out of the loop?
    Cheers,
    Tem

    Hi there,
    We are currently running CF 7.02 and are considering
    upgrading to 8.
    I've seen lots of articles extolling the speed increases in
    CF8 over 7 etc. but I wondered if there was much of a performance
    increase in regards to CFMAIL?
    We send out vast quantities of emails every day and at busy
    times CFMAIL struggles to keep up. Mails seem to be sent out quick
    enough to our mail server but it seems to be the physical process
    of creating the cfmail files ready for sending that is a little
    slow.
    I think I read somewhere that under CF7 CFMAIL could create
    about 600 CFMAIL files a minute. Does anyone know what the figure
    is for CFMAIL under CF8?
    Or does anyone have any real world experience of CFMAIL
    speeding up or slowing down following an upgrade from CF 7 to 8?
    If this is still slow does anyone have any experience of
    using third party, dedicated, products to do what CFMAIL does? The
    mails we send are stored as entries in our SQL DB and we currently
    use CFMAIL to query the DB and produce html and plain text emails
    from these entries. Is there anything that we coul use to do that
    and take CFMAIL out of the loop?
    Cheers,
    Tem

  • Simple Query Help Needed

    I must not be in the right mode today, because this is giving
    me a hard time...
    I have a SQL Server database with 250,000 records. Each
    record represents a medical visit.
    Each record has 25 fields that contain patient diagnosis. A
    visit may show one diagnosis, or it may show as many as 25. Any
    specific diagnosis (250.00 for example) may appear in a field
    called Code1, or a field called Code2.... Code25.
    There are a total of about 500 patients that make up the
    250,000 visits.
    What I need is a report that shows each DISTINCT diagnosis,
    and a listing (and count) of people that have been assigned that
    diagnosis.
    My thought is to first query the table to arrive at the
    unique list of diagnosis codes. Then, in a nested loop, query the
    database to see who has been assigned that code, and how many
    times.
    This strikes me as an incredibly database intensive query,
    however.
    What is teh correct way to do this?

    The correct way to do this is to normalize your database.
    Rather than having 25 separate colums that essentially
    contain the same data (different codes), break that out into a
    separate table.
    Patient
    patientid
    Visit
    patientid (foreign key referencing Patient)
    visitid
    Diagnosis
    visitid (foreign key referencing visitid in Visit)
    diagnosiscode
    order (if the 1-25 ordering of diagnosis codes is important)
    Once you correct your datamodel, what you're trying to do
    becomes simple.
    -- get all diagnosis codes
    select distinct(diagnosiscode) from diagnosis
    -- get a breakdown of diagnosis codes, patients, and counts
    for that diagnosis
    select diagnosiscode, patient.name, count(diagnosiscode) from
    patient left join visit on (patient.patientid =
    visit.patientid)
    left join diagnosis on (visit.visitid = diagnosis.visitid)
    group by diagnosiscode, patient.name

  • Using XML clob in loop

    Hi,
    I need to extract data from a given piece of XML. If I pass the xml to the procedure as clob and query it in a loop, it returns no rows. However if I include the actuall xml in the loop query it returns the data I'm looking for. Why doesn't it return data when using the clob?
    1. Example code below works with xml included in the loop query:
    BEGIN
       FOR x IN (    SELECT x.*
                       FROM XMLTABLE (
                               xmlnamespaces (
                                  'http://schemas.xmlsoap.org/soap/envelope' AS "x",
                                  'http://www.w3.org/2001/XMLSchema-instance' AS "xsi"),
                               PASSING xmltype (
                                          '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Body>
          <loadServiceListResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <loadServiceListReturn href="#id0"/>
          </loadServiceListResponse>
          <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:ExternalSystemOutput" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="java:ExternalSystemOutput.TestIPA.nhsia.nhs">
             <standardOutput href="#id1"/>
             <systemData soapenc:arrayType="ns2:ExternalSystemData[2]" xsi:type="soapenc:Array" xmlns:ns2="java:ExternalSystemData.TestIPA.nhsia.nhs">
                <systemData href="#id2"/>
                <systemData href="#id3"/>
             </systemData>
          </multiRef>
          <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:ExternalSystemData" xmlns:ns3="java:ExternalSystemData.TestIPA.nhsia.nhs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <description xsi:type="soapenc:string">Prescription</description>
             <url xsi:type="soapenc:string">http://192.168.21.131:8080/nhsia/TestIPA/validate.jsp?sdwlhqw@5)vhuylfh@Suhvfulswlrq33509</url>
          </multiRef>
          <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:StandardOutput" xmlns:ns4="java:StandardOutput.TestIPA.nhsia.nhs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <auditID xsi:type="soapenc:string"/>
             <statusID xsi:type="soapenc:string">0</statusID>
             <systemAvailability xsi:type="soapenc:string">Available</systemAvailability>
          </multiRef>
          <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:ExternalSystemData" xmlns:ns5="java:ExternalSystemData.TestIPA.nhsia.nhs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <description xsi:type="soapenc:string">Appointment</description>
             <url xsi:type="soapenc:string">http://192.168.21.131:8080/nhsia/TestIPA/validate.jsp?vgzoktzC8,ykx|oikCGvvuotzsktz61409</url>
          </multiRef>
       </soapenv:Body>
    </soapenv:Envelope>').
                                       EXTRACT (
                                          '//multiRef',
                                          'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
                               COLUMNS description VARCHAR2 (30) PATH 'description',
                                       url VARCHAR2 (250) PATH 'url') x)
       LOOP
          DBMS_OUTPUT.PUT_LINE('Rec:  '||x.description||' '||x.url);
       END LOOP;
    END;
    /Returns:
    Rec:  
    Rec:  Prescription http://192.168.21.131:8080/nhsia/TestIPA/validate.jsp?sdwlhqw@5)vhuylfh@Suhvfulswlrq33509
    Rec:  
    Rec:  Appointment http://192.168.21.131:8080/nhsia/TestIPA/validate.jsp?vgzoktzC8,ykx|oikCGvvuotzsktz614092. If I assign the XML to CLOB variable and reference the clob variable in loop query it returns no data:
    DECLARE
       resp   CLOB :=             
                       '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Body>
          <loadServiceListResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <loadServiceListReturn href="#id0"/>
          </loadServiceListResponse>
          <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:ExternalSystemOutput" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="java:ExternalSystemOutput.TestIPA.nhsia.nhs">
             <standardOutput href="#id1"/>
             <systemData soapenc:arrayType="ns2:ExternalSystemData[2]" xsi:type="soapenc:Array" xmlns:ns2="java:ExternalSystemData.TestIPA.nhsia.nhs">
                <systemData href="#id2"/>
                <systemData href="#id3"/>
             </systemData>
          </multiRef>
          <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:ExternalSystemData" xmlns:ns3="java:ExternalSystemData.TestIPA.nhsia.nhs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <description xsi:type="soapenc:string">Prescription</description>
             <url xsi:type="soapenc:string">http://192.168.21.131:8080/nhsia/TestIPA/validate.jsp?sdwlhqw@5)vhuylfh@Suhvfulswlrq33509</url>
          </multiRef>
          <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:StandardOutput" xmlns:ns4="java:StandardOutput.TestIPA.nhsia.nhs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <auditID xsi:type="soapenc:string"/>
             <statusID xsi:type="soapenc:string">0</statusID>
             <systemAvailability xsi:type="soapenc:string">Available</systemAvailability>
          </multiRef>
          <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:ExternalSystemData" xmlns:ns5="java:ExternalSystemData.TestIPA.nhsia.nhs" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
             <description xsi:type="soapenc:string">Appointment</description>
             <url xsi:type="soapenc:string">http://192.168.21.131:8080/nhsia/TestIPA/validate.jsp?vgzoktzC8,ykx|oikCGvvuotzsktz61409</url>
          </multiRef>
       </soapenv:Body>
    </soapenv:Envelope>';
    BEGIN
       FOR x IN (    SELECT x.*
                       FROM XMLTABLE (
                               xmlnamespaces (
                                  'http://schemas.xmlsoap.org/soap/envelope' AS "x",
                                  'http://www.w3.org/2001/XMLSchema-instance' AS "xsi"),
                               PASSING xmltype (resp).
                                       EXTRACT (
                                          '//multiRef',
                                          'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
                               COLUMNS description VARCHAR2 (30) PATH 'description',
                                       url VARCHAR2 (250) PATH 'url') x)
       LOOP
          DBMS_OUTPUT.PUT_LINE('Rec:  '||x.description||' '||x.url);
       END LOOP;
    END;
    /I would appreciate any help this one.
    Cheers,
    Andy.

    Why do you have 4 rows? I don't understand why you have two rows for 100 bottles?
    Building on Odie's answer and my example plus adding in the needed outer join we have, using Oracle's outer join syntax of (+)
    SQL> with my_sample_table as (
      2      select xmltype('<?xml version="1.0" encoding="UTF-8" ?>
      3  <request>
      4  <identification>
      5  <requestid>12345</requestid>
      6  <periodunit>DAY</periodunit>
      7  <days>MONDAY</days>
      8  </identification>
      9  <product>
    10  <productname>ABC PRODUCT</productname>
    11  <brand>
    12  <brandname>CELL</brandname>
    13  <ndccode>A58048</ndccode>
    14  <ndccode>A49210</ndccode>
    15  </brand>
    16  </product>
    17  <product>
    18  <productname>100 bottles</productname>
    19  </product>
    20  </request>') xmldoc
    21      from dual
    22    )
    23  select x.*, y.*
    24    from my_sample_table t
    25       , xmltable(
    26          'let $e := $d/request/identification
    27           for $i in $d/request/product
    28           return element r {
    29             $e/requestid
    30           , $e/days
    31           , $e/periodunit
    32           , $i/productname
    33           , $i/brand/brandname
    34           , $i/brand/ndccode
    35           }'
    36          passing t.xmldoc as "d"
    37          columns requestid  number       path 'requestid'
    38                , days       varchar2(30) path 'days'
    39                , periodunit varchar2(10) path 'periodunit'
    40                , prductname varchar2(20) path 'productname'
    41                , brandname  varchar2(20) path 'brandname'
    42                , ndccodexml xmltype      path 'ndccode'
    43         ) x,
    44         xmltable('/ndccode'
    45                  PASSING x.ndccodexml
    46                  COLUMNS
    47                  ndccode    VARCHAR2(10) PATH '.') (+) y;
    REQUESTID DAYS                           PERIODUNIT PRDUCTNAME           BRANDNAME            NDCCODEXML                                                                       NDCCODE
         12345 MONDAY                         DAY        ABC PRODUCT          CELL                 <ndccode>A58048</ndccode><ndccode>A49210</ndccode>                               A58048
         12345 MONDAY                         DAY        ABC PRODUCT          CELL                 <ndccode>A58048</ndccode><ndccode>A49210</ndccode>                               A49210
         12345 MONDAY                         DAY        100 bottles                                                                                                                If you prefer the ANSI syntax it would be (just showing changed section)
           ) x
           LEFT OUTER JOIN
           xmltable('/ndccode'
                    PASSING x.ndccodexml
                    COLUMNS
                    ndccode    VARCHAR2(10) PATH '.') y
           ON 1=1;

  • Sort problem on dynamic query !!

    Hi,
    I have a dynamic query written in pl/sql, when I check "Sort" for each field in Report Attribute, error message raised up as "ORA-01785: ORDER BY item must be the number of a SELECT-list expression".
    If I do not check Sort, it works fine. In my apps I need all fields sorted by user, how to fix this problem?
    My query as below:
    declare
    query varchar2(2000):='select';
    s_class varchar2(1000);
    cursor c1 is select * from demo_preference;
    begin
    for c1_val in c1 loop
    if c1_val.login is not null then
    query := query ||' ' || 'login' || ',';
    end if;
    if c1_val.id is not null then
    query := query ||' ' || 'id' || ',';
    end if;
    end loop;
    query := SUBSTR(query, 1, length(query)-1);
    s_class := '(NVL(:P2_class, ''%'' || ''null%'') = ''%'' || ''null%'' OR
    EXISTS (SELECT 1 FROM apex_collections WHERE collection_name = ''P2CLASSCOL'' AND c001 = class))';
    query := query ||' ' || 'from ming.reg_report_view1 where'
    || ' ' || s_class;
    return(query);
    end;

    Maybe the internally mapped column used when you clicked on sort is not shown in the report. Try using aliases when you construct the query string, it could help apex internally in identifying a column even if its order changes for a different user. After all the column order in the code is dynamic and I guess even the no of columns displayed might vary both of which could make sorting on a column identified with a number, invalid.
    How about displaying the report query somewhere, so that you know what is the exact query being processed, it might give you better information about the problem.
    If the problem persists, then use a collection that is fetched those record using the same query string and change the report to refer the collection and then set column sorting on. This way apex would get confused on what columns are being sorted and it would just sort on a c001..c050 column as though it was a string(yes problems with number columns sorting when you do this).

  • How u guys build query in program

    Hey guys,
    i was wondering how u guys build queries in the program. i mean if you use String or StringBuffer. e.g.
    SELECT * FROM MY_TABLE WHERE X=someValue and Y=someValue and Z= someValue. if i use String i have to use + operator to get the values at runtime and which causes problem with performence. and when i use StringBuffer its kind of cumbersome. whats the best way you guys find for building queries at run time.
    appreciate the time you have taken to read this.
    take care and have a good day.

    Hi
    yes i'm creating the query in a loop. query is very
    big like 2 page long. basically i've to join data from
    many tables and many filter criteria entered by the
    clients which i put in the where clause. we r running
    optimizers on our application and it shows query
    building processes are making the overall performence
    slow.
    First you limit the query in some fashion (if you don' t then you might as well just give them a text box and let them type SQL.)
    In your case that might be limiting it to a query on all of the five tables.
    Second you produce a query DTO.
    A standard DTO might look like this....
           class CustomerDTO
             public String customerName;
             public double accountBalance;
      A query DTO, built to match the above, would look like this....
           class CustomerQueryDTO
             public String customerName1;
             public String customerName2;
             public OperatorType customerNameOperator;
            public double accountBalance1;
            public double accountBalance2;
            public OperatorType accountBalanceOperator;
          }And OperatorType would allow equality, between (which is why there are two parameters), greater than, etc
    You build the query string as follows
           CustomerQueryDTO query = ...
           StringBuffer b = new StringBuffer();
           b.append("select ");
           b.append(fieldList);
           b.append(" from ");
           b.append(tableList);
           b.append("where 1=1");
           if (query.customerNameOperator != null)
                b.append(" and ");
                String exp = createExpression(query.customerName1,
                                       query.customerName2,
                                       query.customerNameOperator );
                b.append(exp);
         String sql = b.toString(); 
    You also want to make sure that a query actually is limited by something. So the query must have at least one clause.

  • Inserting a list with 1 query

    Hi
    I have a list of email addresses seperated by a comma.
    I want to insert all of those email address into a table using 1 query.
    Is that possible?
    Here is my the list i have...
    <Cfset mylist = "[email protected],[email protected],[email protected],[email protected],[email protected]">
    Is it possible to insert using 1 query?
    Thanks in advance.
    Regards
    Delon

    Hi Delon
    I see now exactly what you're getting at and I see what you mean by only wanting to do one insert.
    People have different styles and I always believe that if it works then it's a successful solution, but just to make you aware of other options: If it were me (and I know it's not, but this is my opinion and there's no-one here to stop me ) I'd do the following:
    Get emails
    Loop query (very efficient in CF)
      Try
        Do whatever processing necessary, REFinds, auditing etc
        Do an insert into your database - also very efficient
        Delete email from inbox
      Catch
        Error handler
      End try
    /End Loop query
    So yes you're doing lots of inserts but you're not using any List functionality. Bear in mind lists aren't like Arrays or Querysets - there are no fixed memory points CF can index in order to find the next value, it has to scan through character by character looking for your delimiter. I've always been advised to keep away from lists for this very reason, especially if they get quite long as in this case.
    This method also allows for error handling on an email-by-email basis - say you use a list; you loop however many emails and something goes wrong at the last index. Your script falls over and has to start again from the start. Using the try/catch methodology gets around this and means you don't end up reprocessing the same emails more than once.
    As I say it largely ends up the same, but the whole point of these forums is to make people aware of what's possible, not to tell them what to do.
    Hope that helps.
    O.

Maybe you are looking for

  • Video won't play on certain websites

    Hi, I'm having some trouble with the adobe flash player.  It will play in some websites like YouTube without a problem; however in other websites, like cnn or msnbc, it won't show the videos (the audio will still work, I just get a white box where th

  • Connect internet from laptop to iphone

    hey guys i like to connect internet to iphone ....i have internet connection in my laptop so v can connect internet via wifi .........first v want to setup wireless internet i mean by laptop router v can connect iphone. my question is .. how to creat

  • Sun access Manager session failover

    Hi, I am trying to install Sun Access Manager (2005Q1) with Session failover. I have hardware load balancer under which i have configuring Access Manager on two seperate boxes. For session failover i have configured Berkelay database on both system b

  • Regarding Patches While Installing XI

    Hi Experts, I want to Know Some Info... Regarding Applying the Patches while Installing the XI . 1...Do we need to Apply the Patches while Installing the XI?????????? 2...If YES When we need to do that???????What is the Need of that 3...In the Pre In

  • LV acquire the print information from the embed board with Linux system through serial port

    I want to acquire the print information by LV from the embed board with Linux system through serial port, like the window hyperterminal tool? I try to use VISA serial config function to achieve it ,but lost and prompt that is error like attachment. I