Create multiple Insert statements from multiselect list

I want to thank everyone in advance for the help on this one.
I have a multiselect list that I would like to use to create multiple Insert statements. I would like to then take those statements and execute them against the database, thus inserting the records. My thoughts are below;
1.     Customer selects multiple items in the list
2.     Clicks the submit button
3.     onclick event walks through the string created by the multiselect list and creates the Insert statements by walking through an array of the values.
4.     the Insert statements get executed against the database
5.     page redirects to the proper page after the process is done.
I actually have already created a javascript function that will use the split command on the string to create an array. I then get the length of the array and walk through a loop creating the sql statements. I am not sure what to do from here. How can I get the sql to execute.
I am not wed to this approach. If there is a better idea out there please do not hesitate to share it with me. I am relatively new to APEX and have not done much work in pl/sql or javascript. But I learn fast, so don’t hold back.
Thanks again and please let me know what questions you have for me.
Derek.

I setup the demo app on apex.oracle.com:
http://apex.oracle.com/pls/apex/f?p=26255:3
Login as demo / demo
Go to the "products" tab. There is a Test region with a multiselect list. It shows product names (with product id's) from the demo_product_info table.
When you select multiple things from the list and click apply, it uses the following procedure to simply insert a new record for each into the product table. It increments the product_id by 1000 and prepends "DUPLICATE " to the product_name:
declare
cursor c_products is
select product_name, product_id
from demo_product_info
where instr(':' || :P3_X || ':', ':' || product_id || ':') >= 1
order by 1
begin
for r_product in c_products loop
insert into demo_product_info (product_id, product_name)
values (r_product.product_id + 1000, 'DUPLICATE ' || r_product.product_name);
end loop;
end;
You can see that is working by using it on the duplicate entries themselves.
-Richard

Similar Messages

  • Creating Multiple INSERT statements with SQL

    is there a way to create multiple INSERT staements with SQL .
    Example scenario : This is only example but i have lot of data in the real time.
    sql : Select Emplid from Table A where Emplid between 100 and 350 will retun me 50 rows . i want to insert those rows into another table.
    I am looking for output like below instead of Giving output just as EMPLIDs
    Insert into PS_LM_DATA ( EMPLID ) values ( 123 )
    Insert into PS_LM_DATA ( EMPLID ) values ( 234 )
    Insert into PS_LM_DATA ( EMPLID ) values ( 334 )
    and so on....
    thanks ,
    Karu

    If you are inserting into another table, you could use
    insert into PS_LM_DATA ( EMPLID ) 
    select Emplid from Table A where Emplid between 100 and 350Example:
    SQL> insert into emp2(empno) select empno from emp;
    14 rows created.
    SQL> insert into emp2(empno) select empno from emp where empno between 7369 and 7788;
    8 rows created.

  • How do I create multiple text files from a list in another file?

    I have a text file with data in it:
    1. Bristol
    2. Bath
    3. Exeter
    etc
    I want to run an action which outputs the following files:
    1.txt (contents: 1 Bristol)
    2.txt (contents: 2.Bath)
    3.txt (contents: 3.Exeter)
    I can't work ou how to do this, any help appreciated. Thanks
    Dave

    Hi mate, thanks for the suggestion.  I saw that section in the user guide - but it is only for copying from one library to another - I want to copy from an FCP library to a file structure OUTSIDE FCP.  I have had problems with FCP losing media when copying to another library so I just want the files in the Finder where I can see them...
    Stephen

  • Can v create multiple billing document from delivery with single line item

    can v create multiple billing document from delivery with single line item

    Dear Sandesh
    Go to VOV7, select your item category.  In this maintain K  for Billing Relevance
    Now go to VF01, give the delivery number and do not press Enter.  Instead click on Selection list on the next screen, select the items you want to bill and click copy and continue if necessary
    thanks
    G. Lakshmipathi

  • Can't create multiple dependent LOVs from the same bind variable

    Hi all,
    I'm having difficulty creating multiple dependent LOVs from queries based on the same bind variable in my JSF application (JDev 10.1.3.1). Basically I have a static LOV in a af:selectOneChoice component from which users select a value which then becomes the bind variable value for two separate queries that generate two different dependent LOV. Having developed the code along the lines of Steve Muench 's blog (http://radio.weblogs.com/0118231/2006/04/03.html#a685), the first dependent LOV works really well. The first dynamic LOV gets refreshed whenever the list from the static LOV changes, and I can execute other queries based on the values selected.
    The problem arises when I want to create the second dynamic/dependent LOV that has the same bind variable based on the same selected value from the static LOV. Here I would also like the functionality whereby the second dynamic LOV is also refreshed after the selected value in the static LOV changes. Thinking that all I had to do was replicate the methodology used in creating the first dependent LOV, I created the second iterator, invokeAction and other binding components in the PageDef. The executable section now looks like the following:
    <iterator id="SelectStaticQueryViewObjIterator"
                  Binds="SelectStaticQueryViewObj" RangeSize="-1"
                  DataControl="DMSApplicationModule1DataControl"/>
    <invokeAction id="refreshDynamicQuery1BindParameter"
                  Binds="ExecuteWithParams1" Refresh="prepareModel"
                  RefreshCondition="#{empty requestScope.VariableChanged}"/>
    <iterator id="SelectDynamicQuery1ViewObjIterator"
                  Binds="SelectDynamicQuery1ViewObj" RangeSize="-1"
                  DataControl="DMSApplicationModule1DataControl"/>
    <invokeAction id="refreshDynamicQuery2BindParameter"
                  Binds="ExecuteWithParams2" Refresh="prepareModel"
                  RefreshCondition="#{empty requestScope.VariableChanged}"/>
    <iterator id="SelectDynamicQuery2ViewObjIterator"
                  Binds="SelectDynamicQuery2ViewObj" RangeSize="-1"
                  DataControl="DMSApplicationModule1DataControl"/>I now have a problem whereby everytime I change the value of the static LOV, multiple HTML components for the same ADF component are being generated (the LOVs are refreshed via PPR). The surprising thing is that this duplicating behaviour applies to all ADF components listed after the first dynamic LOV in the *.jspx source. For example, I have a <af:outputText="Test Text"/> component created after the first dynamic LOV. Each time the value in the static LOV changes, a duplicate HTML component is created. This also applies to the 'related' second dynamic LOV which is bound to a af:selectOneChoice component - multiple dropdown lists are created. I've checked with the browser's Page Source and there are actually multiple html components being generated with their own unique ADF-generated IDs. I've tried all different options for the Referesh and RefreshCondition attibutes in the second invokeAction element but nothing seems to eliminate this issue.
    Any suggestions about how I might create multiple dependent LOVs from the same bind variable that get refreshed when the selected value changes would be greatly appreciated.
    Thanks
    George

    Hi all,
    Just updating the thread on how I've overcome this issue. As it stood the manner in which I was trying to solve my use case, as described above, was creating an absolute mess. Then with a blank sheet of paper I quickly realised that a much simpler solution would be to create a whole series of master-detail VOs and build my components around them. Thankfully I haven't had any issues going down this path as yet.
    Cheers
    George

  • How to prepare an INSERT statement from the resultset

    Hi Friends ,
    I have to generate CREATE and INSERT statements for the Table already present in the database .
    I can prepare CREATE statement by getting the MetaData from the database . Is it possible to create INSERT statement for the data already present in the database table if so how.
    Thanks ,
    Rajesh Reddy

    You should be able to do something like SELECT * FROM foo WHERE 1 = 2. No rows will be returned. Call ResultSet#getMetaData() to get the meta data for the column names and types. You should then be able to dynamically create your own INSERT statement.
    - Saish

  • Use Multiple Insert Statements in Prepared Statements

    Hi Friends
    i am stuck in a problem for which i need your help.i will brief you about the issue below.
    I am having Multiple Insert Statements which i need to execute to put the data in the database.i have a doubt about the use of the executeUpdate() function in the statement interface. sample code is as below.
    stmt = conn.prepareStatement("INSERT INTO Client ( clientPk, provincePk, countryPk, statusPk, branchPk, salutation, ) VALUES(PID, 2, '123123123', '123', '66', 1, 1 );");
    int n =stmt.executeUpdate();
    Now the problem is how do i insert multiple Insert statements using the conn.prepareStatement().should i do like
    stmt = conn.prepareStatement("")
    int n =stmt.executeUpdate();
    stmt = conn.prepareStatement("")
    int n =stmt.executeUpdate();
    stmt = conn.prepareStatement("")
    int n =stmt.executeUpdate(); ..................................
    should i use the same steps to execute each individual query and then use executeUpdate().
    Please let me know the correct procedure to be followed to execute these tasks.waiting for a positive reply from your side.
    Thanks & Regards
    Vikram K

    Hi
    Thanks a lot once agin for the reply.
    I think i have figured out the solution. I am using SQL statements in the Prepared statements(""). But now i have dropped the idea of using the prepared statement and decided to use the simple Statement instead.
    what i have done is as below.
    conn = ConnectionFactory.getInstance().getConnection();
    stmt = conn.createStatement();
    stmt.executeUpdate("INSERT INTO Client ( clientPk, provincePk, countryPk, statusPk, branchPk, salutation, heightMeasurementType, weightMeasurementType ) VALUES(PID, '1', '1', '0', '1', 'Mr', CONCAT('Jason ', PID), 'R', 'Mawdsley', '123', '66', 1, 1 );");
    stmt.executeUpdate("INSERT into Cp () Values ()");
    stmt.executeUpdate("INSERT into gp () Values ()");
    stmt.executeUpdate("INSERT into jk () Values ()");
    I think this makes sense to use the Statement and execute all the queries in one shot rather than using PS.
    thanks a lot for your help.
    Regards
    Vikram K

  • Create multiple sales orders from single service notification?

    Is it possible to create multiple sales orders from a single notification (IW51)? 
    We currently create sales orders directly within transaction IW51 (Create Service Notification).  We kick off the sales order creation by pressing the "SALES ORD." button in the notification screen.  We're now interested in creating a 2nd Sales Order which would tie directly to the same Service Notification.  This is so that we can have the second order assigned to a different account assignment WBS (there are two different parties doing work on the service notification).
    I assume you would have to go to VA01 to create the Sales Order, but am not sure how to tie it directly to the service notification from here.  I treied to do a create with reference, but there is no ability to create with reference to a service notification.
    Do I have to create a second service notification for the 2nd Sales Order for this to work?  I want to avoid doing this if at all possible.
    I'm running SAP R/3 Enterprise
    Thanks for your help!

    Hi,
    go to vtaa- copy controls for sales document to sales document.
    select your combination of order and quotation go to item level. There select value 0(zero) in field positive/negative negative.
    No need to change update document flow.
    After setting zero in copy control that be told on above. create order with respective to the quotation.
    After saving the order.
    go to document flow to see the status in between quotation and order.
    If you placed setting right, then u certainly observe for quotation status will be open. so you can create no. of sales order with respect to that quotation..
    Have a good day..

  • How do I get to the screen in Mail that allows you to delete multiple "Previous Recipients"  from the list? I have seen it but cannot find it again. Help.

    How do I get to the screen in Mail that allows you to delete multiple "Previous Recipients"  from the list? I have seen this screen but cannot find it again. It shows all of the "Previous Recipients" in a long list. You can edit the list by selecting multiple names or all names with the command key and delete. Help.

    Launch the Mail app on your Mac and go to Window>Previous Recipients.

  • Can we create multiple billing document from delivery with single line item

    can we create multiple billing document from delivery with single line item

    Hi
    Please check the link
    [can v create multiple billing document from delivery with single line item]
    and as Lakshmi said, check the forum before posting an issue.
    Regards
    AA

  • Executing multiple insert statement in oracle

    hellor every one,
    I have multiple insert statements which should be executed in a single execution and i placed the sample insert statement here. How can i execute these statement in a single execution. Please help me.
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',1,'04509','Abdomen pain');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',2,'04509','Abdominal bloating');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',3,'04509','Abdominal cramps');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',4,'04509','Abdominal pain');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',5,'04509','Abdominal sensitivity');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',6,'04509','Abnormal bleeding');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',7,'04509','Abnormal weight gain');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',8,'04509','Abnormal sensitivity to cold');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',9,'04509','Abnormal sensitivity to heat');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',10,'04509','Abnormal movements');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',11,'04509','Absence of menstrual periods');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',12,'04509','Absence of periods');\
    insert into r_symptom_master_tcs (RSM_CRT_DT,RSM_SYM_CD,RSM_CRT_UID,RSM_SYM_DESC) values('30-Sep-2005',13,'04509','Absent menstrual periods');\

    > but in what editor we should do this, either in the sql editor, or pl/sql
    Whatever editor you are comfortable with. I assume there is one.
    btw if there are a lot of INSERT statements in the script it might be worth adding the following to the top:
    ALTER SESSION SET CURSOR_SHARING = SIMILAR;

  • Creating Form Manually w/Process that Contains Multiple Insert Statements

    Hello,
    I've been trying to create a form manually by following the instructions in the Users Manual under "Creating Form Manually - Creating a Process that Contains One or More Insert Statements." I have not had much luck and I think that it is because I'm not sure what is ment when said:
    "Create a conditional process of type PL/SQL that executes when the user clicks the button."
    Here is the PL/SQL that I used:
    BEGIN
    UPDATE T
    SET first_name = :P1_FIRST_NAME,
    last_name = :P1_LAST_NAME
    WHERE ID = :P1_ID;
    END;
    I am not sure where to create this process,however. I've tried several areas (i.e. Processes under Page Processing, Processes under Page Rendering, Under Conditions on the Button, etc.) but will get errors or no effect at all.
    Please let me know what i am doing wrong. If you could provide me with a simple example of how to create a form manually, that would be greatly appreciated.
    Thanks.
    Linda
    Message was edited by:
    lhudak

    Hello Scott,
    I followed your instructions and the error that I get is that nothing happens at all. I submit the page and nothing gets updated, deleted or added.
    I have the table, report, processes and form in place. Here are the settings:
    Process Point: is "on-submit, after computations...(in the Page Processing Section)
    Type: PL/SQL anonymous block
    Source: BEGIN
    INSERT INTO T ( first_name, last_name )
    VALUES (:P1_FIRST_NAME, :P1_LAST_NAME);
    END;
    Conditional Processing: When Button Pressed (Create (ADD))
    For the Button:
    Database Action: SQL Insert action
    URL Redirect: No Target
    Should I have any special settings on the Page Item? (i.e. under Default: Default Value Type: PL/SQL Expression) or maybe under Conditions: Condition Type - PL/SQL?
    Please let me know.
    Thanks
    Linda

  • Want to construct insert statement from all_tab_columns

    I am using Oracle 10GR2 and a new user for plsql
    I want to write a plsql block or SQL in order to insert some dummy data.
    I want to use the column list from all_tab_columns and want to construct insert statement
    EX: I am trying to construct SQL as below
    for i in (select column_name from all_tab_columns where table_name='EMP')
    loop
    v_sql := insert into emptest valuesi.column_name
    could you please let me know any pointer for the same ..?
    can I use any other technique for the same .. like collection, nested table etc

    Am not clear for this requirement, if possible could you please elaborate.
    Also specify the requirement, inputs and expected outputs with your query in code format...
    This will help..

  • How to get the selected values from multiselected list

    Hi,
    I have a multiselect list displaying all the years from 2003 to 2008 (used dynamic LOV). The user can choose one or more years as per his needs, and then when user clicks on the link the selected values of the list are to be captured and a pop up page of a Discoveror report needs to be opened where these years get passed as a parameter. I tried several methods to capture the value, but either one or all are getting passed but not exactly what the user has chosen.
    This is how it looks:
    P2_FISCAL_YEAR is a multiselect list containing values from 2003,2004... 2008
    If user chooses 2004 and 2007
    then I want the url to capture these values and pass as parameters for my discoveror reports. as '&qp_fiscal_year=2004,2007'
    Any help is appreciated!
    Thanks in advance,
    Sapna.

    Hi,
    I have a multiselect list displaying all the years from 2003 to 2008 (used dynamic LOV). The user can choose one or more years as per his needs, and then when user clicks on the link the selected values of the list are to be captured and a pop up page of a Discoveror report needs to be opened where these years get passed as a parameter. I tried several methods to capture the value, but either one or all are getting passed but not exactly what the user has chosen.
    This is how it looks:
    P2_FISCAL_YEAR is a multiselect list containing values from 2003,2004... 2008
    If user chooses 2004 and 2007
    then I want the url to capture these values and pass as parameters for my discoveror reports. as '&qp_fiscal_year=2004,2007'
    Any help is appreciated!
    Thanks in advance,
    Sapna.

  • How can i create multiple apple ids from the same mac

    There seems to be a limit on how many apple ids can be created from the same cpu. Trying to create 100 apple ids for a client to use on ipads distributed to employees i found i could only create three or four before i got the message account cannot be created, contact itunes support. Had the same problem creating multiple itunes accounts through the App Store.

    I found this discussion because I need to create dozens of Apple IDs for the faculty and staff of the school for which I'm the IT Director.
    This is weak.
    Apple, PLEASE upgrade the Apple ID system so it represents the current needs and paradigm.
    What am I thinking, Apple (like Google) don't follow user discussion forums, except by accident when an employee sees something and is motivated enough to carry the water for users in need.

Maybe you are looking for