Need to insert a list of multiple selection as individual records

I have a list that is popluated with names and names have a unique number assigned to them
The other list is filled with the names of County and they also have a number that was

As the code is now it will not work because the loop is in the wrong place, I think that?
CF raises an error stating that the invalid data type because it attempts to insert "1,2,3,4,5,6, etc...". »
I changed the text data type, so it would be at least accept insertion, which worked, but this isn't what I want. I then changed backed to numeric, but get the error invalid data type.

The database is as follows 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
3 s
1 2
1 3
1 4
3 w
etc...


I need somehow a loop to check and see if a county is selected and then insert a record in the personnel_ID and the countyID, then check the following County and so on.


Here is my code... Any help would be greatly appreciated



< cfset CurrentPage = GetFileFromPath (GetTemplatePath ()) >

< cfif IsDefined "(FORM. MM_InsertRecord") AND the 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 VALUE
< / cfif >
,
< cfif IsDefined ("FORM.countyID") AND #FORM.countyID # NEQ "" > "".
< cfqueryparam value = "" #FORM.countyID # "cfsqltype ="cf_sql_numeric">"
< cfelse >
NULL VALUE
< / cfif >
)
< / cfloop >
< / cfquery >
< / cfif >



< name cfquery = "personal" datasource = "wildlife_nwco" >
SELECT *.
Of the members OF
ORDER BY personnel.lastName
< / cfquery >
< name cfquery = "County" datasource = "wildlife_nwco" >
SELECT *.
OF countyID
ORDER BY countyID.countyName
< / cfquery >


<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " 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 >


< are method = "post" name = "form2" action = "< cfoutput > #CurrentPage # < / cfoutput >" >
< table align = "center" >
< tr valign = 'of basic">
< td align = 'right' nowrap > RUSE name: < table >
< td > < select name = "personnel_ID" >
< cfoutput query 'personal' = >
< value = "" #personnel.personnel_ID # the option ' < cfif (isDefined ("personnel.personnel_ID") AND personnel.personnel_ID EQ personnel.personnel_ID) > selected < / cfif > > #personnel.lastName #, #personnel.firstName # < / option > "
< / cfoutput >
< / select >
< table >
< b >
< tr valign = 'of basic">
< td align = 'right' nowrap > counties worked: < table >
< td > < select name = "countyID" size = "10" multiple = "multiple" >
< cfoutput query = 'County' >
< value = "" #county.countyID # the option ' < cfif (isDefined ("county.countyID") AND county.countyID EQ county.countyID) > selected < / cfif > > #county.countyName # < / option > "
< / cfoutput >
< / select >
< table >
< b >
< tr valign = 'of basic">
< td align = 'right' nowrap > < table >
< td > < input type = "submit" value = "insert disk" > < table >
< /tr >
< /table >
< input type = "hidden" name = "MM_InsertRecord" value = "form2" >
< / make >
< p > < / p >
< / body >
< / html >

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

Tags: ColdFusion

