Pass collections into to select query on IN caluse

Hi friends,
I wanted to pass collections in to select query IN caluse .
Eg..
Declare
type tab is table of varchar2(25);
v_tab tab:
type tab1 is table of varchar2(25);
v_tab1 tab:
Begin
select ename into v_tab from emp where deptno in (10,20,30);
select location into v_tab1 emp_hist where ename in ( v_tab1 ); -- here where i wnt to pass the collections
End;
i dont want to write an loop to do this , i like to use only collections ? any idea how
thanks in advance .
Raj

Hi Raj,
In the examples above you will need to have a type declared in the database, however you can create a pipelined function to do what you want... something like this,
SQL> Create OR Replace Package My_Types Is
  2 
  3     Type enames_tab Is Table Of Varchar2(50);
  4 
  5  End My_Types;
  6  /
Package created
SQL> Create OR Replace Function lookup_ename Return my_types.enames_tab
  2     Pipelined Is
  3     v_row   my_types.enames_tab;
  4     cur     Sys_Refcursor;
  5     v_ename Varchar2(50);
  6  Begin
  7     v_row := my_types.enames_tab();
  8     Open cur For
  9        SELECT ename
10          FROM emp
11         WHERE ename IN ('SMITH', 'JAMES', 'WARD');
12     Loop
13        Fetch cur
14           INTO v_ename;
15        Exit When cur%Notfound;
16        v_row.Extend;
17        v_row(v_row.Count) := v_ename;
18        Pipe Row(v_row(v_row.Count));
19     End Loop;
20     Return;
21  End;
22  /
Function created
SQL> Set Serveroutput on;
SQL> Declare
  2     v_tab my_types.enames_tab;
  3  Begin
  4     SELECT ename Bulk Collect
  5       INTO v_tab
  6       FROM emp
  7      WHERE ename IN (SELECT *
  8                        FROM Table(lookup_ename));
  9 
10     For i IN v_tab.First .. v_tab.Last Loop
11        dbms_output.put_line(v_tab(I));
12     End Loop;
13  End;
14  /
SMITH
WARD
JAMES
PL/SQL procedure successfully completedRegards,
Christian Balz

