Delete in database based on multiselect list values

Hi,
I have a selectlist in Apex and a function in the database to do some delete based on the selected value from the select list.
FUNCTION delete_batch (v_batch VARCHAR2) RETURN VARCHAR2
IS
BEGIN
IF v_batch like 'M%'
THEN
   RETURN ('A monthrun cannot be deleted');
ELSE
   DELETE FROM so_disco_pa
   WHERE  batch = v_batch
   DELETE FROM so_batch_pa
   WHERE  batch = v_batch
   COMMIT;
   RETURN ('Batch '||v_batch||' has been deleted');
END IF;
EXCEPTION
WHEN OTHERS THEN
    RETURN ('Batch could not be deleted');
END delete_batch;The package function is called when the delete button is clicked with following process:
BEGIN
DECLARE
x   varchar2(100);
BEGIN
x := pa_control.delete_batch (:P3_BATCH);
:F105_MESSAGE := x;
END;
END;Now I want to change the selectlist to a multiselect list so that multiple batches can be deleted.
How do I change my procedure and process to delete batches based on the selected values?
Thanks,
Diana

I got this so far, but only the first batch selected in the list is being deleted. The other selected batch values are not deleted.
Some help please.
FUNCTION delete_batch (v_batch VARCHAR2) RETURN varchar2
IS
T Apex_application_global.vc_arr2;
BEGIN
T := apex_util.string_to_table(v_batch);
For I in 1..t.count loop
IF  t(i) like 'M%'
THEN
   RETURN ('A monthrun cannot be deleted');
ELSE
   DELETE FROM so_disco_pa
   WHERE  batch = t(i)
   DELETE FROM so_batch_pa
   WHERE  batch = t(i)
   COMMIT;
   RETURN ('Batch '||v_batch||' has been deleted');
END IF;
end loop;
EXCEPTION
WHEN OTHERS THEN
    RETURN ('Batch could not be deleted');
END delete_batch;