Similar Questions

  • Insert the values of multiple selection

    Hello

    I have a list of multiple selection on my page and I want to insert this list in my database. Now, I want to create a new line for each of the selected values. My table has three rows. ID, GET_ID, PAR_ID. In my page, you can select the GET_ID. Then you have a list of multiple selection for PAR_ID (here, you choose more options). Now the script should put in the table so the format looks like this:
    ID        GET_ID      PAR_ID
    1         1               1
    2         1               2
    3         1               3
    4         2               1
    5         2               2
    
    etc..
    When I use the automated process of line it will insert the data as PAR_ID 1:2:3 and this isn't what I want. I think I must create a PL/SQL procedure with a loop, but my knowledge of pl/sql is not very good. If anyone can put me in the right direction?

    Kind regards
    Wijnand

    Hello Wijnand,

    I did sort of like this:

    DECLARE
    l_selected APEX_APPLICATION_GLOBAL. VC_ARR2;
    whole i_exists;
    BEGIN
    --
    -Convert the string two points separated values in
    -a table of PL/SQL
    l_selected: = APEX_UTIL. STRING_TO_TABLE(:P1_MULTISELECTLIST);

    --
    -Loop through the array to insert
    --
    BECAUSE me IN 1.l_selected.count
    LOOP
    SELECT count (*) in i_exists
    TABLE
    WHERE TABLE_PK = l_selected (i);

    IF i_exists > 0 THEN
    null; -DO NOTHING
    ON THE OTHER
    INSERT INTO TABLE (...) values (...);
    END IF;

    END LOOP;
    END;

    BR, Paul

  • Maximum number of list to multiple selection on a page

    Greetings,

    I use the Application Express 4.2.1.00.08. I have a problem in one of my pages. I have several items (123 from today ' hui), and two of them are lists of multiple selections. They are all the same... created is based on a named LOV, together forever, used Source Source Type defined on the database column... and they all work fine, except the last. Don't just save to the database.

    I tried:
    -Delete and recreate from scratch - does not save
    -Deletion and recreation of one copy of another list selection multiple work - does not save
    -Change the view state for one of my multiple selections of work lists to never (to have a less rendered multiselect list) - does not save
    -Keep everything the same but by changing the type of element (text field) - saves
    -Keeping all the same, but change to a normal selection list (no) - saves

    So, I came to the point of wondering... is there a limit on how many multiple-selection list can be on a page?

    If so, does anyone know a kind of workaround?
    If this isn't the case, anyone has an idea why I'm having this problem?

    Thank you for your comments,
    Mathieu

    I found something. If I move the item to another region, it works again, but not in all regions. I tried to create a new region and delete my article in there, but it doesn't seem to work. I'll keep looking.

    Thank you
    Mathieu

  • How can I get the value of list of multiple selection in javascript?

    Hello

    If I want to show the list of colon delimited in an alert box JS what I'd do?
    or if not, how do you show it?

    There are several SelectedIndexes?

    Type = select-multiple

    Bill

    Bill,

    Watch more closely the example I've provided earlierly:

    http://Apex.Oracle.com/pls/OTN/f?p=31517:166

    I use this code:

    for (i = 0; i < $x (pShuttle2) .length; i ++)
    {
    If (p_array == ")
    {
    p_array is $x (pShuttle2).value;.
    }
    on the other
    {
    p_array = p_array + ":" + $x (pShuttle2) [i] .value;
    }
    }

    Get.Add ('SHUTTLE_ITEM_VALUE', p_array);

    to concatenate the values in the table in a colon delimited string by some. It is later used to define the session state of the element of the shuttle to this value.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • Need to run a report in multiple selections of Member HFRfor

    Hello

    I have a reportIn HFR, for which the user wants to run the same report to multiple member, as in selections
    There is a dimension, which has about 1,000 children, for which the user wants the report to run on its own and create a PDF file.

    Is it possible that this is possible?

    Please answer.

    Thank you

    You can refer to the admin guide books, there are also other options such as planning, but I would start by looking at how to build a book to run that you can select the descendant members or the basis of a POV that is specified.

    JOINT TASK FORCE

  • The MySQL Multiple selection list

    How to make multiple selections in the drop-down list in a form in Dreamweaver 8 and publish on MySQL?

    I tried using implode as recommended here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12 & catid = 263 & threadid = 1112556 & highlight_key = y & keyword1 = multiple

    It worked unless the user did not select all the items in the list. Then, I got a bad argument error message.

    Then I tried just using POST without the implode and [] at the end of the name, but this put the word 'Picture' in the row/column in the database instead of the data.

    I then tried the POST with [the] on the chosen name and [] in the SQL statement: GetSQLValueString ($_POST [' devices [] ""], "text"), Dreamweaver wouldn't let me associate it under Insert a record in the section of the server behaviors - so nothing is put in the database.

    I need to be able to display multiple selected items in a list box for MySQL, but allow the user to select nothing in the drop-down list without receiving an error.

    Thank you very much for your help. In the end, he has worked with put the [] after the name and the following code:

    GetSQLValueString (isset($_POST['appliances'])? implode ("-", $_POST ['appliances']): "", "text")

  • Multiple selections cascading lists

    Hi all

    I have two lists of multiple selections called: P1_PARENT and: P1_CHILD. When a user selects a value of: P1_PARENT values of: P1_CHILD are filtered accordingly. This works well and is very easy through ApEx 4.0.

    I express this so that a user can select several elements of: P1_PARENT and filter: of P1_CHILD the value accordingly. The problem I have is that ApEx return the: P1_PARENT value as a string delimited by two points and I find it difficult to identify means to refer to this in the SQL code to: P1_CHILD, or how to create: P1_CHILD of a PL/SQL function.

    I want to use for SQL: P1_CHILD LOV would be something like:

    SELECT display, return
    TABLE
    WHERE parent_id in (: P1_PARENT);

    This property will return an error such as: P1_PARENT is not a number.

    Help, please!
    Thank you
    Lucy

    Lucy,
    you need a function in pipeline to be able to select from your list of parents separated by commas. This same function can be used for your START WITH id in the clause, but be careful with several relatives in hierarchical queries.

    create or replace type my_varchar_table_type as
    table of varchar2(255) --or however large you need your strings to be
    /
    
    create or replace
    function get_my_values ( p_string in varchar2 ) return my_varchar_table_type pipelined is
    t_vars apex_application_global.vc_arr2;
    begin
       t_vars := apex_util.string_to_table( p_string );
    
       for j in 1 ..  t_vars.count
       loop
         pipe row ( t_vars(j));
       end loop;
    
       return;
    
    end;
    /
    

    Then you should be able to do things like (just a model... you'll probably need to fix it a bit)

    SELECT display_val d, return_val r
    FROM (SELECT column_1, column_2, CONNECT_BY_ISLEAF IsLeaf
    FROM my_table
    START WITH id in
     (select to_number column_value)
      from table(get_my_numbers (:P1_PARENT))
      )
    CONNECT BY PRIOR id = parent_id)
    where IsLeaf=1
    

    I would really have a utility package and put this function in

    See you soon
    Kofi

  • Store multiple selections in list in a single field

    I need help to find this one. I have a simple form that uses a field list with "multiple selection" enabled. The values in the list are North, South, East and West. The user selects 1-4 on these options, and I want to memorize all these values in a single text field in the database called "direction". The ONLY value that is stored is the last value in the list.

    Using DW CS3 and mySQL 5.

    What Miss me? Thanks in advance.

    "weidemannia" wrote in message
    News:fftbd2$CB4$1@forums. Macromedia.com...
    > Someone out there with a suggestion?

    Add [] to the name of the field, multiple fields will be available as a
    table.

    Joris

  • Need to field multiple select the option without having previously selected deleted

    Hi all

    Request Express 4.1.1.00.23

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    I have a requirement of adding a field of multiple selection to a single screen, and I added the list to multiple selection, without a second thought. Of course, the question is when a user tries to edit a record, click on (with the CTRL key) two options in the selection list multiple, but not clicked on those previously selected, then we lost them. Then I thought to create checkboxes and thus those already selected will be always checked when try to update.

    But I want to do with the multiple selection field. So I was wondering if there is a way?

    Thank you!

    Sam82 wrote:

    Request Express 4.1.1.00.23

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    I have a requirement of adding a field of multiple selection to a single screen, and I added the list to multiple selection, without a second thought. Of course, the question is when a user tries to edit a record, click on (with the CTRL key) two options in the selection list multiple, but not clicked on those previously selected, then we lost them. Then I thought to create checkboxes and thus those already selected will be always checked when try to update.

    But I want to do with the multiple selection field. So I was wondering if there is a way?

    This is the behavior expected multiple-selection list. It can be changed using a point hidden shadow and JavaScript, but there is no way out of the box to achieve what you propose.

    Selections several lists are usually a bad idea:

    • Users do not know how they work
    • They are confused and source of errors, except if all options are visible (which generally wastes space UI)
    • The resulting values of treatment is problematic
    • They are often the cause of a model of incorrect data or result

    Checkboxes or a shuttle are much better options and controls for multiple choice options.

  • How to make default an element selected in the multiple selection list

    Hello

    I'm filling the list of multiple selection of a lov (dynamic lov). Is it possible to do by default one of the selected items in the list.

    Please let me know how to do this...

    Thanks /.

    How do you determine that a particular value of the LOV must be the default?
    You should be able to combine the LOV query and your 'default selection' health by using an SQL statement or a pl/sql function and specify it for the 'default value Type' in the section 'Default' definition of the elements page.

    CITY

  • How ins or upd multiple values in a record of diff of the fields by using the cursor

    Hai All

    I need to insert or update or multiple values in a single diff of one field records to another table.

    Table 1 has 3 fields

    Bartime bardate barcode

    02/01/10 0011, 0815

    02/01/10 0022, 0820

    02/01/10 0011, 1130

    02/01/10 0022, 1145

    02/01/10 0011, 1230

    02/01/10 0022, 1235

    02/01/10 0011, 1645

    02/01/10 0022, 1650


    These are the times that arrives at 0815 and pauses at 1130 and arrives at 12: 30 a.m. and coming home at 4:45 pm
    These table I have to insert into another table called table2
    and the fields are bar codes, date, intrinsically timein, introut, tiomout

    And the output you want to like this

    barcode timein intrinsically introut timeout date
    0011 0815 1130 1230 1645 02/01/10

    0022 0820 1145 1235 1650 02/01/10

    If all give some good answer that it will be help full...

    Thanks and greetings

    Srikkanth.M

    Hi Srikanth,

    1. first create a datablock (better do instead of the table because its only for querying details of table 1 for the period) with table1 as table base and better use order by clause in form as "order to barcode, date, bartime.

    2. create a second datablock with table2 and get this rank on the two table (second block as base table, because here, you should insert/update)

    now on the screen you can see all the data in 2 tables.

    3. fix the button of some process.

    a time-but-press

    Loop

    1 block of travel and take a line

    Find the same block 2

    If code in bars-avail so
    -you want to update
    on the other
    -you want to insert

    end if;

    end of loop

    and 2nd block will be updated / inserted as u desire, and finally, you can save the second block.

    Iqbal

  • Settlement data based on multiple selection ListBox reference need help

    Hello again,

    The question that I have is selecting from a listbox with multiple selection to fill the tables with the selected data. My code is as follows:

    Void loadData_EventClick (ByRef This)

    Dim j

    Dim k

    k = 0

    If ListBox.MultiSelection.Count = 0 Then Exit Sub

    For j = 1 To ListBox.Items.Count

    If ListBox.MultiSelection (j). Count = True Then

    k = k + 1

    End If

    Next

    TextBox.Text = k

    End Sub

    The code works perfectly up to the second if statement. My current channel group list contains 16 channels and with the second if statement guided the textbox output is equal to 16 (i.e. k = 16), which is what I expected. Im just using the k = k + 1 for the test. Eventually will be replaced by operating code specific to what I need to do.

    So the question that I have is to get the code to recognize what values are selected and referring to the index for the selections in a table. Im not sure on how to do it.

    Any help is very appreciated.

    Thank you

    ~ Nathan

    Attached JPEG shows the current user interface and the output of k with the second if statement commented

    Hey Nathan--

    ListBox.MultiSelection () is a function that returns an array of [multiple] selected items in ListBox.

    ListBox.MultiSelection.Count is a property that returns the number of items in the table above.

    Therefore, the logic in your second IF statement that says if ListBox.MultiSelection (j). Count = True really makes no sense because:

    1. The array returned by the multiple selection (using (j) indexing now refers to a single selected item in the list (which has not its own 'Count' property)

    2. If you don't the array index, assuming that you had selected 4 items in your list, your statement would still be actually as said if 4 = True which is not what you get.

    Make sense?

    Here is a modified version of your code that I hope makes it a little more obvious how these elements relate to one another.  Give it a run; of course, 75% of the code is extranneous to you working end to account, so make sure that you subsequently delete what you won't need.

    Sub loadData_EventClick (ByRef This) ' creates the event handler
    Dim j
    If ListBox.MultiSelection.Count = 0 Then Exit Sub
    TextBox.Text = "Total ListBox items:" & ListBox.Items.Count & + "" \n "".
    TextBox.Text = TextBox.Text & "Total selected items:" & ListBox.MultiSelection.Count & + "" \n "".
    TextBox.Text = TextBox.Text & "Selected Items:" & + "\n"
    For j = 1 to ListBox.MultiSelection.Count
    TextBox.Text is TextBox.Text & ListBox.MultiSelection (j). Text & ", index" & ListBox.MultiSelection (j). Index & + "\n"
    Next
    End Sub

    You are making great progress; It will get quickly easily faster and we are here to help – do not hesitate.

  • Multiple selection list

    I have a web form that I need to allow users to select multiple items in a list.  I 'google' and can not find an answer.

    The application has 2 parameters.

    < %

    Dim HoursWorked_PP__varTI

    HoursWorked_PP__varTI = '% '.

    If (Request.QueryString ("TI") <>"") then

    HoursWorked_PP__varTI = Request.QueryString ("TI")

    End If

    % >

    < %

    Dim HoursWorked_PP__varPP

    HoursWorked_PP__varPP = '% '.

    If (Request.QueryString ("PP") <>"") then

    HoursWorked_PP__varPP = Request.QueryString ("PP")

    End If

    % >

    < %
    Dim HoursWorked_PP
    Dim HoursWorked_PP_cmd
    Dim HoursWorked_PP_numRows

    Set HoursWorked_PP_cmd = Server.CreateObject ("ADODB.Command")
    HoursWorked_PP_cmd. ActiveConnection = MM_Connection_STRING
    HoursWorked_PP_cmd.CommandText = "SELECT * FROM dbo.vw_HoursWorked WHERE COLUMN_NAME =? and PP =?

    HoursWorked_PP_cmd. Prepared = true
    HoursWorked_PP_cmd. Parameters.Append HoursWorked_PP_cmd. CreateParameter ("param1", 200, 1, 255, HoursWorked_PP__varTI) ' adVarChar
    HoursWorked_PP_cmd. Parameters.Append HoursWorked_PP_cmd. CreateParameter ("param2", 200, 1, 255, HoursWorked_PP__varPP) ' adVarChar

    Set HoursWorked_PP = HoursWorked_PP_cmd. Run
    HoursWorked_PP_numRows = 0
    % >

    From my research, I tried:

    < %
    WorkedDate = Request.form ("WorkedPP") ' info from a string conversion

    MakeDate = Replace (WorkedDate, ",", "" OR WorkedPP = "" ") ' replace comma-space of a single quote - or WorkedPP = - singlequote
    % >


    < %
    Dim HoursWorked_PP
    Dim HoursWorked_PP_cmd
    Dim HoursWorked_PP_numRows

    Set HoursWorked_PP_cmd = Server.CreateObject ("ADODB.Command")
    HoursWorked_PP_cmd. ActiveConnection = MM_Connection_STRING
    HoursWorked_PP_cmd.CommandText = "SELECT * FROM dbo.vw_HoursWorked_PP_Sum WHERE COLUMN_NAME =? and PP = ' "' & MakeDate &" ' "
    HoursWorked_PP_cmd. Prepared = true
    HoursWorked_PP_cmd. Parameters.Append HoursWorked_PP_cmd. CreateParameter ("param1", 200, 1, 255, HoursWorked_PP__varTI) ' adVarChar
    HoursWorked_PP_cmd. Parameters.Append HoursWorked_PP_cmd. CreateParameter ("param2", 200, 1, 255, HoursWorked_PP__varPP) ' adVarChar

    Set HoursWorked_PP = HoursWorked_PP_cmd. Run
    HoursWorked_PP_numRows = 0
    % >

    Any help or a point in the right direction?  I'm not sure, but I can't find a solution to allow multiple selection lists.  If I change the query to use IN, then the URL string has always tried to use 'AND' so the results are null.

    Thanks for any help!

    Crystal

    WHERE COLUMN_NAME = lamyae and PP IN ("varPP")

    No, what I wanted was that you should analyze varPP and wrap all the values inside quotes. You must also put parens around all this. Therefore, this:

    "option 1, option 2, option3 ' who comes to the selection list is converted to this:

    '(' option1', 'option2', 'option3').

    I posted here a few years ago code to achieve this, but I did not practice routine. See if you can search for it.

  • Multiple selection works only not on the list box properties/Option screen

    When I select a multiple selection in the list box properties/Options tab, I get no difference from the default value of single selection. Still, he points out that the last of multiple entries (as a single room) and displays only the last entry. Is there anything else I need to do?

    Thanks for your help.

    To select multiple items, hold the CTRL key when you click additional items.

  • Multiple selection list limit (or simply select)

    Hello

    Does anyone know if there is a limit to how many upper elements can be presented during the use of a multiple selection (or a shuttle service).

    I have a query that returns hundreds of values (all valid). The user will need to select 1,2,5... all the way to ALL these elements to use in another application.

    When I select ALL returned items, I get an error from browser (Web page not found - error 400). It is in IE 8 (I know, I know, not my choice!).

    Thoughts?

    My shuttle comes from a dynamic LOV which seems to work fine.

    Pete

    The problem is in the limitation of the URL. all values in the list will be passed in the URL, and if it exceeds the limit of length of URL... I'm looking for something that can help

    Sam

Maybe you are looking for

  • Store the Spanish: Star Wars in English

    A few comments. I am British and live in Spain. I suffer by your Spanish store with her Spanish dubbed movies that sometimes are not available in their original language. Despite the fact that you're the best option I have, the Microsoft store and Go

  • Windows 10 bootcamp on external support.

    Hello I am currently studying a master's degree in engineering at the University, and it becomes increasingly imperative that I have a stable OS of Windows that will run the likes of AutoDesk Inventor on my system. However, I'm not really happy to ha

  • Satellite C665 does not turn on or charge

    Hello Like a fool I plugged a universal power adapter in my laptop set to 23v not 19v, now it does not work or load with its own adapter. The battery was already endangered and did not cool that I don't know if it is independent or not, but I would l

  • Need suggestion for USB Bluetooth adapter for HP Z230 workstation

    I just bought a workstation HP Z230, with an I7 processor.  I need to equip it with Bluetooth capability so that I can connect the computer to an old Palm Tungsten T2. There are gobs of USB Bluetooth 4.0 adaptors / dongles on the market, but in readi

  • try reinstalling Microsoft keyboard and wireless mouse 1000 on another computer.

    I have successfully used the keyboard or the mouse on another computer.  This time my computer recognizes the receiver, but I can't get the keyboard/mouse to synchronize with the computer.  I am running Windows XP.  Thank you in advance for your help