Similar Messages

  • Passing parameters to a Select Query

    Hi,
    I am going to add "send to" feild in the check in page, this field is a dropdown list filled by a Result set that retrieve users form User table according to the following query
    SELECT dname FROM USERS WHERE Umanager =? OR Umanager IN (SELECT Umanager FROM USERS WHERE DNAME= ?) OR DNAME IN (SELECT Umanager FROM USERS WHERE DNAME= ?)
    where ? represents the logged in user DNAME. the pomnit how can I pass this parameter from the check in page.

    Hey Younis, looks like you don't have the tracker installed, that's ok.
    A simpler way is to just write a service that calls the CHECKIN_NEW service and add that parameter you want to it; you can add this in the component you're already writing.
    These are the steps to you create a service called MY_CHECKIN:
    1. Open your custom component with component wizzard.
    2. In the Resource Definitions tab, click Add.
    3. Select Template and click Next.
    4. Click Next.
    5. Set the name to MY_CHECKIN.
    6. Set the Class to Pages.
    7. Set the Form Type to mycomponent.
    8. Set the File Name to my_service_page.htm.
    9. Click Finish.
    10. In the Resource Definitions tab, click Add.
    11. Select the Service button and click Next.
    12. Click Next.
    13. Name the service MY_CHECKIN and make it call CHECKIN_NEW and add the parameter you want.
    14. Set the Service Class to Service.
    15. Click Finish.
    16. Restart the Content Server.
    Hope that helps,

  • How to pass variable into lov sql query using like operator

    hi.
    i want to use a lov where i want to pass a variable using like operator.
    my query is
    select empno,name from table where empno like ':ed%';
    my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
    how can i do this ?
    reagrds

    kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
    and provide us with that detail
    and its better if you start new topic for that error... because that will be new error,,,
    -- Aamir Arif
    Edited by: Aamiz on Apr 7, 2010 12:27 PM

  • Pass Variables into AS3 through Query String?

    Man! I've been searching ferociously and can't seem to find a solution that works for me. I am trying to pass variables via query string on a PHP page to Flash, and then have the swf add movie clips to the stage depending on the information it receives.
    Here is what the PHP outputs:
    swfobject.embedSWF("flash/detailScore.swf?a=0-0&b=0-0&c=30-54&d=30-20&e=42-18", ...
    And here is my AS3 code:
    function loaderInfoSh(e:Event):void{
    var myQueryStrings=this.loaderInfo.parameters;
    a = myQueryStrings.a;
    b = myQueryStrings.b;
      c = myQueryStrings.c;
    d = myQueryStrings.d;
    e = myQueryStrings.e;
    addTheResults(a,1);
    addTheResults(b,2);
    addTheResults(c,3);
    addTheResults(d,4);
    addTheResults(e,5);
    this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoSh);
    The addTheResults function takes the coordinates, adds a MC instance to the stage and positions it accordingly.
    var colorMCArray:Array = new Array();
    function addTheResults(val,colnum:Number){
    if(val == null){val = "52-46";} // so I can test it locally
    var daColor:String;
    switch (colnum){
    case 1:
    daColor = "f3951c";
    break;
    case 2:
    daColor = "74b47d";
    break;
    case 3:
    daColor = "436494";
    break;
    case 4:
    daColor = "9b74ac";
    break;
    case 5:
    daColor = "b43d44";
    break;
    var dash:int = val.indexOf("-");
    var lateral = val.slice(0,dash);
    var vertical = val.slice(dash+1);
    lateral --;
    vertical --;
    // adding the MC instance
    var comm:tileB = new tileB();
    comm.name = "comm"+colnum;
    addChild(comm);
    colorMCArray[colnum] = comm;
    //Change the color
    var colorTransform:ColorTransform = colorMCArray[colnum].transform.colorTransform;
    var thiscolor = "0x"+daColor;
    colorTransform.color = thiscolor;
    colorMCArray[colnum].transform.colorTransform = colorTransform;
    colorMCArray[colnum].x = 5;
    colorMCArray[colnum].y = 536;
    colorMCArray[colnum].x += (lateral * 9);
    colorMCArray[colnum].y += (vertical * 9)*-1;
    colorMCArray[colnum].addEventListener(MouseEvent.MOUSE_OVER, btnro);
    colorMCArray[colnum].addEventListener(MouseEvent.MOUSE_OUT, btnrout);
    I don't know what I'm doing wrong here.

    Was this the "e" in the code below you were pertaining to as the culprit? "e" is not a keyword. It's just the shortcut for the word "event" for the variable name of type Event which is the Event object that triggered the call of function loaderInfoSh. In your code you assigned e = myQueryString.e which should have given you a type mismatch error.
    function loaderInfoSh(e:Event):void{
    var myQueryStrings=this.loaderInfo.parameters;
    a = myQueryStrings.a;
    b = myQueryStrings.b;
      c = myQueryStrings.c;
    d = myQueryStrings.d;
    e = myQueryStrings.e;
    addTheResults(a,1);
    addTheResults(b,2);
    addTheResults(c,3);
    addTheResults(d,4);
    addTheResults(e,5);
    this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoSh);

  • Select query using variable

    Hi all,
    If I have a variable with multiple value (returned from bulk collect), how can I pass it into a select query as a condition?
    Eg.
    set serveroutput on
    declare
    type v_LockSessInfo is table of integer;
    empdata v_LockSessInfo;
    begin
    select unique sid bulk collect into empdata from v$lock;
    [select sid,serial#,username from v$session where sid in (empdata)]
    end;
    I hope to be able to pass in the variable collected, into the next select statement. How can I achieve it?
    Thanks in advance.
    Eugene

    Sorry for any confusion caused, I have almost 0 knowledge on pl/sql, only can survie on normal sql query.
    Further elaboration, the intention of my query is to query out any locking that exists in my DB. It meant to serve as a report to management, so I have to break it down into couple of sections for easier reference (minimising the complication that may arise from others who view the report).
    Couple of steps/procedures I am thinking of:
    1) query out the unique sid that exists in v$lock (blocking and blocked sessions) <<< this set of returned record (SIDs) should be stored in a variable.
    Eg. achived by the select statement "select unique sid from v$lock into [variable]"
    2) query v$sessions for the lock details from step 1's output. Username, sid, serial#, machine etc.
    Eg. To be achieved by "select sid,serial#...... from v$session where sid in [variable]; Same condition applies to 2 and 3.
    3) query v$locked_object to identify which are the blocking/blocked sessions, and who's blocking who from step 1's output.
    4) query the locked object and locked record (based on rowid locked) from step 1's output.
    This is all that I can think of at the moment. Any opinions that can perform the above activity will be appreciated alot. Hope I'm able to clear up any confusion triggered.
    PS: I can't re-query the SID as the SID may change or be lost upon the re-query therefore losing any evident. Thus I was thinking of putting it into a variable for consistent querying for step 2,3 and 4. All 4 steps will be performed within a single script.
    Regards
    Eugene
    Edited by: eteo78 on May 28, 2009 8:40 AM

  • How to compare dates in a select query in open sql

    Hi
                       How can I retrieve data pertaining to a specified date using a select query.
    I have inserted date using the following code:
    String dateString = "2009-03-11";
    java.sql.Date date = java.sql.Date.valueOf(dateString);
    PreparedStatement stmt =con.prepareStatement("insert into DATEACCESS"
                                                                            + "(DATETEST)"
                                                                            + "values (?)");
    stmt.setDate(1,date);
    stmt.executeUpdate();
    How can I pass this in a select query,the below mentioned query did not fetch me any results.
    Select * from  DATEACCESS where DATETEST='2009-03-11'

    Hi
    Has ur date  problem resolved  ?
    If not resolved u can do the following
    As u already have sql date today declared . You want to get the data depending on that date
    As ur query is
    if( today != null)
    String query2 = select * from DATEACCESS where DATETEST<= ?
    PreparedStatement ps = conn.prepareStatement(query2);
    ps.setDate(1,today)
    ResultSet rs = ps.executeQuery();
    While(rs.next)
        ////// Here u will get data from query u needed ///
    If this also does not work just print the date and check in which format is it returning u .
    Regards
    Anuradha Rao
    Edited by: Anuradha Rao on Mar 20, 2009 10:16 AM

  • Using buffering option in select query

    Hi All,
           Can anybody give me a brief idea on , where we will use the buffering and how we will write it in coding part.Similarly please tell me what will happen if we use  by passing buffering  addition in select query. Please explain  it with steps of sample code if possible.
    Thanks in advance.
    Regards,
    Rakesh.

    Hi Sharma,
    Buffer is used to hold large amount of data.
    if internla table is unable to hold data.. Buffer is used..this is mainly used in copy data from PRD to Quality as a part testung.
    see the sample code how the buffer is used..
    FUNCTION zzrfc_get_zcpeg_fg_related.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(PL_VERSION) LIKE  ZCPEG_FG_RELATED-PL_VERSION OPTIONAL
    *"     VALUE(BYPASS_BUFFER) LIKE  SY-FTYPE DEFAULT SPACE
    *"     VALUE(FROM_KEY) LIKE  SY-ENTRY DEFAULT SPACE
    *"     VALUE(GEN_KEY) LIKE  SY-ENTRY DEFAULT SPACE
    *"     VALUE(MAX_ENTRIES) LIKE  SY-TABIX DEFAULT 0
    *"     VALUE(TABLE_NAME) LIKE  X030L-TABNAME
    *"     VALUE(TO_KEY) LIKE  SY-ENTRY DEFAULT SPACE
    *"  EXPORTING
    *"     VALUE(NUMBER_OF_ENTRIES) LIKE  SY-INDEX
    *"  TABLES
    *"      ENTRIES STRUCTURE  ZCPEG_FG_RELATED
    *"  EXCEPTIONS
    *"      INTERNAL_ERROR
    *"      TABLE_EMPTY
    *"      TABLE_NOT_FOUND
      TABLES dd02l.
      DATA: BEGIN OF buf OCCURS 100,
                line(4100),
            END OF buf.
      DATA keyln TYPE i.
      DATA: l_tabname LIKE dd25v-viewname.
      DATA: l_len     TYPE i.
      DATA : w_plversion TYPE /sapapo/vrsioex.   "PJONNALA
      w_plversion =  pl_version.                 "PJONNALA
      l_tabname = table_name.
      CALL FUNCTION 'VIEW_AUTHORITY_CHECK'
        EXPORTING
          view_action                = 'S'
          view_name                  = l_tabname
          no_warning_for_clientindep = 'X'
        EXCEPTIONS
          OTHERS                     = 6.
      IF sy-subrc <> 0.
        RAISE internal_error.
      ENDIF.
      IF bypass_buffer NE ' ' AND bypass_buffer NE 'N'.
        bypass_buffer = 'Y'.
      ENDIF.
      IF gen_key CA ' '. ENDIF.
      keyln = sy-fdpos.
    * read client dependant tables always with client
      SELECT SINGLE * FROM dd02l WHERE tabname = table_name
                                  AND as4local =  'A'.
      IF dd02l-clidep = 'X'.
    *l_len = strlen( sy-mandt ) * cl_abap_char_utilities=>charsize.
    *  " ecwg. unicode
    *    move gen_key to gen_key+l_len.
    *    move sy-mandt to gen_key(l_len).
    *    add l_len to keyln.
        CONCATENATE sy-mandt gen_key INTO gen_key.
        keyln = STRLEN( gen_key ) * cl_abap_char_utilities=>charsize.
      ENDIF.
    *  endselect.
      IF keyln NE 0 OR from_key = space.
        CALL 'C_GET_TABLE' ID 'TABLNAME'  FIELD table_name
                           ID 'INTTAB'    FIELD buf-*sys*
                           ID 'GENKEY'    FIELD gen_key
                           ID 'GENKEY_LN' FIELD keyln
                           ID 'DBCNT'     FIELD number_of_entries
                           ID 'BYPASS'    FIELD bypass_buffer.
      ELSE.
        CALL 'C_GET_TABLE' ID 'TABLNAME'  FIELD table_name
                           ID 'INTTAB'    FIELD buf-*sys*
                           ID 'FROM_KEY'  FIELD from_key
                           ID 'TO_KEY'    FIELD to_key
                           ID 'DBCNT'     FIELD number_of_entries
                           ID 'BYPASS'    FIELD bypass_buffer.
      ENDIF.
      CASE sy-subrc.
        WHEN 4.  RAISE table_empty.
        WHEN 8.  RAISE table_not_found.
        WHEN 12. RAISE internal_error.
      ENDCASE.
      DESCRIBE TABLE buf LINES number_of_entries.
    ENDFUNCTION.
    Regards,
    Prabhudas

  • BULK COLLECT INTO (Oracle 11 G)

    ORACLE 11G (The same code works fine in Oracle 9i)
    FETCH v_cursor BULK COLLECT INTO AuditData, AuditData1;
    the above statement gives me an error:-
    ORA-01007: variable not in select list
    ORA-06512: at "DEC0512.FCT_AUD_TRAIL_REAL_ENTRY_UPD", line 175
    ORA-06512: at line 1
    But if the change the statemement to
    FETCH v_cursor BULK COLLECT INTO AuditData;
    The query works fine.
    Any help will be much appreciated.

    >
    ORACLE 11G (The same code works fine in Oracle 9i)
    FETCH v_cursor BULK COLLECT INTO AuditData, AuditData1;
    the above statement gives me an error:-
    ORA-01007: variable not in select list
    ORA-06512: at "DEC0512.FCT_AUD_TRAIL_REAL_ENTRY_UPD", line 175
    ORA-06512: at line 1
    But if the change the statemement to
    FETCH v_cursor BULK COLLECT INTO AuditData;
    The query works fine.
    Any help will be much appreciated.
    >
    If the second query 'works fine' then your 'AuditData' collection is consuming all of the result set columns and there is nothing to put into the other collection.
    So you have a mismatch between the result set your cursor returns and those collections you are trying to put the data into.
    This works for me:
    DECLARE
      CURSOR c1 IS (SELECT empno, deptno FROM emp);
      empno_tab dbms_sql.number_table;
      deptno_tab dbms_sql.number_table;
    BEGIN
      OPEN c1;
      LOOP                                                 --Loop added
        FETCH c1 BULK COLLECT INTO empno_tab, deptno_tab LIMIT 3; -- process 3 records at a time
            -- process the first 3 records
           DBMS_OUTPUT.PUT_LINE('Processing ' || empno_tab.COUNT || ' records.');
            FOR i in 1..empno_tab.count loop
                dbms_output.put_line('empno is [' || empno_tab(i) || '].');
            end loop;
        EXIT WHEN c1%NOTFOUND;
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('All done');
    END;
    Processing 3 records.
    empno is [7369].
    empno is [7499].
    empno is [7521].
    Processing 3 records.
    empno is [7566].
    empno is [7654].
    empno is [7698].
    Processing 3 records.
    empno is [7782].
    empno is [7788].
    empno is [7839].
    Processing 3 records.
    empno is [7844].
    empno is [7876].
    empno is [7900].
    Processing 2 records.
    empno is [7902].
    empno is [7934].
    All done

  • How to ignore zero in select query

    select * from EINA where  EINAMATNR = <b>yyyy</b> and EINALIFNR = <b>zzzz</b>
    In select query, how to ignore zero? for example, EINAMATNR = 0000000yyyy, EINALIFNR=000zzz
    Maybe I can use LIKE keyword in sql query. Any other way?
    Thanks.

    Use the following conversion routines to convert yyyy & zzzz  to remove the leading zeros and then pass it to your select query.
    For Matnr -> CONVERSION_EXIT_MATN1_INPUT
    For LIFNR ->CONVERSION_EXIT_alpha_input.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = yyyy
            IMPORTING
              output = t_lifnr.
          CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
            EXPORTING
              input  = zzzz
            IMPORTING
              output = t_matnr.
    select * from EINA where EINA~MATNR = t_matnr  and EINA~LIFNR = t_lifnr .

  • How to split this select query

    Hi all,
    Can any one help me to split this single select query into 9 select query.   
    select KNA1STCEG VBRKBUKRS VBRKVKORG VBRKVBELN VBRKFKDAT VBRKFKART VBRKVBTYP VBRKVBUND VBRKKUNAG VBRKKUNRG VBRK~NETWR
               VBRKWAERK VBRKFKSTO VBRKSFAKN VBRKLAND1 T001WKUNNR VBRPPOSNR VBRPWERKS VBRPFKIMG VBRPVRKME VBRPPRSDT
               VBRPNETWR VBRPVGBEL VBRPVGPOS VBRPMATNR VBRPPRCTR VBRPCHARG VBRPAUBEL VBRPAUPOS VBRPVBELN T001WAERS T001~BUKRS
               MBEWSTPRS MBEWPEINH MBEWMATNR MBEWBWKEY LIKPLFART LIKPWERKS LIKPVBELN MBEW_RECVSTPRS MBEW_RECV~PEINH
               MBEW_RECVBWKEY MBEW_RECVMATNR CKMLCRBDATJ CKMLCRPOPER CKMLCRSTPRS CKMLCRWAERS CKMLCRPEINH CKMLCRCURTP
               CKMLCRKALNR CKMLCR_RECVSTPRS CKMLCR_RECVWAERS CKMLCR_RECVPEINH CKMLCR_RECVCURTP CKMLCR_RECVBDATJ CKMLCR_RECV~POPER
               CKMLCR_RECV~KALNR
        from ( KNA1
               left outer join VBRK
               on  VBRKKUNRG = KNA1KUNNR
               inner join T001W
               on  T001WKUNNR = VBRKKUNAG
               inner join VBRP
               on  VBRPVBELN = VBRKVBELN
               inner join T001
               on  T001BUKRS = VBRKBUKRS
               left outer join MBEW
               on  MBEWMATNR = VBRPMATNR
               and MBEWBWKEY = VBRPWERKS
               left outer join LIKP
               on  LIKPVBELN = VBRPVGBEL
               inner join MBEW  as MBEW_RECV
               on  MBEW_RECVBWKEY = T001WBWKEY
               and MBEW_RECVMATNR = VBRPMATNR
               inner join CKMLCR
               on  CKMLCRKALNR = MBEWKALN1
               inner join CKMLCR  as CKMLCR_RECV
               on  CKMLCR_RECVKALNR = MBEW_RECVKALN1 )
             where VBRP~WERKS in SP$00005
               and VBRP~MATNR in SP$00008
               and VBRP~CHARG in SP$00009
               and VBRP~AUBEL in SP$00017
               and CKMLCR~CURTP in SP$00015
               and CKMLCR~BDATJ in SP$00013
               and CKMLCR~POPER in SP$00014
               and CKMLCR_RECV~CURTP in SP$00019
               and CKMLCR_RECV~BDATJ in SP$00020
               and CKMLCR_RECV~POPER in SP$00018 .

    Hi, it is not good for your performance to split into 9 selects but the select you are now using is also not so good. Start with VBRP instead of KNA1.
    You can do it in the following way. For example:
    DATA tb_kna1  TYPE STANDARD TABLE OF kna1.
    DATA tb_vbrk  TYPE STANDARD TABLE OF vrbk.
    DATA tb_vrbp  TYPE STANDARD TABLE OF vrbp.
    Start with VRBP for a better performance
    SELECT * FROM vrbp
      INTO CORRESPONDING FIELDS OF TABLE tb_vbrp
      WHERE werks IN ....   etc.
    SELECT * FROM vbrk
      INTO CORRESPONDING FIELDS OF TABLE tb_vbrk
      FOR ALL ENTRIES IN tb_vrbp
      WHERE vbeln = tb_vrbp-vbeln.
    SELECT * FROM kna1
      INTO CORRESPONDING FIELDS OF TABLE tb_kna1
      FOR ALL ENTRIES IN tb_vrbk
      WHERE kunnr = tb_vrbk-kunnr.
    Success.

  • How to pass the feild names of a select query dynamically?

    Hi
    How can we pass the feilds names in select query dynamically?
    For example in my selection screen i wil be giving the table name, and feilds in that table.....
    those feilds should be taken in my select query...
    instead of
    PARAMETERS : tab_name TYPE ddobjname .
      SELECT *
        FROM (tab_name)
        INTO TABLE <newtab>
       UP TO 25 ROWS.
    parametrs : feild1 like-------
                     feild2----
    i need select feild1 feild2 feild3    FROM (tab_name)
        INTO TABLE <newtab>
       UP TO 25 ROWS.

    by the way, contrary to popular belief there is no performance problem when using
    SELECT * FROM dbtab INTO CORRESPONDING FIELDS OF TABLE itab WHERE ...
    as long as the structure of itab contains only the required fields.
    I ran some benchmarks against this and above construct is maybe 0.1% slower (Oracle 10g) than a
    SELECT f1 f2 f3 f4 ... FROM dbtab INTO TABLE itab WHERE ...
    but is saves you from maintaining a potentially very long field list in your code. So when you need additional fields later on, you just add them to the DDIC structure or type definition and that's it.
    Maybe something you want to factor in here.
    Cheers
    Thomas

  • Passing a string into an SQL query IN statement

    Hello,
    I need to connect to a database to pull some data to dynamically create a form based on the data I pull back. My SQL query works fine when I manually run it through a SQL client tool, but when I try to pass it through my workflow I'm having trouble with passing my string into the IN part of the statement. So if for example my SQL query is:
    SELECT Field1, Field2, Field3 FROM Table1 WHERE Field4 IN (?)
    I have a process variable that has the string I'm trying to pass into the ?, but I don't seem to be able to get the query to run. I have tried setting up my query to run as a Parameterized Query (passing my string process variable into the ?), and by setting the query up through xPath (where I am calling my process variable with an xPath declaration), but am not having any luck.
    The process variable I am trying to pass is formatted such that I'm passing 'Value1','Value2','Value3' but I can reformat this string if need be. Even with using test data I can't get the query to return anything. For test data I have tried: 'Value1','Value2','Value3' ; Value1','Value2','Value3 ; Value1,Value2,Value3 but the query never returns any data. I can't seem to see how to format the string to pass into the query. The Query will work with a single Value in the test data, but as soon as I try to pass multiple values within the string it fails. Any suggestions?

    The problem looks to be a limit on what I can pass into the SQL query component. My string is coming from data returned from another database. I take the xml output from that database call, pass it through a set variable component to remove my xml tags from the string, and then format the string in a script component (I have to do it this way because of the way the data coming out of my first database call). I've put in loggers, and can see that the string I'm passing into my query that is giving me problems, is formatted the same way as if I were to use the concat function Scott listed above. It looks like there is a limitation on what can be passed in my variable. I have tried creating my entire SQL query statement in a set variable component, and then just calling the process variable that holds that statement, but there is a character limit of 128 character for what can be passed in a variable through xpath in the SQL query component.
    The next thing I tried was changing my SQL where clause. Instead of passing my variable directly into the IN statement I set up a PATINDEX('%:'+countyname+ ':%', ?) > 0 call to check for the values in my database call. As you can see I took out the "," that I was passing as part of my string, thinking that the SQL component was getting confused by them, and placed ":" characters around my values being passed in my string variable. No matter what I try to do though I'm not able to get the query to run. The component looks like it is taking my string, and is seeing the whole thing as a string instead of passing it as individual values within a string.
    I think I'm getting close, but I keep getting a Content not allowed in prolog exception in the server logs.

  • Nested table collection in select query "in clause" taking long time

    create or replace type t_circuitids is table of varchar2(100);
    --Below anonymous block keeps on running and never ends
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (v_circuitid));
    END;
    --I got the issue, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" which is used in above code is responsible for this.
    --Same code works fine in Development and Test environments, But in prod it keeps on running
    --I solved this issue by creating a temp table, loading all values in collection into the temp table and using that temp table in "in clause"    "
    --Can any one answer why its behaving like this when i use collection in where clause?
    --I am using Oracle 9i

    Below is the code i used
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (ccard(v_circuitid)));
    END;
    And got below error
    ORA-06550: line 27, column 5:
    PL/SQL: ORA-00906: missing left parenthesis
    ORA-06550: line 24, column 4:
    PL/SQL: SQL Statement ignored

  • Getting Username to pass into LOV select statement

    Hello!
    I'm wondering if its possible to get the username of the current user logged in and pass it as a variable into a select statement used in a dynamic LOV in Oracle AS Portal?
    What I'm attempting to do is pull all the values from a table that equal the current user's username to user on a portal report
    so (as a rough example)
    select color from mytable where username = 'whatever the user name is would be here'
    And then the current user would get a list of values from which to select based off of the values entered in this table.
    The issue I'm having is determing how to fill the 'whatever the user name is would be here' portion with the actual logged in user's username (or even if its possible). I know on the actual portal one can do #USER.FULLNAME# to display their username, is there a similar "variable" one may use to get the username for a LOV sql call?
    I can get it to work if I statically fix the username to a particular value (ex: where username = 'Joe.Hacker') but I'm unsure if theres a variable or bind value (for lack of a better term) to grab the username on the fly.. dynamically.

    portal.wwctx_api.get_user can be used in the SQL query of your portal report to get the user_name of the currently logged-in portal user. For more info on wwctx_api, see the 10.1.2 or 10.1.4 portal API docs at http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1012/index.html or http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1014/index.html

  • Passing user parameter into your sql query

    I've created two user parameters...'Order_date_from' and 'Order_date_to'
    I've written a simple query to list the total order amount, order number, party name and ordered date
    Select sum ((unit_selling_price)*(ordered_quantity)), count(line_number), oe_order_headers_all.order_number, hz_parties.party_name, oe_order_headers_all.ordered_date
    from oe_order_lines_all,
    oe_order_headers_all,
    hz_parties,
    hz_cust_accounts
    where oe_order_lines_all.header_id=oe_order_headers_all.header_id
    and oe_order_headers_all.sold_to_org_id = hz_cust_accounts.cust_account_id
    and hz_cust_accounts.party_id = hz_parties.party_id
    group by order_number, party_name, ordered_date;
    I want to know how I can pass the value for the above mentioned parameters into my sql query so that it reflects as the 'ordered_date' in the report and only shows the data for the dates that the user inputs.
    Any feedback would be appreciated. Thanks.

    I want to know how I can pass the value for the above
    mentioned parameters into my sql query so that it
    reflects as the 'ordered_date' in the report and only
    shows the data for the dates that the user inputs.
    Any feedback would be appreciated. Thanks.And how does the "user" input these dates?

Maybe you are looking for

  • Using class from one application in another application

    How can I use a class deployed as part of an application in another application withour putting the jar files in the classpath? For example, there two application deployed: app1 and app2. An EJB in app1, app1_ejb1, uses an class, app2_class1. In orde

  • Search feature in Abobe X

    I'm viewing a pdf document (2000 pages) and can't find a "search" feature in the Adobe X tool bar - is ther one and how can I activate it?  Thank you - -

  • My whole music store is in French!

    Hi! I've just updated my old iTunes and iPod to the newest version. But oh dear, the whole music store is in French and I can't understand anything. I want podcasts, English podcasts, goddamnit! If anyone could explain to me how to change the languag

  • Computers came with Windows 7 64-bit and we need Windows 7 32-bit

    Our company purchased 5 IdeaCentre K300 computers from a big blue retail store. The computers came with W7 64-bit Home Premium preinstalled. We also purchased 5 Windows Anytime Upgrade PIN's  allowing us to upgrade to W7 Professional so we can add th

  • Settlement Profile for Sales Order make to Order Production.

    Hi This is the first time I am working for CO and I do have a very basic question: When our settlement process is complete (production order and sales order both settled to COPA), there is a balance remaining on the sales order cost report which is e