Pass a list of number values to a pl/sql function

I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause. Ideally I would like to do the following:
CREATE OR REPLACE FUNCTION ( dept_list in varchar2) is
begin
select ... where dept in (dept_list) ;
usage: process_list ( '7730,7735,7740,7745') ;
I can not find an example of doing this in pl/sql function but it seems feasible.
Is there a way to do this?

user12088323 wrote:
I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause.
usage: process_list ( '7730,7735,7740,7745') ;The first thing is you need an appropriate data type to store a list of numbers. A single character value that looks to you like a list of numbers, is not in fact a list of numbers but a single character value.
This example uses the built in data type odcinumberlist in a procedure, you can do the same in function
Re: Passing an array to an Oracle stored procedure
If you have an old version of the database you may need to create your own type with the same definition of odcinumberlist.

Similar Messages

  • 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

  • Pass a value from a PL/SQL function to a javascript (html header) ? ?

    Hey Guys,
    Have a question regarding how to pass a value from a PL/SQL function to a javascript in the HTML Header.
    I have created a PL/SQL function in my database, which does looping.
    The reason for this is:  On my apex page when the user selects a code, it should display(or highlight buttons) the different project id's present for that particular code.
    example= code 1
    has project id's = 5, 6, 7
    code 2
    has project id's = 7,8
    Thank you for your Help or Suggestions
    Jesh
    The PL/SQL function :
    CREATE OR REPLACE FUNCTION contact_details(ACT_CODE1 IN NUMBER) RETURN VARCHAR2 IS
    Project_codes varchar2(10);
    CURSOR contact_cur IS
    SELECT ACT_CODE,PROJECT_ID
    FROM ACTASQ.ASQ_CONTACT where ACT_CODE = ACT_CODE1;
    currec contact_cur%rowtype;
    NAME: contact_details
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 6/25/2009 1. Created this function.
    BEGIN
    FOR currec in contact_cur LOOP
         dbms_output.put_line(currec.PROJECT_ID || '|');
         Project_codes := currec.PROJECT_ID|| '|' ||Project_codes;
    END LOOP;
    RETURN Project_codes;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END contact_details;
    /

    Jesh:
    I have made the following modifications to your app to get it to work as I thing you need it to.
    1) Changed the source for the HTML Buttons Region(note use of id vs name for the Buttons)
    <script>
    function hilitebtn(val) {
    //gray buttons
    $x('graduate').style.backgroundColor='gray'
    $x('distance').style.backgroundColor='gray'
    $x('career').style.backgroundColor='gray'
    $x('photo').style.backgroundColor='gray'
    //AJAX call to get project-ids
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=GETPROJECTS',0);
    get.addParam('x01',val)
    gReturn = get.get();
    var arr=gReturn.split(':');  //dump into array
    get = null;
    for (i=0;i<arr.length;i++) {
    // alert('val=' + arr);
    if ( arr[i]==5)
    $x('graduate').style.backgroundColor='red';
    if ( arr[i]==6)
    $x('distance').style.backgroundColor='red';
    if ( arr[i]==7)
    $x('career').style.backgroundColor='red';
    if ( arr[i]==8)
    $x('photo').style.backgroundColor='red';
    </script>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr><td>
    <input type='button' id='graduate' value='Graduate'>
    </td>
    <td>
    <input type='button' id='distance' value='Distance'>
    </td>
    <td>
    <input type='button' id='career' value='Career/Tech'>
    </td>
    <td>
    <input type='button' id='photo' value='Photos'>
    </td>
    </tr></table>
    2) Defined the application process  GETPROJECTS as DECLARE
    IDS varchar2(1000);
    l_act_code varchar2(100) :=4;
    begin
    IDS:='';
    l_act_code := wwv_flow.g_x01;
    for x in(
    SELECT ACT_CODE,PROJECT_ID
    FROM ASQ_CONTACT
    where ACT_CODE = l_act_code)
    LOOP
    IDS := IDS || X.PROJECT_ID|| ':' ;
    END LOOP;
    HTP.PRN(IDS);
    END;
    3) Changed the 'onchange' event-handler on p1_act_code to be 'onchange=hilitebtn(this.value)'
    4) Added the JS to the HTML Page Footer <script>
    hilitebtn($v('P1_ACT_CODE'));
    </SCRIPT>

  • How to use a select list value in a PL/SQL function body returning SQLquery

    Hi Friends,
    I have a select list P6_TEST with values 'nav' anf 'jyo'. I am trying to create a report using "SQL Query (PL/SQL
    function body returning SQL query)". In my report query can i check if P6_TEST='nav' and do something like the
    code shown below.How can i do that.
    DECLARE
    v_sql VARCHAR2(3000);
    BEGIN
    IF :P6_TEST = 'nav' THEN
    v_sql :=
    'SELECT
    * from department';
    ........................Thanks,
    Nav

    Nav:
    What you have should work. Give it a go. Post back if you run into issues.
    Varad

  • Using return value of a pl/sql function in the "where" coarse in a

    Hi,
    I have a question,
    if I have a pl/sql function that returns a boolean value, how can I use
    it directly in a select statement?
    I can easily do this if the function returns a number value , e.g.
    select * from my_table where my_package.function('abc') = 1;
    But I can't figure out how to do this if the function return a boolean.
    Any idea other than creating another function?
    Please reply to me directly as I'm not in the email list. Thanks.

    BOOLEAN is not a SQL datatype - you can only reference Boolean values in PL/SQL.

  • Catch a value from a pl*sql function in a shell script

    Hi all,
    I have a shell script that simply calls the following pl*sql function.
    echo "execute scott.my_pkg.test('FDLmaster');\n exit;" >./pippo.sql
    sqlplus scott/tiger @/fidcap_ftp/FDL/SCRIPTS/pippo.sql
    What I have to do to catch the value returned from the function test?
    Thanks in advance
    best regards
    Mario

    SQL> create or replace function do_something return varchar2 is
      2  begin
      3      return ('Something');
      4* end;
    SQL> /
    Function created.
    SQL> select do_something from dual;
    DO_SOMETHING
    Something
    SQL> save pippo
    Created file pippo.sql
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [linuxas tmp test10]$ echo exit >>pippo.sql
    [linuxas tmp test10]$ VAR=`sqlplus -s scott/tiger @pippo`
    [linuxas tmp test10]$ echo $VAR | cut -f3 -d" "
    Something
    [linuxas tmp test10]$

  • Returning a number with precsion in pl/sql function

    How can I return a number with desired precision in oracle function
    e.g
    Function return_number ( --- )
    return number
    is
    v_number number(10,2)
    begin
    select no into v_number from table;
    return v_number;
    end;
    will this work

    How can I return a number with desired precision in oracle functionCreate a subtype as e.g. in
    SQL> create or replace package pkg
    as
    subtype n10_2 is number(10,2);
    end pkg;
    Package created.
    SQL> create or replace function return_number
       return pkg.n10_2
    is
       v_number       pkg.n10_2;
    begin
       return v_number;
    end return_number;
    Function created.
    SQL> select object_name ,data_type, data_precision, data_scale from user_arguments where object_name = 'RETURN_NUMBER'
    OBJECT_NAME                    DATA_TYPE                      DATA_PRECISION DATA_SCALE
    RETURN_NUMBER                  NUMBER                                     10          2
    1 row selected.also possible:
    ... return tab.col%type;where col is a column of tab with data type number(10,2).

  • Passing dynamic list / array of values to Droplet

    I want to know what's the best way to pass list of values as array or list to a droplet.
    Any examples here?

    u can refer to the following droplet , it uses both list and array
    <droplet bean="/atg/commerce/pricing/PriceEachItem">
    <param name="items" value="param:product.childSKUs">
    <!-- the product param is already defined in this scope so we do not need to set it -->
    <oparam name="output">
      <!-- Now iterate over each of the CommerceItems to display the prices -->
      <droplet bean="/atg/dynamo/droplet/ForEach">
      <param name="array" value="param:element">
      <param name="elementName" value="pricedItem">
      <oparam name="output">
      <valueof param="pricedItem.auxiliaryData.catalogRef.displayName"></valueof> -
      <!-- Toggle a different display depending if the item is on sale or not -->
      <droplet bean="Switch">
      <param name="value" value="param:pricedItem.priceInfo.onSale">
      <oparam name="false">
      <valueof param="pricedItem.priceInfo.amount" currency>no price</valueof>
      </oparam>
      <oparam name="true">
      List price for <valueof param="pricedItem.priceInfo.listPrice" currency>no price</valueof>
      on sale for <valueof param="pricedItem.priceInfo.salePrice" currency></valueof>!
      </oparam>
      </droplet><BR>
      </oparam> 
      </droplet>
    </oparam>
    </droplet>

  • Need to pass value from check box to the pl/sql function in process

    My requirement is to use single value check box and pass the flag value to the pl/sql function.
    The function need to interpret the flag and execute accordingly.
    In this case checkbox name is P1_DELETE and it returns Delete, if checked.
    Anonymous block with in the process looks as follows:
    declare
    l_result VARCHAR2(1024);
    begin
    l_result := test_function(:P1_DELETE);
    end;

    Hi Visu,
    checkboxes in APEX are handled as arrays, namely APEX_APPLICATION_GLOBAL.VC_ARR2. To pass and process the checked values of checkboxes in a pl/sql function or procedure you could use the following way, assuming you have a checkbox named P1_DELETE with a single return value of "Delete"
    DECLARE
        l_checkbox_values apex_application_global.vc_arr2;
    BEGIN
        l_checkbox := :P1_DELETE;
        -- calling function test_function processing the value
        test_function(NVL(l_checkbox(1), 'SOME_OTHER_VALUE'));
    END;If the checkbox is not checked then the array at position 1 is null and you have to process that as you like.
    If your checkbox would be a group than the array would be colon separated such as 1:2:3:4 etc. and you would have to loop the array like:
        FOR idx IN 1..l_checkbox.COUNT LOOP
            test_function(l_checkbox(idx));
        END LOOP;Hope that helps.
    Andreas

  • Problem with empty report parameters when passed to PL/SQL function

    Hi,
    We have come across what appears to be a bug in the JRC. When passing a report parameter to a PL/SQL function as a parameter, empty parameters are changed before being sent to the function. More specifically, an empty string "" ends up as the value "(')" in the PL/SQL function parameter. In our report we print the report parameters on the first page so we know that the parameters are OK before being passed to the database.
    The problem exists for version 12.2.203, 12.2.204 and 12.2.205 of the JRC.
    We have identified a workaround, but it is not exactly elegant: Before executing the report we modify all empty  parameters ("") to " " . In the PL/SQL function, we trim all parameters before using them.
    We call the function using a command object with a sql syntax like this example:
    select * from table (qa_batch_release.get_qa_br('{?p_report_id}','{?p_reg_set_number}','{?p_cr_number}','{?p_change_id_decode}','{?p_country_id}','{?p_mfg_item_no}','{?p_4_no}','{?p_5_no}','{?p_7_no}'))
    The PL/SQL function is a table returning function.
    Best regards, Thor

    Hi Kishore,
    using #COLUMN_VALUE# would probably not make much sense, because normally a report has multiple columns and not just the numeric column which you want to verify if it's negative. But APEX will fire the template condition for each column, because the report template is a column cell template.
    What you can do to make it more generic is to use for example
    #CHECK_AMOUNT#
    in the template and provide a not displayed column in your SQL statement which contains your value which is named CHECK_AMOUNT. For example:
    SELECT NAME
         , BALANCE
         , BALANCE AS CHECK_AMOUNT
    FROM XXX;Because this CHECK_AMOUNT column would be a generic name, you can use this template in all your reports as long as you provide this column.
    Thope that helps
    Patrick

  • Multiple Select List looping thru PL/SQL function body returning SQL query

    Hi,
    I have a Multiple Select List. I want to loop through the values from the Select List and process them in a PL/SQL function body returning a SQL query. Currently, my code only returns the SQL SELECT results of one item in the select list. How do I change my code to make it return the results of all of the items in the select list? (I tested it and it is definitely picking up all the values in the select list).
    <b>
    DECLARE
    selected_items HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    s   VARCHAR2(20);
    q varchar2(32767);
    BEGIN
    selected_items := HTMLDB_UTIL.STRING_TO_TABLE(:P50_SELECTED_INSTRUMENTS);
    -- htp.p('COUNT: '||selected_items.count);
      FOR i in 1..selected_items.count LOOP
      s := TO_CHAR(selected_items(i));
    -- htp.p('First: '||s);
    -- htp.p('Second: '||:s);
    -- htp.p('Third: '||TO_CHAR(selected_items(i)));
      q:= 'SELECT  '||
    'SUBSTR(orig_geo_loc_sys,1,INSTR(orig_geo_loc_sys,''-'')-1) AS INSTRUMENT, '||
    'SUBSTR(orig_geo_loc_sys,INSTR(orig_geo_loc_sys,''-'')+1, LENGTH'||
    ' (orig_geo_loc_sys)) AS ORIG_LINENUM, '||
    'sum(orig_intrl) orig_intrl, '||
    'sum(orig_extrl) orig_extrl, '||
    'sum(recv_intrl) recv_intrl, '||
    'sum(recv_extrl) recv_extrl '||
    'FROM line_usage_sum_view '||
    'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''' || s ||'%'' '||
    --'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''2213003%'' '||
    'AND switch_id = ''' || :P1_SWITCH_ID || ''' ' ||
    'AND call_start_date > TO_DATE(''30-NOV-1999'') ' ||
    'AND call_clear_time > TO_DATE(''30-NOV-1999'') '||
    'AND '||
    :SORTFIELD||' BETWEEN '||
    'TO_DATE(:STARTDATE,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:STOPDATE, ''dd-MON-YYYY HH24:MI'') '||
    'GROUP BY GROUPING SETS (orig_geo_loc_sys)';
    -- htp.p('SQL query: '||q);
      RETURN q;
      END LOOP;
    END;</b>
    Thank you,
    Laura

    Laura,
    First, I would be careful of introducing SQL Injection possibilities. Any time I see
    'Select ... ' || :P123_FOO || ' ... '
    I worry about sql injection. In your case you are converting :P50_SELECTED_INSTRUMENTS into selected_items and then selected_items into s. So when I see
    'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''' || s ||'%'' '||
    I think, "I could use sql Injection and hack this."
    So, I would do some validation on :P50_SELECTED_INSTRUMENTS or some other method to avoid this.
    I'm not certain I understand your query. Do you really intend to allow the user to select the beginning of a string and then find all rows that start with that string? Or, do you just want to let them find when it matches the string. This is one way if you want to do matching:
    DECLARE
    selected_items HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    s VARCHAR2(32767);
    q varchar2(32767);
    BEGIN
    -- Change the : separate string to be comma separated with quoted strings
    s := '''' || replace(:P50_SELECTED_INSTRUMENTS, ',', ''',''')|| '''' ;
    -- htp.p('COUNT: '||selected_items.count);
    q:= 'SELECT '||
    'SUBSTR(orig_geo_loc_sys,1,INSTR(orig_geo_loc_sys,''-'')-1) AS INSTRUMENT, '||
    'SUBSTR(orig_geo_loc_sys,INSTR(orig_geo_loc_sys,''-'')+1, LENGTH'||
    ' (orig_geo_loc_sys)) AS ORIG_LINENUM, '||
    'sum(orig_intrl) orig_intrl, '||
    'sum(orig_extrl) orig_extrl, '||
    'sum(recv_intrl) recv_intrl, '||
    'sum(recv_extrl) recv_extrl '||
    'FROM line_usage_sum_view '||
    'WHERE TO_CHAR(orig_geo_loc_sys) in (' || s ||' ) '||
    --'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''2213003%'' '||
    'AND switch_id = ''' || :P1_SWITCH_ID || ''' ' ||
    'AND call_start_date > TO_DATE(''30-NOV-1999'') ' ||
    'AND call_clear_time > TO_DATE(''30-NOV-1999'') '||
    'AND '||
    :SORTFIELD||' BETWEEN '||
    'TO_DATE(:STARTDATE,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:STOPDATE, ''dd-MON-YYYY HH24:MI'') '||
    'GROUP BY GROUPING SETS (orig_geo_loc_sys)';
    -- htp.p('SQL query: '||q);
    RETURN q;
    END;
    If you want to do something more like you originally stated, try this:
    DECLARE
    selected_items HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    s VARCHAR2(20);
    q varchar2(32767);
    BEGIN
    selected_items := HTMLDB_UTIL.STRING_TO_TABLE(:P50_SELECTED_INSTRUMENTS);
    -- htp.p('COUNT: '||selected_items.count);
    q:= 'SELECT '||
    'SUBSTR(orig_geo_loc_sys,1,INSTR(orig_geo_loc_sys,''-'')-1) AS INSTRUMENT, '||
    'SUBSTR(orig_geo_loc_sys,INSTR(orig_geo_loc_sys,''-'')+1, LENGTH'||
    ' (orig_geo_loc_sys)) AS ORIG_LINENUM, '||
    'sum(orig_intrl) orig_intrl, '||
    'sum(orig_extrl) orig_extrl, '||
    'sum(recv_intrl) recv_intrl, '||
    'sum(recv_extrl) recv_extrl '||
    'FROM line_usage_sum_view '||
    'WHERE 1=1 ';
    FOR i in 1..selected_items.count LOOP
    s := TO_CHAR(selected_items(i));
    q := q || ' and TO_CHAR(orig_geo_loc_sys) LIKE '''|| s ||'%'' ' ;
    END LOOP;
    q := q || ||'%'' '||
    --'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''2213003%'' '||
    'AND switch_id = ''' || :P1_SWITCH_ID || ''' ' ||
    'AND call_start_date > TO_DATE(''30-NOV-1999'') ' ||
    'AND call_clear_time > TO_DATE(''30-NOV-1999'') '||
    'AND '||
    :SORTFIELD||' BETWEEN '||
    'TO_DATE(:STARTDATE,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:STOPDATE, ''dd-MON-YYYY HH24:MI'') '||
    'GROUP BY GROUPING SETS (orig_geo_loc_sys)';
    -- htp.p('SQL query: '||q);
    RETURN q;
    END;
    Hope this helps...
    Anton

  • PL/SQL Function call error while reading or assigning returned value

    Hi,
    I am getting the following error while tryih to read the value of the PL/SQL Function. I am calling a function in one of my PL/SQL Packages passing mutliple IN parametes and the function returns some value back. Now on BPEL side when I try to read the return value I am getting an error:
    *<summary>*
    empty variable/expression result.
    xpath variable/expression expression "/ns3:OutputParameters/ns3:TEST_FUNCTION" is empty at line 124, when attempting reading/copying it.
    Please make sure the variable/expression result "/ns3:OutputParameters/ns3:TEST_FUNCTION" is not empty.
    *</summary>*
    Even though in the console when I check the Invoke Output Parameter it does shows me a valid value being retuned by a Function but when I am trying to Assgn this value to some variable using Assign Activity I get the above error.
    Even though all goes fine but looks like I am not able to read or assign the value returned from the Function.
    So just wondering if this even works as to me I have a very simple example and that seems not to work. Function is called successfully and is returning the value as I can see it in the BPEL console but when tryin to read or assign that value to some other variable I get the above error.
    Any ideas?
    Thanks

    This issue has come up a lot. The problem is with a mismatch between the version of JDeveloper and SOA. You'll encounter namespace issues if you use 10.1.3.1 in combination with 10.1.3.3 (or 10.1.3.4). You MUST synchronize both JDev and SOA to 10.1.3.3 or 10.1.3.4 (mixing 10.1.3.3 and 10.1.3.4 is OK). We changed when going to 10.1.3.3 by adding elementFormDefault="qualified" to the generated XSD. We used the default "unqualified" in 10.1.3.1. So you'll encounter namespace issues unless you're using 10.1.3.3 or higher JDev AND SOA. The fact that I see &lt;*db:*...&gt; tells me that you're using 10.1.3.1 JDeveloper. The correct solution is to upgrade your components.

  • Data passed from Java to a PL/SQL function

    OK, I am at the beginner-to-intermediate level when it comes to PL/SQL...and a virtual novice when it comes to Java, so please forgive me if my question seems strange or naive.
    We are developing a Java-based web app. Some of the screens are reminiscent of a spreadsheet-type layout--potentially LOTS of rows and LOTS of columns (actually, an open-ended # of rows/columns--the rows represent a particular 'thing' and the columns represent the dates on which that 'thing' occurred), where the user can check off any and all the cells that apply. We are also 'auditing' all database activity (who did what to the data, and when). The approach we have chosen is as follows: When the user clicks save, the first thing we do is 'inactivate' all of the existing active rows in the db for that screen, whether or not they have changed(i.e., there is an 'active' flag that we set to false & we also save the user id of the person making the change and the date time of the change). Then the Java code calls the database once per row/contiguous column unit. For instance, on a single row, if the user checks off columns 1-4 and 7-15 and column 21 the Java code will send three calls to the database for that row with info about the start/stop column for each unit.
    OK--here is my concern...the majority of the time there will be a reasonably small #of 'units'. Occasionally there will be a moderate, and once in awhile a LARGE # of 'units'. So, let's take an extreme case and say that currently the db has 200 such row/contiguous column units for a given screen. The user goes into that screen and adds the 201st unit, then clicks Save. Java calls the db to first inactivate the 200 rows. Then one by one Java calls the db to add the rows back in, only on row #40, the internet connection is lost. The only way the user can tell what happened is to look at the entire screen and reverify ALL the data in order to tell what got saved/resaved and what didn't. Obviously this is a bad situation that we want to avoid.
    I should add that the reason this approach was chosen is that the Java developers thought it would be way too complex in this situation to track the changes the user made on the screen, sort out what has been added/modified/deleted, and only call the db for changes.
    So given this background, can anyone offer any suggestions/ideas on how we can prevent unintended data loss given the auditing constraints and concern about minimizing complexity on the Java side (redesigning the GUI screen is NOT an option, as the users are very attached to this design)?
    Is there a way for Java to pass a multidimensional (& variable-sized) array to a PL/SQL function? Can Oracle's complex (row, table) data types be used in a function's parameter string, and if so...how?...Or else is there some way we can send a single call to the db on a screen like this one? We thought of calling the db once and sending one very large string packed with all the data (could get very big, not sure of Oracle's limatations on passed data--is it 32K for varchar2? )
    Advice, ideas, even random thoughts would be greatly appreciated!

    Tracy,
    <quote>… only on row #40, the internet connection is lost. The only way the user can tell what happened is to look at the entire screen and reverify ALL the data in order to tell what got saved/resaved and what didn't</quote>
    That would be "the only way" if the Java programmers had decided to totally bury the error … what should happen here is the end-user should get a proper error message … no need to re-verify at this point since all bets are off (in fact, nothing should’ve been changed in the database).
    Nonetheless, your concerns regarding the chosen approach are valid … making multiple calls to the database after a Save makes controlling a business transaction rather complex (in an n-tier system) … they should make one call only to the database passing in all the data to be saved … one database transaction … either all changes get applied or none.
    The fact that lots of data may need to be passed in for one Save is of no relevance … if you have to carry 500Kb of data for that screen then, well, you have to do it … 1 bucket of 500Kb or 50 buckets of 10Kb? … it doesn’t really matter as far as the actual transport part is concerned.
    As already answered, one can pass complex types in pl/sql … so one database call per Save would be my first random thought. There are lots of suspect things in here … some things you didn’t mentioned at all … like how is concurrency addressed? … have you/they implemented some sort of optimistic locking mechanism? Of course the architecture of your system won’t be solved in a forum … so, finding a good system/data/Oracle architect on site for the project would be my second random thought.
    PS. One last random thought … fight off that idea of packing and sending large strings (XML or not) … if the data is structured then contemplate XML for no more than few seconds.

  • Difficulty in using a variable to pass a list of names between 2 tables

    Hi All,
    I am trying to pass a list of names from one table as a variable to another table and trying to find the Highest level they exist at in the hierarchy. I am having some troubles with the variable and need some guidence and also if this should be a procedure or not.
    this is what i have now :
    Variable man_name Varchar;
    exec :man_name = (Select full_name from direct_manager_report)
    UPDATE direct_manager_report
    Set Manager_level_number =
    (Select 'Manager_Level_0' from manager_hierarchy where level_0_manager_name = man_name
    UNION
    Select 'Manager_Level_1' from manager_hierarchy where level_0_manager_name < > man_name AND level_1_manager_name = man_name
    UNION
    Select 'Manager_Level_2' from manager_hierarchy where level_1_manager_name < > man_name AND level_2_manager_name = man_name
    UNION
    Select 'Manager_Level_3' from manager_hierarchy where level_2_manager_name < > man_name AND level_3_manager_name = man_name
    Where full_name = man_name;
    Let me know what modifications have to be done for this the variable to get the name from table 1 and find the manager level from table 2 and populate it back in table 1.
    Any help is appreciated.
    Thanks

    Frank Kulash wrote:
    Hi,Thanks for your reply. I am sorry for not providing enough information.
    What's wrong with what you have now? I want to pass the manager name (about 2000) from direct_manager_report to the variable which i pass to manager_hierarchy table to find the highest level for each manager
    If it doesn't give the right results, then how is anyone except you to know what the right results are?
    Variable man_name Varchar;
    exec :man_name = (Select full_name from direct_manager_report)Does that really work for you?No thats why i said this is what i have and i am trying to see the best to past the list of manager names to get the level number.
    UPDATE direct_manager_report
    Set Manager_level_number =
    (Select 'Manager_Level_0' from manager_hierarchy where level_0_manager_name = man_name
    UNION
    Select 'Manager_Level_1' from manager_hierarchy where level_0_manager_name < > man_name AND level_1_manager_name = man_nameIt looks like something is missing on the line above. Did you mean "level_0_manager_name != man_name"?
    This site doesn't like to display the &lt;&gt; inequality operator. Always use the other (equivalent) inequality operator, !-, when posting here.
    UNION
    Select 'Manager_Level_2' from manager_hierarchy where level_1_manager_name < > man_name AND level_2_manager_name = man_name
    UNION
    Select 'Manager_Level_3' from manager_hierarchy where level_2_manager_name < > man_name AND level_3_manager_name = man_name
    Where full_name = man_name;Are you sure the UNION will never return more than 1 row?
    Let me know what modifications have to be done for this the variable to get the name from table 1 and find the manager level from table 2 and populate it back in table 1.Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data (in this case, the contents of table1 after everything is finished).
    See the forum FAQ {message:id=9360002}Sorry did not realize the missing !. Yes the union will always return one record for each manager name passed. I have tested the select part which hard coding the manager name and it does update the level number correctly. but i am struggling with passing a large list of values as a variable.
    This is the output i am looking for in the direct manager report table is :
    Manager Name | Manager Level Number
    ABC Manager Level 0
    XYZ Manager Level 1
    This is the structure of the manager hierarchy:
    Manager Level 0 Manager Level 1 Manager Level 2...Manager Level 14
    ABC ABC ABC ABC
    ABC XYZ XYZ XYZ
    Let me try the below but hopefully i am more clear on the requirement now.
    >
    You may want something like this
    MERGE INTO  direct_manager_report     dst
    USING   (
             SELECT    dmr.full_name
             ,           'Manager_Level_'
                    || MIN ( CASE  dmr.full_name
                                 WHEN  level_0_manager_name  THEN '0'
                                 WHEN  level_1_manager_name  THEN '1'
                                 WHEN  level_2_manager_name  THEN '2'
                                 WHEN  level_3_manager_name  THEN '3'
                               END
                     ) AS manager_level_number
             FROM      manager_hierarchy  dmr
             JOIN      manager_hierarchy      mh   ON   dmr.full_name IN ( level_0_manager_name
                                                                   , level_1_manager_name
                                                , level_2_manager_name
                                                , level_3_manager_name
             GROUP BY  dmr.full_name
         )                    src
    ON     ( dst.full_name  = src.full_name )
    WHEN MATCHED THEN UPDATE
    SET     dst.manager_level_number = src.manager_level_number
    Edited by: user599926 on Jun 4, 2013 9:41 PM

  • How to pass a list of parameters to a query?

    Hi,
    I use OracleXE 10 Database with JDeveloper 11g.
    In my project I use a Toplink mapping to get access to the database (Toplink Object Map file). This mapping xml file is called crmMap.xml.
    In the crmMap.xml file I define a mapping to a "User table" which has the four columns id (number), title (varchar2), firstName (varchar2) and lastName (varchar2). A title can have the four values Bachelor, Master, Doctor and Professor.
    I do define a query in crmMap.xml which has to find all the users that have a special title. I do give the query one parameter called "title" which has the type "java.util.ArrayList". The parameter "title" is a list that has for example the two values "Bachelor" and "Doctor", if I want to find all the users that are Bachelor or Doctor. The query looks like this ...
    Select * from User where title in(?title)I do use an EJB Session Bean to call the query. The code looks like this ...
    public List<User> findUserByStatus() {
        Session session = getSessionFactory().acquireSession();
        Vector params = new Vector(1);
        List stati = new ArrayList();
        stati.add("Doctor");
        stati.add("Bachelor");
        params.add(stati);
        List<User> result = (List<User>)session.executeQuery("findUserByStatus", User.class, params);
        session.release();
        return result;
    }Doing this I get an error, in the line
    List<User> result = (List<User>)session.executeQuery("findUserByStatus", User.class, params);while the app is trying to execute the query.
    Part of my log
    WARNING: ADFc: Invalid column type
    java.sql.SQLException: Invalid column type
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:116)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:177)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:233)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:407)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7931)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7511)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8168)
         at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8149)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:229)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.setPrimitiveParameterValue(DatabasePlatform.java:1694)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:1684)
         at oracle.toplink.platform.database.oracle.Oracle9Platform.setParameterValueInDatabaseCall(Oracle9Platform.java:339)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.setParameterValuesInDatabaseCall(DatabasePlatform.java:1669)
         at oracle.toplink.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:649)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:517)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:467)
         at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:447)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:179)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:250)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:583)
         at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:467)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:445)
         at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2260)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1074)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1032)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:945)
         at de.virtual7.crmTL.model.crmFacadeBean.findUserByStatus(crmFacadeBean.java:720)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
         at $Proxy90.findUserByStatus(Unknown Source)
         at de.virtual7.crmTL.model.crmFacade_etlagg_crmFacadeLocalImpl.findUserByStatus(crmFacade_etlagg_crmFacadeLocalImpl.java:838)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:563)
         at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2119)
         at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:2929)
         at oracle.adf.model.bean.DCBeanDataControl.invokeMethod(DCBeanDataControl.java:396)
         at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:258)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1441)
         at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2126)
         at oracle.adf.model.bean.DCBeanDataControl.invokeOperation(DCBeanDataControl.java:414)
         at oracle.adf.model.adapter.AdapterDCService.invokeOperation(AdapterDCService.java:311)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:697)
         at oracle.adf.model.binding.DCInvokeAction.refreshInternal(DCInvokeAction.java:46)
         at oracle.adf.model.binding.DCInvokeAction.refresh(DCInvokeAction.java:32)
         at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:2970)
         at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2639)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareModel(PageLifecycleImpl.java:110)
         at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.prepareModel(FacesPageLifecycle.java:77)
         at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(Lifecycle.java:135)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:190)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.mav$executePhase(ADFPhaseListener.java:19)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.startPageLifecycle(ADFPhaseListener.java:229)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(ADFPhaseListener.java:265)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:69)
         at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:51)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:175)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:279)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:239)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:196)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:139)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:85)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:257)
         at oracle.security.jps.wls.JpsWlsSubjectResolver.runJaasMode(JpsWlsSubjectResolver.java:250)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:100)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    07.09.2009 11:50:16 oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
    WARNUNG: ADFc: EJB Exception: : Lokaler Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g (11.1.1.0.1) (Build 081030)): oracle.toplink.exceptions.DatabaseException
    Interne Exception: java.sql.SQLException: Ungültiger Spaltentyp
    Fehlercode:17004
    Aufruf:Select * from User where title in(?title)
         bind => [[Doctor,Bachelor]]Does anyone know a way how to pass a list of parameters
    Thanks Bodhy

    Hi,
    One alternative way is to create String with , sepearted as pass the string to in clause.For example ,create a string ('Bachelor','Doctor') and pass this string to in clause.
    Session session = getSessionFactory().acquireSession();
    String params=( 'Bachelor','Doctor);
    List<User> result = (List<User>)session.executeQuery("findUserByStatus", User.class, params);
    session.release();
    This is an alternative way and workaround which can work for Strings .
    Or you can use EXpression to build the query to pass the collection as example given below.
    Expression addressExpression;
    ReadObjectQuery query = new ReadObjectQuery(Employee.class);
    ExpressionBuilder emp = query.getExpressionBuilder();
    addressExpression =
    emp.get("address").get("city").equal(
    emp.getParameter("employee").get("address").get("city"));
    query.setName("findByCity");
    query.setSelectionCriteria(addressExpression);
    query.addArgument("employee");
    Vector v = new Vector();
    v.addElement(employee);
    Employee e = (Employee) session.executeQuery(query, v);
    Hope this helps.
    Regards,
    Vinay Kumar

Maybe you are looking for

  • No more than one picture at a time...

    Photoshop will no longer let me open more than one picture.  I get the error message "Adobe Photoshop CS3 has encountered a problem and needs to close.  We are sorry for the inconvenience." And Photoshop closes.  Has anyone ever encountered this issu

  • Need help! easy question about scrollpane?

    DefaultStyledDocument document = new DefaultStyledDocument(); JTextPane tp = new JTextPane(document); tp.setMargin(new Insets(5,5,5,5)); JScrollPane tpScrollPane = new JScrollPane(); tpScrollPane.setBounds(new Rectangle(5,5,100,200)); tpScrollPane.ge

  • Restricting a sum output

    Say if you had a sum : the number of something = the number of something 1 + the number of something 2 + the number of something 3 If all the the attributes within the sum = 1, then obviously the number of something would = 3. However according to th

  • I can't install Mac OS X Lion, I want to go back to Snow Leopard

    The problem is I am stuck in the OS X Lion Install window but when I try to install it, it asks for my Apple ID, I give it but It says I haven't bought Lion. So I gave up and decided to just go back to Snow Leopard, how do I do that?

  • My ipod is stolen what can i do?

    my ipod touch is stolen, what can i do ?