Need to insert a multiple select list as individual records

i have one list that is popluated with names and the names
have a unique number assigned to them
The other list is populated with county names and they also
have a number assigned to them
As the code is now it will not work because, the loop is in
the wrong place, I think??
CF throws an error saying invalid data type because it is
trying to insert "1,2,3,4,5,6,etc..."
I changed the data type to text so it would atleast accept
the insert, which worked but that is not what i want. I then
changed it backed to numeric, but get the invalid data type error.
The database would look like this if changed to text data
type:
personnel_ID countyID
1 1,2,3,4,5,6
i want it to look like this:
personnel_ID countyID
1 1
1 2
1 3
1 4
1 5
etc.....
I somehow need a loop to check and see if a county is
selected and then insert the personnel_ID and countyID into one
record, then check the next county and so on.
below is my code.........Any help would be greatly
appreciated
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND
FORM.MM_InsertRecord EQ "form2">
<cfquery datasource="wildlife_nwco"
name="insertCounties">
<cfloop index="listElement" list="#form.countyID#">
INSERT INTO countiesWorked (personnel_ID, countyID)
VALUES (
<cfif IsDefined("FORM.personnel_ID") AND
#FORM.personnel_ID# NEQ "">
<cfqueryparam value="#FORM.personnel_ID#"
cfsqltype="cf_sql_numeric">
<cfelse>
NULL
</cfif>
<cfif IsDefined("FORM.countyID") AND #FORM.countyID# NEQ
"">
<cfqueryparam value="#FORM.countyID#"
cfsqltype="cf_sql_numeric">
<cfelse>
NULL
</cfif>
</cfloop>
</cfquery>
</cfif>
<cfquery name="personnel" datasource="wildlife_nwco">
SELECT *
FROM personnel
ORDER BY personnel.lastName
</cfquery>
<cfquery name="county" datasource="wildlife_nwco">
SELECT *
FROM countyID
ORDER BY countyID.countyName
</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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" name="form2"
action="<cfoutput>#CurrentPage#</cfoutput>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Name of NWCO::</td>
<td><select name="personnel_ID">
<cfoutput query="personnel">
<option value="#personnel.personnel_ID#" <cfif
(isDefined("personnel.personnel_ID") AND personnel.personnel_ID EQ
personnel.personnel_ID)>selected</cfif>>#personnel.lastName#,
#personnel.firstName#</option>
</cfoutput>
</select>
</td>
<tr>
<tr valign="baseline">
<td nowrap align="right">Counties Worked:</td>
<td><select name="countyID" size="10"
multiple="multiple">
<cfoutput query="county">
<option value="#county.countyID#" <cfif
(isDefined("county.countyID") AND county.countyID EQ
county.countyID)>selected</cfif>>#county.countyName#</option>
</cfoutput>
</select>
</td>
<tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert
record"></td>
</tr>
</table>
<input type="hidden" name="MM_InsertRecord"
value="form2">
</form>
<p> </p>
</body>
</html>

You are on the right track. Most dbs do not allow mulitple
queries in a single cfquery tag. Put your query in the loop instead
of the the loop in the query. Also, your countyid will be
ListElement, not form.countyId.

Similar Messages

  • Inserting multiple rows into a table using a multiple-select list

    I'm trying to figure out how to take the output of a multiple-select list (":" separated list of values) and use that to update a table by inserting multiple rows based on the values. Is there a straight-forward way to do that in APEX?
    Thanks.
    Chris

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Multiple selection lists in abap report

    I need to populate a multiple selection list and then read the selection in an ABAP report. A parameter with list box is not solving my purpose.
    Please give any suggestion on this.

    Hi
    If you can't use the SELECT-OPTION statament, there's no standard solution.
    U can only try to create a table control with only one colunm and every hit of the table control is a single hit for the selection.
    To insert a table control in a selection-screen u need to use the statament:
    SELECTION-SCREEN BEGIN OF TABBED (see the help)
    In order to create a TAB where u can load a subscreen where u can insert a table control.
    The u need to transfer the hit from table control to a range.
    Max

  • Multiple selection list and passing that value to oracle reports

    Hi
    I need to create a multiple selection list and then based on use selection, I need to pass that value to oracle reports. Can any one help with steps on how I can do this. Thanks

    Hi
    Concatenate the multiple values into a string separated by comma and then pass that string to report as a parameter.
    In report query, you have to use the lexical parameter using ' & '
    regards
    SD

  • Insert items from two different Multiple Select Lists into a single table

    I need help. I have a training tracking system that tracks the courses taken by employees.
    I have created two multiple select lists, one is SelectEmployees and the other is SelectCourses. I want to insert
    the selected item from those two multiple select lists into Training_Record table.
    Note, SelectEmployees" is from Employee table and SelectCourses is from Courses table. Those two table has no intersetion.
    Train_Record is the table that joins those two together.
    Please advice and your help is appreciate.

    Thank you for your help.
    I tried your code and changed the table/field name to my actual table/field name and the iitem name to actual item name.
    declare
    cursor c_Employees is
    select PERSONNEL_NEW.EMPLOYEEID from PERSONNEL_NEW where PERSONNEL_NEW.EMPLOYEEID in (:P15_SELECTEDEMP);
    cursor c_Courses is
    select COURSES.COURSE_ID from COURSES where COURSES.COURSE_ID in
    (:P15_SELECTEDCOUR);
    begin
    foreach :=r_employee in c_Employees loop
    foreach :=r_course in c_Courses loop
    insert
    into COPYOFTRAINREC ( EMPLOYEEID, COURSEID )
    values ( r_employee.EMPLOYEEID, r_course.COURSE_ID );
    end loop;
    end loop;
    end;
    I got error message as :
    ORA-06550: line 12, column 25: PLS-00103: Encountered the symbol "C_EMPLOYEES" when expecting one of the following: (
    Error
    OK

  • Multiple Select List does not Refresh with Dynamic Action

    All,
    Scenario:
    Using APEX 4.2.2, I have a Select List page item (P4_SPONSOR) set to allow multiple values which has a dynamic LOV to populate the list.  What I would like to do is highlight the display values based on another page item's value (P4_DRIVER_ID).  When I set the source of P4_SPONSOR to static text, such as a delimited string of 1:2:3:4, any display values where the return values are equal to the static text are highlighted when the page loads.
    Problem:
    The problem lies in trying to use a query as a source for P4_SPONSOR which is filtered based on the other page item, P4_DRIVER_ID.  For instance, my SQL Query (returning colon separated values) returns the same as the static text noted above.  In the query's WHERE clause, I specify that the driver's ID is equal to P4_DRIVER_ID:
    SELECT sponsor_id
    FROM sponsors_drivers_xref
    WHERE driver_id = :P4_DRIVER_ID;
    This, as I understand it, would necessitate a refresh of P4_SPONSOR whenever the value of P4_DRIVER_ID changes.  So, I have a Dynamic Action that does just that.  When executed on the page, I can see the P4_SPONSOR multiple select list actually refresh, but none of the display values become highlighted.
    Thoughts?
    Thanks,
    -Seth.

    Seth,
    A dynamic action refresh of your select list will refresh the list of values (this is what you are seeing), it will not refresh the value of the item itself.  In fact, it will remove any values that you had already selected.  To refresh the value you will need to add additional dynamic actions.
    Create another dynamic action with:
    Event: After Refresh
    Selection Type: Item(s)
    Item(s): P4_SPONSOR
    If this was a normal select list you could just create a Set Value action and use your query to set the value of the select list.  Since this is a multiple select list your will need to get your colon delimited value first and then use some javascript to set the values of your select list.
    Create an hidden page item name P4_SPONSOR_TEMP.
    Add a true action to your new dynamic action:
    Action: Set Value
    Set Type: SQL Statement
    SQL Statement:
    SELECT sponsor_id
    FROM sponsors_drivers_xref
    WHERE driver_id = :P4_DRIVER_ID;
    Page Items to Submit: P4_DRIVER_ID
    Selection Type: Item(s)
    Item(s): P4_SPONSOR_TEMP
    Add another true action to your new dynamic action:
    Action: Set Value
    Set Type: JavaScript Expression
    JavaScript Expression:
    $("#P4_SPONSOR_TEMP").val().split(":")
    Selection Type: Item(s)
    Item(s): P4_SPONSOR
    --Jeff

  • How to submit a multiple-selection list box in an Infopath Sharepoint form as multiple entries on a Sharepoint list?

    I would like to be able to submit an Infopath form with a multiple selection list box in Sharepoint as multiple entries on a Sharepoint list.
    For example, a user has to complete the following fields:
    First Name:
    Last Name:
    Favorite Color (can select more than one):
    [] Blue
    [] Red
    [] Yellow
    [] Green
    If the user picks blue AND red and submits the form, the Sharepoint list would feature TWO entries, both with their first and last names, but with different colors in the "Favorite Color" column.
    Please let me know if there is a way to do this. Any guidance would be helpful!

    Hi redhotc,
    According to your description, my understanding is that you want to set multiple default values for a multiple checkbox list in InfoPath form.
    I did a test with SQL database table. I set three default values for the checkbox list by adding three values field under the group field(Data->Default values), each value field is for a default value. Then publish it to my SharePoint site, everything
    was fine.Please have a try as the below link:
    http://www.bizsupportonline.net/infopath2010/pre-select-items-multiple-selection-list-box-infopath-2010.htm
    Note: if you are using SQL databse table, you may need to enable ‘Allow cross-domain data access for user form templates that use connection settings in a data connection file’ in CA. More information, please refer to:
    http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010customization.aspx?ID=418b9423-a96c-4e5e-91f9-6a1b010ebb69
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Multiple select list in Safari 8.1 is broken again

    Multiple select list is broken again in iOS 8.0.* and 8.1 Safari.
    Few temp solutions can be found here until apple fixes this issue again.
    Multiple Select box does not retain selected choice
    Multiple Select on Safari - iPhone iOS 7

    Reinstalling OS X Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall OS X: Select Reinstall OS X and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.
    Also see:
    Reinstall OS X Without Erasing the Drive
    OS X Yosemite- Reinstall OS X
    OS X Mavericks- Reinstall OS X
    OS X Mountain Lion- Reinstall OS X
    OS X Lion- Reinstall Mac OS X
         Note: You will need an active Internet connection. I suggest using Ethernet
                     if possible because it is three times faster than wireless.

  • Multiple-Selection List Box Values in Multiple Columns

    I am using InfoPath 2010 with SharePoint 2013. I have a form with a multiple-selection list box which has A LOT of choices. Instead of displaying all the choices in one column, is it possible to display the values of my list box in several
    columns? 

    Hi Andrea,
    I agree with Brij, one multiple-selection list box is associated with one list field, we cannot use the one multiple selection list box value for other multiple selection list boxes, we need to create multiple choices for each multiple-selection list box
    control in InfoPath form.
    Thanks
    Daniel Yang
    TechNet Community Support

  • Set focus on item that selected in multiple-selection list box field in infopath

    Hi
    I have  multiple-selection list box field in infopath that have for example 40 items. (I customize sharepoint list with infopath),then
     publish infopath form in to sharepoint list. users want to add new item,when they selected or checked each item in multiple selection list box, after that automatically control focus on first item, but I want to focus remain on that item
    I was selected. Why this happen?! I also set postback settings to “never” in multiple-selection list box properties. But didn’t work.
    Thanks.

    Hi,
    According to your post, my understanding is that you wanted  to find several columns based on user selection of checkboxes in one of the Multiple-selection List Box.
    I recommend to customize the form to concatenate values from choice field (with multiple values) into single line text box, and then hide the fields based on the text box value.
    We can follow the steps as following:
    Add a text box control(filed 3) on the form to hold the value selection in the multiple selection list box.
    Set the default value for the text box control as
    substring-after(eval(eval(Value, 'concat(., ";")'), ".."), ";")
    (you need to change the ‘Value’ in the formula to your multiple selection list box name: filed1).
    Add the conditional formatting on the flied: flied 3 does not contain value (you need to change the ‘Value’ in the formula to your multiple selection list box value.).
    In addition, you can add Formatting action to hide the text box control.
    Here are the result screenshots for you to take a look at:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Select MULTIPLE default values for a multiple selection list box based on another field in Infopath 2010

    Hello there - Before I explain my issue, I would like to point out that I have reviewed some other discussions on selecting default values for multiple selection listbox. But my issue is specific and different, and not answered by any of the discussions
    I visited.
    I have a multiple selection list box (say for example all countries in the world as values), and I would like to pre-select or setup multiple default values (say five countries) based on some criteria that I query from MS SQL database table.
    I know we can go to Data | Default Values option to setup one or many default values for multiple selection list box. When I enter the default values manually this works. I also right click the field under the Multiple-Selection List Box group, then select
    Add another Value Below and set the Default Value for this field to setup multiple default values.
    However, if I reference a field (either an infopath field or a field from SQL database) I am not able to setup multiple default values. Infopath automatically selects the last field I selected for all instances and in the end I am able to see only one
    default value selected instead of many. How to fix this problem? Why would infopath allow multiple default values when we enter it manually but not when we reference some fields?
    Please let me know if you need more info. Appreciate your help.
    Thanks!

    Hi redhotc,
    According to your description, my understanding is that you want to set multiple default values for a multiple checkbox list in InfoPath form.
    I did a test with SQL database table. I set three default values for the checkbox list by adding three values field under the group field(Data->Default values), each value field is for a default value. Then publish it to my SharePoint site, everything
    was fine.Please have a try as the below link:
    http://www.bizsupportonline.net/infopath2010/pre-select-items-multiple-selection-list-box-infopath-2010.htm
    Note: if you are using SQL databse table, you may need to enable ‘Allow cross-domain data access for user form templates that use connection settings in a data connection file’ in CA. More information, please refer to:
    http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010customization.aspx?ID=418b9423-a96c-4e5e-91f9-6a1b010ebb69
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • ApEx2: Many-to-many with checkboxes or multiple select list?

    Hello all together
    I have the following specification:
    * a table for tool users: tool_users(tu_id, tu_name)
    * a table for groups: groups(gr_id, gr_name)
    * a table for the many to many relationship of tool users and groups: tool_users_to_groups(tu2gr_id, tu2gr_tu_id, tu2gr_gr_id)
    I'd like to have some checkboxes or a multiple select list in my "add/edit group" form where I can select which users belong to this group. The same vice versa for users to specify which groups they belong to.
    edit user
    (general details)
    Has to the following groups:
    [X] Group 1
    [ ] Group 2
    [ ] Group 3
    [X] Group 4
    [ ] Group 5
    After submitting the checked values should be insert into the many-to-many relationship table.
    How can I do that?
    Thanks a lot for any help,
    Josh

    Thanks for your kind help.
    I'll have to learn PL/SQL if I want to go on with my work in ApEx in future, I see this too.
    But at the moment there are just a few problems I got and I should get a small application up and running as soon as possible, so I'd be really thankful for some newbie help.
    My problem is now:
    I have created the process for my form page with the following code:
    declare
    v_list varchar2(200);
    begin
    for r in (select tu2gr_gr_id id
    from tool_users_to_groups
    where tu2gr_tu_id = :P3_TU_ID)
    loop
    v_list := v_list ||r.id|| ':';
    end loop;
    :P3_GROUPS := v_list;
    end;
    Sadly the code does not seem to be executed. I have changed the name from :P3_GROUPS to :P3_GROUPS2 (which doesn't exist and I'd expect the application to crash when loading the page). I have set the process to a Before Header process. What could I have done wrong?

  • Multiple Select List not returning multiple values

    I have created a Multiple Select List, and the manual says that when multiple values are selected and the page is submmitted (I'm using a GO button), the multiple values are put into the ITEM field, separated with a colon . However, whenever I select multiple entries in my list, it only ever returns a value for the first item (like a single select list).
    Does anybody know what I may have missed ? I'm still fairly new to this stuff, so I'm hoping it's fairly simple!
    thanks.
    p.s I'm using a dynamic list of values.

    Andy / Scott,
    Sorry, please bear with me ... still new to this.
    I have a multi select list item in page 2, called P2_MULTI_LIST. When the page is submitted, I no longer physically pass it to page 3, but how would page 3 pick up the value ? Do I need to set up a P3_MULTI_LIST item in page3 and set that item to the P2_MULTI_LIST value, or do I reference P2_MULTI_LIST directly in my Page3 SQL query ?
    Also, if I then want to propogate the value in P2_MULTI_LIST down to another page from page3, via a link in a report, is this possible ?
    thanks
    Tim

  • Filter report on multiple select lists dynamically

    Hello
    Can somebody tell me how to filter/refresh a interactive report based on multiple select lists?
    The select lists are created with apex_item.select_list_from_query, because I need to create them dynamically.

    do not post duplicate questions/posts when you already have {message:id=10453848}
    It doesn't make any sense

  • How can i display Value in Report which i select from Multiple select list

    Dear All,
    i am using multiple select List in form with report page.
    When i create new Entry with select Multiple value in Multiple Select List then in report Value display me in below format
    my SQL Query are
    select NAME D, CODE R from  COUNTRY_MAS WHERE ACTIVE_FLG ='Y' order by NAME
    AS:AI:AG:AM these are return value .i want to display NAME in report .
    How can i do this ?
    Thanks
    Edited by: Vedant on Apr 25, 2012 11:14 PM

    Short answer, use the apex_util.string_to_table to convert to a table; then you can either iterate through the table to generate a string of names, or accomplish the same with a bulk operation.
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_util.htm#CHDFEEJD
    Encapsulate all this within a pl/sql function.

Maybe you are looking for

  • Generare e-mail status by tracking Delivery and Read Receipt?Challenge

    Hi, I got bit confused, How can I came to know that my e-mail has been successfully sent or not without opening my inbox. Am sending 50,000 mails per day by using java mail sending program, while sending I am enabled Delivery and Read receipt and I s

  • What driver do I need to connect to Brother MFC-9325CW

    what driver do I need to connect t0 Brother MFC-9325CW?

  • "ugly" fonts on gnome

    I've just downloaded packages from gnome and gnome-extra.I don't know how to explain but I thought default fonts of Gnome would look the same in every distro, but here are pretty different with respect to my previous slack installation, even if I alw

  • Oracle SQL command

    I have read this statement on these forums many times: Just keep 1 thin in mind... CR will send any SQL statement, exactly as it is written, to the database. That means that if you can execute it from TOAD or the Oracle SQL Developer, you should be a

  • AppleScript error with iTunes: Can't get window 'iTunes' of class pcap ...

    Hi there. I'm working on a script that posts iTunes track names to Campfire based on the AirPlay device in use. I've been getting a "Can't get window 'iTunes' of <<class pcap>> 'iTunes' of application 'System Events'" and was hoping someone might see