Similar Messages

  • ApEx How 2  turn a multiselect list value (eg. 1:2:3:4 ) into (1,2,3,4)

    ApEx newbie here,
    I'm trying to get the output of a multi select list into an in list of a sql query for a report. The error message I'm getting is report error:
    ORA-01722: invalid number. (The inlist is a list of id numbers, and the data type for this column in the database is NUMBER)
    I've got a page item called P3_x which is populated from a MultiSelect list. I learned that these come out as colon delimited strings. (found a reference to hidden items in a blog that helped me figure this out)
    So I created a hidden item called P3_x_in_list which does this:
    Select '('|| regexp(:p3_x,':',',')||')' from dual which turns this into a comma separated list, like so: (1,2,3,4)
    I put this hidden item, P3_X_IN_LIST into the sql in my report region
    So in the report my sql looks like:
    select a, b, c
    from t1
    where id in: P3_x_in_list
    and some_date between :P1_X and :P2_X
    For some reason it throws an invalid number error when it runs. I haven't been able to find anything in the documentation or on the web that sheds any light on this. I'm hoping that there is a benevolent, experienced developer that can point me in the right direction. The debuging information from the page is below:
    Here is the debugging information
    0.24: ...Session State: Save "P3_X" - saving same value: "1:2:3:4:5"
    0.24: ...Session State: Save "P1_X" - saving same value: "01-DEC-2008"
    0.24: ...Session State: Save "P2_X" - saving same value: "04-DEC-2008"
    0.30: ...Session State: Save Item "P3_X_IN_LIST" newValue="(1,2,3,4,5)" "escape_on_input="N"
    0.30: Processing point: ON_SUBMIT_BEFORE_COMPUTATION
    0.46: show report
    0.46: determine column headings
    0.46: parse query as: my_schema
    1.76: binding: ":P3_X_IN_LIST"="P3_X_IN_LIST" value="(1,2,3,4,5)"
    2.64: binding: ":P2_X"="P2_X" value="04-DEC-2008"
    report error:
    ORA-01722: invalid number
    ORA-02063: preceding line from my_schema
    3.23: Computation point: AFTER_BOX_BODY
    3.23: Processing point: AFTER_BOX_BODY
    3.23: Computation point: BEFORE_FOOTER
    3.23: Processing point: BEFORE_FOOTER
    3.23: Show page tempate footer

    Well, let's say you had a SQL statement like
    select * from obj where object_id in 12345
    where object_id is defined to be a number type.
    Now, if you replace the literal '12345' with a bind variable and then bind "(1,2,3,4,5)" to this bind variable it will be clear why the SQL fails.
    As for using pipeline functions it is pretty straightforwad
    Here's an example
    CREATE OR REPLACE TYPE vc_array_1 AS TABLE OF VARCHAR2 (50);
    CREATE OR REPLACE FUNCTION get_list (
       p_string      IN   VARCHAR2,
       p_delimiter   IN   VARCHAR2 DEFAULT ':'
       RETURN vc_array_1 PIPELINED
    IS
        l_string     varchar2(32000);
        l_array     wwv_flow_global.vc_arr2;
    BEGIN
       l_array := apex_util.STRING_TO_TABLE(p_string,p_delimiter);
       for i in l_array.first..l_array.last loop
          pipe row (trim(l_array(i)));
       end loop;
       return;
    end;
    select column_value from table (get_list('1:2:3:4:5'));Your query can now be
    select a, b, c
    from t1
    where id in (select column_value from table get_list(: P3_x_in_list)) )   
    and some_date between :P1_X and :P2_XVarad

  • Refresh classic report based on select list value selected

    hello,
    can anyone please help me out with this issue. I have a parameterized classic report based on a select list and I want to refresh this report whenever the select list value is changed. I am using oracle apex version 3.2. i just want to have a javascript function onchange event for the select list which refreshes my report whenever a value is selected.
    My select list item is p1_datastore
    select distinct datastore d,datastore r from my_table1 order by 1;
    My classic report query is
    select * from my_table2 where datastore = :p1_datastore order by last_updated_dt desc;
    ****************************************************thanks,
    orton

    can anyone please help me out with this issue.
    thanks,
    orton

  • APEX4: Populating fields from database based on the SelectList value

    Hi,
    I've a Select List and 4 Text Fields on a form. On selecting a value on the Select List, I've to populate the Text Fields by fetching its values from the database by using the Select List value as the primary key.
    How can I do this in APEX 4?
    Thanks for the help.
    --Hozy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you so much for helping me out.
    Yes, it comes from the same table account.
    These are the sqls to fetch the 4 values in each dynamic action:
    select a.address1 from account a where a.account_id = :P14_ACCOUNT
    select a.address2 from account a where account_id = :P14_ACCOUNT
    select a.city from account a where a.account_id = :P14_ACCOUNT
    select a.postal_code from account a where a.account_id = :P14_ACCOUNT
    Right now, I only have one dynamic action for text field P14_BILLING_ADDRESS_1, and even for just one the value is not showing up in it. Please note that when I added for dynamic actions, the the values were showing up in all the 4 text fields before.
    Then when I added 4 more dynamic actions for a different Select List (P14_CUSTOMER), but for the same text fields, it all stopped working. And now even a single dynamic action is not working. This is how the sql for next 4 dynamic actions looked like:
    select c.address1 from customer c where c.customer_id = :P14_CUSTOMER
    select c.address2 from customer c where c.customer_id = :P14_CUSTOMER
    select c.city from customer c where c.customer_id= :P14_CUSTOMER
    select c.postal_code from customer c where c.customer_id= :P14_CUSTOMER
    }

  • How to pass multiselect list values to javascript?...

    Hi, guys...
    (continuation...)
    Here is a Q. I have two multiselect lists item on the page. I need to use the values of these items in ODP. The button calls javascript, and javascript envoke ODP. Everything is working fine if i submit the page and then call javascript, But this is extra step and it's not kind of cool...
    So i am looking for the way to pass the value of multiselect lists to javascript without submitting the page first...
    Thnks...
    Mike
    Edited by: mishkar on Oct 1, 2009 10:59 AM

    Mike:
    Try using v('page_item') instead of :page_item in the ODP code
    varad

  • How to get multiselect list values

    I have a multiselect list set up called :P_Staff_ID which uses a LOV (select staff_name, staff_id from staff)
    to display staff names to the screen.
    What function can i use to get all the selected names in the list for my submit process?
    Thanks
    Ray

    Ray,
    The selected values will be returned as a colon delimited list, e.g.: 20:30:40:50
    You can use the htmldb_util.string_to_table function to convert it to something a more suitable for inserting. This is the spec of the function from the documentation:
    HTMLDB_UTIL.STRING_TO_TABLE (
    p_string IN VARCHAR2,
    p_separator IN VARCHAR2 DEFAULT ':')
    RETURN HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    and a sample that loops over the values:
    DECLARE
    l_vc_arr2 HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    BEGIN
    l_vc_arr2 := HTMLDB_UTIL.STRING_TO_TABLE('One:Two:Three');
    FOR z IN 1..l_vc_arr2.count LOOP
         htp.p(l_vc_arr2(z));
    END LOOP;
    END;
    Sergio

  • Calling pages based on choice list value

    Hi,
    I'm using jdev11.1.2.1.0
    I have created page with one single choice list and 3 buttons.
    in choice list, all the selected items are static only. I have created 3 selected items under the choice list.
    and I created 9 jsff fragments.
    now these 9 jsff's are called as regions in page when i select choice list value and button.
    how can I achieve this?
    Thank You..

    Hi Puthanampatti
    thanks for Ur reply,
    I have tried like this...
    I have taken 9 buttons and i created valuechangelistener event and by depending up on the selecteditem in the choice list, rendered only three buttons and under those buttons i created setpropertylistener.
    its working fine.
    but I have created choice list by drag and drop the choice from the component palette and there I created list items( just labels only with no values)
    by default its showing blank item in the list.
    but as per my requirement, first item should be displayed first.
    I don know much about unselectedlabel property for the choicelist.
    how can I use this in displaying the first selectitem in the list?

  • Populate cc field based on dropdown list values

    I know this question has been posted before, but I'm very new at this, and the answers I've found so far are over my head.
    I'm trying to create a submit button that will not only e-mail to a specific address, but also carbon copy someone when their name is selected in a drop-down list on the form.
    I don't know much about javascript - and that seems to be the way to get this done - but I don't know the syntax or where to enter the JS to get this functionality. The field I am using is called 'Supervisor1', and I've assigned values (e-mail addresses) to each of the names in the drop-down.
    Can someone help me get this done?
    Thanks in advance!

    Hi,
    this scenario is not covered by the macro, but it's not that complicated to handle.
    1. Select the button with the script you generated with the macro.
    2. Now wrap the mail function into an if-expression.
    This sample checks if var0 or var1 is null.
    var var0 = xfa.resolveNode("Formular1.#subform.Dropdown1").rawValue;
    var var1 = xfa.resolveNode("Formular1.#subform.Textfield1").rawValue;
    if (var0 === null || var1 === null) {
              xfa.host.messageBox("Please select an item from the drop down box first!");
    } else {
              event.target.mailDoc({
                        bUI: false,
                        cTo: var1,
                        cCc: var0,
                        cBcc: '',
                        cSubject: 'Testmail',
                        cMsg: 'Hello,\n\nhere is the final form data. \n\nKind regards\nMe'

  • How to delete a node based on some attribute value

    Hi,
    I want to delete one node from xml file.
    My XML file is given below::::
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <config>
    <employeeDetails>
    <employee id = "1" name = "aa" salary = "1000" />
    <employee id = "2" name = "bb" salary = "2000" />
    <employee id = "3" name = "cc" salary = "3000" />
    <employee id = "4" name = "dd" salary = "4000" />
    </employeeDetails>
    </config>
    Lets say i want to delete the row whose id = "2" means whole employee node of id 2, but i don't know how to delete?
    Please somebody help me its very very urgent.

    madforjava wrote:
    Please somebody help me its very very urgent.Is someone going to die if you don't get answered within a couple of minutes?

  • If / then calculation based on dropdown list value in repeating row

    Hello
    I am new to Livecycle. I have created a repeating row in a form. The last field in the repeating row is a numeric field that = the product of two previous fields in the row (NumericField1 *  Numeric Field2). I also have a DropDownList1 near the beginning of the row (third column) that contains variable categories for that calculation row, e.g. Advertising, Office Supplies, Entertainment. I would like to create numeric fields in the form (perhaps in a footer row?) that contain sums of the subtotals of each row, depending on the category selected in DropDownList1. In other words I need to create a subtotal field for all calculations beginning with the category of Advertising, another for Office Supplies, another for Entertainment.
    From what I understand I need to list the variables first, then create an if/then calculation but I am not sure about the steps involved in creating the script.
    df

    NumericField3 is the name of the field containing the product of NumericField1 * NumericField2. I have created a NumericField8 in the form with the following calculation in FormCalc:
    if(Table1.Row.DropDownList1.rawValue == "ADVERTISING") then
    sum(Table1.Row[*].NumericField3)
    end if
    That's not helping. I think I need to designate variables before the if/then script, yes? Would I need to use a resolve command, a getfield command, or . . .? Can anyone help?
    Thanks, in advance,
    df

  • Build Dynamic Query based on values of multiselect list

    I am trying to implement the same functionality as shown in this app.
    http://htmldb.oracle.com/pls/otn/f?p=9741:6:13406902443304236283:::::
    I have hit a brick wall when I try to set the value of my text area/select statement, even after viewing the detail section in above app.
    Does anybody know exactly how I can set the value of a text area from multiselect list values??

    Hi Sam,
    check out How to use multi select in a query report
    See also Denes sample application which has and example where you can still do an index access if a index is defined for the column. http://htmldb.oracle.com/pls/otn/f?p=31517:138
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Multiselect List and Branches

    Hi,
    1. I understand that multiselect list problem has discussed here multiple times but I could not find any answer for my situation. May be someone can give me an advise.
    I have a page that has 8 multiselect lists. A user makes his selection, presses button “Report” and gets redirected to the report page (say page A) that displays records according to the user selection. Report source on page A is PL/SQL function body returning SQL query.
    I created the button “Report” with wizard (selected option Submit Page & Redirect to URL). Everything was working fine till report was created in the same browser window. But a customer wanted to have a report displayed as a new page. So I changed ”Optional URL Redirect” target from “No Target” as it was before to URL and inserted a call to the JavaScript as URL Target ( I use this approach on several other pages).
    Now when a user presses “Report” button he is redirected to the page A but that page displays completely different set of records. It looks like multiselect lists values are not passed to the report on page A any more. What am I missing?
    2. As I mentioned before a main page has 8 multiselect lists so SQL statement is very long and I will need to create a lot of different reports based on the selections in those multiselect lists .
    Is it possible to create an Application Level Variable, pass “WHERE” part of the SQL statement into it when button “Report” is pressed ( button has setting Submit Page & Redirect to URL!) and then use it in the SQL report source to generate reports?
    Thank you in advance.
    Val

    Scott,
    Thank you for your reply.
    At the moment I switched to the URL it stopped passing multiselect list parameters( I have javascript function in the HTML Header section and call this function from the button).
    If I understand the problem correctly I do not submit page as it was before. Session window does not show any parameters.
    The only reason I need this switch - create a report in a new window.
    Val

  • Help on passing multiselect list as in values to function in database

    I am having problemn passing multiselect list as in values to function in database
    I have a static multiselect list :P1_SELECT_LIST
    10
    11
    12
    13
    14
    15
    I am passing to another item :P2_SELECTED_LIST
    ('10','11','12','13')
    I have to send :P2_SELECTED_LIST to a DATABASE PACKAGE(P_DATABASE).FUNCTION(PASS_LIST)
    P_DATABASE.PASS_LIST(P2_SELECTED_LIST)
    IN MY PASS_LIST(FUNCTION)
    function PASS_LIST(P_STRING IN VARCHAR2) IS
    type T_EMPNO is table of VARCHAR2(10) index by binary_integer;
              type T_ENAME is table of VARCHAR2(6) index by binary_integer;
              v_EMPNO T_EMPNO;
              v_ENAME T_ENAME;
    CURSOR C1 IS SELECT EMPNO,ENAME FROM EMP
    WHERE DEPTNO IN P_STRING/* ('10','11','12','13')*/;
    BEGIN
    OPEN c1(P_STRING);
    FETCH c1_axl bulk collect
    into v_EMPNO, v_ENAME limit 40000;
    CLOSE c1;
    FOR I IN 1 .. V_EMPNO.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('V_EMPNO.COUNT :'||V_EMPNO.COUNT);
    END LOOP;
    END;
    any help

    This link may help:
    Re: Date Time field
    Denes Kubicek

  • 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 to set a default value for a drop down list box and then apply cascading based on the default value in Infopath 2010.

    Hello Everyone
    I have two drop downs. Both are coming from look up fields from two lists. i want to set a default value(first list item) for the first drop down list box and then apply cascading based on the default value for the next drop down list box. I found one article(http://www.bizsupportonline.net/infopath2010/display-first-item-drop-down-list-box-infopath-2010.htm)
    where in i can set a default value but i can't apply cascading based on that default value. Any suggestions would be highly appreciated.
    Thanks
    Ramanjulu Naidu N

    Hey Ramanjulu,
    Take a look at the below article which I believe will answer your question.
    http://basquang.wordpress.com/2010/03/29/cascading-drop-down-list-in-sharepoint-2010-using-infopath-2010/
    Daniel Christian (MCTS)

Maybe you are looking for