Using rowconcat in where cluse

hi all
i need to use rowconcat function in my where cluse
ex:
select id,name
from emp
where id in (select rowconcat('select emp_id from emp_test') from dual);
select rowconcat('select emp_id from emp_test') from dual = returned (2,10,14,20)
plz help

Why not:
select id,name
from emp
where id in (select emp_id from emp_test);Again, I don't know your business logic, but assuming there is a need for dynamic SQL I'd use pipelined table function:
create or replace
  type NumList
    as
      table of number
create or replace
  function num_list(
                    v_stmt varchar2
    return NumList
    pipelined
    is
        v_num number;
        v_cur sys_refcursor;
    begin
        open v_cur for stmt;
        loop
          fetch v_cur
            into v_num;
          exit when v_cur%notfound;
          pipe row(v_num);
        end loop;
        close v_cur;
        return;
end;
select  id,
        name
  from  emp
  where id in (select * from table(num_list('select emp_id from emp_test')))
/SY.
P.S. You can also make pipelined function to run in parallel.

Similar Messages

  • Can you use home share where there are 2 itunes on the same computer but under different user profiles?

    Can you use 'Home Share' where there are 2 itunes on the same computer, but under different user profiles?

    check out method one from this support article -> How to use multiple iPods, iPads, or iPhones with one computer

  • How do i use ichat? Where is it on my macbook air?

    I want to video chat, i heard about ichat but i don't know how to use it or where it is on my desktop?
    10 points to best answer!

    When you select , you will see "About this Mac". After you click it, a window will appear, so look at "Version" under OS X text.

  • Selecting using a field that stores a column_name to be used in the where

    I have a table REPORTING_CRITERIA with fields and field values:
    gl_criteria1 = 'cc.segment5'
    from_value1= '1123'
    to_value1= '1130'
    gl_criteria2 = 'cc.segment5'
    from_value2 = '1140'
    to_value2 = '1150'
    I am trying to run a select where I pull records where the actual field name stored in gl_criteria1 and gl_criteria2 is used in the where clause.
    ie.
    select bal.gl_balance, account_code
    from gl_balances bal, accounts cc, reporting_criteria crit
    where crit.report_name ='BUDGET'
    and crit.gl_criteria1 between crit.from_value1 and crit.to_value1
    What I want is to have the where read like:
    where crit.report_name ='BUDGET'
    and cc.segment5 between crit.from_value1 and crit.to_value1
    Thus cc.segment5 is the value stored in the reporting_criteria table in the gl_criteria1 field but it is an actual db column to be used in my select.
    How can I get this query to work so that the contents of gl_criteria1 field are actually read like a column name in my where?
    Edited by: ajgolden87 on Nov 8, 2012 11:10 AM

    Hi,
    You should know the column names of the table you are quering. If so you can make queries like this:
    with CC as
    select 1 id, 1123 segment5 from dual union all
    select 2 id, 1124 segment5 from dual union all
    select 3 id, 1125 segment5 from dual union all
    select 4 id, 1126 segment5 from dual union all
    select 5 id, 1127 segment5 from dual union all
    select 6 id, 1128 segment5 from dual union all
    select 7 id, 1129 segment5 from dual union all
    select 8 id, 1130 segment5 from dual union all
    select 9 id, 1131 segment5 from dual union all
    select 10 id, 1132 segment5 from dual
    ,REPORTING_CRITERIA  AS
    SELECT
      'SEGMENT5'        GL_CRITERRIA_1
      ,'1123'           FROM_VALUE_1
      ,'1130'           TO_VALUE_1
      ,'ID'             GL_CRITERRIA_2
      ,'4'              FROM_VALUE_2
      ,'7'              TO_VALUE_2
    FROM
      DUAL
    SELECT
      cc.*
    FROM
      CC
      ,REPORTING_CRITERIA
    WHERE
      GL_CRITERRIA_1 IS NULL
      OR CASE WHEN GL_CRITERRIA_1 = 'SEGMENT5' THEN SEGMENT5
              WHEN GL_CRITERRIA_1 = 'ID' THEN ID
              ELSE NULL END BETWEEN FROM_VALUE_1 AND TO_VALUE_1
      ) AND
      GL_CRITERRIA_2 IS NULL
      OR CASE WHEN GL_CRITERRIA_2 = 'SEGMENT5' THEN SEGMENT5
              WHEN GL_CRITERRIA_2 = 'ID' THEN ID
              ELSE NULL END BETWEEN FROM_VALUE_2 AND TO_VALUE_2
    ID SEGMENT5
    4     1126
    5     1127
    6     1128
    7     1129 Regards,
    Peter

  • Error while using REMAP_TABLE and WHERE clause  together in IMPDP

    I am trying to move some records from a very large table to another small table.
    I am facing trouble while using REMAP_TABLE and WHERE clause together in IMPDP.
    Problem is data filter is not getting applied and all records are getting imported.
    here is how I have simulated this. please advice.
    CREATE TABLE TSHARRHB.TMP1
      A  NUMBER,
      B  NUMBER
    begin
    Insert into TSHARRHB.TMP1
       (A, B)
    Values
       (1, 1);
    Insert into TSHARRHB.TMP1
       (A, B)
    Values
       (2, 2);
    COMMIT;
    end;
    expdp system/password TABLES=tsharrhb.TMP1 DIRECTORY=GRDP_EXP_DIR DUMPFILE=TMP1.dmp REUSE_DUMPFILES=YES LOGFILE=EXP.log PARALLEL=8
    impdp system/password DIRECTORY=GRDP_EXP_DIR DUMPFILE=TMP1.dmp LOGFILE=imp.log PARALLEL=8 QUERY='TSHARRHB.TMP1:"WHERE TMP1.A = 2"'  REMAP_TABLE=TSHARRHB.TMP1:TMP3 CONTENT=DATA_ONLY
    Import: Release 11.2.0.1.0 - Production on Fri Dec 13 05:13:30 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options
    Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/********@GRD6.RBSG DIRECTORY=GRDP_EXP_DIR DUMPFILE=TMP1.dmp LOGFILE=SSD_93_TABLES_FULL_EXP.log PARALLEL=8 QUERY=TSHARRHB.TMP1:"WHERE TMP1.A = 2" REMAP_TABLE=TSHARRHB.TMP1:TMP3 CONTENT=DATA_ONLY
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    . . imported "TSHARRHB"."TMP3"                           5.421 KB       2 rows
    Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 05:13:33
    here I am expecting only 1 record to get imported but both the records are getting imported. please advice.

    The strange thing compared to your output is that I get an error when I have table prefix in the query block:
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/******** DUMPFILE=TMP1.dmp LOGFILE=imp.log PARALLEL=8 QUERY=SYSADM.TMP1:"WHERE TMP1.A = 2" REMAP_TABLE=SYSADM.TMP1:TMP3 CONTENT=DATA_ONLY
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    ORA-31693: Table data object "SYSADM"."TMP3" failed to load/unload and is being skipped due to error:
    ORA-38500: Unsupported operation: Oracle XML DB not present
    Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 1 error(s) at Fri Dec 13 10:39:11 2013 elapsed 0 00:00:03
    And if I remove it, it works:
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/******** DUMPFILE=TMP1.dmp LOGFILE=imp.log PARALLEL=8 QUERY=SYSADM.TMP1:"WHERE A = 2" REMAP_TABLE=SYSADM.TMP1:TMP3 CONTENT=DATA_ONLY
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    . . imported "SYSADM"."TMP3"                             5.406 KB       1 out of 2 rows
    Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at Fri Dec 13 10:36:50 2013 elapsed 0 00:00:01
    Nicolas.
    PS: as you can see, I'm on 11.2.0.4, I do not have 11.2.0.1 that you seem to use.

  • When I send a text message from my iPhone response only comes back to my iPhone .  If I send from iPad, response only comes back to iPad. Whichever I used last is where response comes.  Responses are not coming to both anymore!  Please help?

    When I send a text message from my iPhone response only comes back to my iPhone .  If I send from iPad, response only comes back to iPad. Whichever I used last is where response comes.  Responses are not coming to both anymore!

    On both devices when you go to settings>messages>send and recieve how are poeple contacting you on each device?. e.g. email or mobile number.

  • Using alias in where statement

    simple sql:
    SELECT EMPLOYEE_ID,
    FIRST_NAME,
    LAST_NAME,
    EMAIL,
    PHONE_NUMBER,
    HIRE_DATE,
    JOB_ID,
    SALARY,
    COMMISSION_PCT,
    MANAGER_ID,
    DEPARTMENT_ID
    FROM EMPLOYEES
    WHERE EMPLOYEE_ID > 1000;
    is it somehow possible to use alias in where statement like
    SELECT EMPLOYEE_ID "ID",
    FIRST_NAME,
    LAST_NAME,
    EMAIL,
    PHONE_NUMBER,
    HIRE_DATE,
    JOB_ID,
    SALARY,
    COMMISSION_PCT,
    MANAGER_ID,
    DEPARTMENT_ID
    FROM EMPLOYEES
    WHERE "ID" > 1000;

    Hi,
    is it somehow possible to use alias in where statement likeWhy do you need it?
    To answer your question "Not directly"
    SQL> select empno eno, sal
      2  from emp
      3  where eno = 7900;
    where eno = 7900
    ERROR at line 3:
    ORA-00904: "ENO": invalid identifierColumn Alias are names given to give meaningful names to columns or the arithmetic operations' column.
    Twinkle

  • Using function in where clause

    I have created a function as follows
    create or replace FUNCTION get_codes RETURN varchar2 IS
    scodes varchar2(50) := 'A1,A2';
    BEGIN
    scodes := '('''||REPLACE(scodes,',',''',''')||''')';
    return scodes;
    END;
    this function returns ('A1','A2')
    now i want to use this in where clause, both below statements fetches no rows
    select * from tablea where code in (select get_codes from dual);
    select * from tablea where code in get_codes;
    but the following will fetch rows
    select * from tablea where code in ('A1','A2')
    how to use function in where clause
    Thanks

    Hi,
    The code that works:
    where code in ('A1','A2')is testing whther code is either of two 2-character strings, A1 or A2.
    The ones that don't work, such as:
    where code in get_codes;are comparing code to one 9-character string: 'A1','A2', where characters 1, 4, 6 and 9 are single-quotes. (The function can only return one value.)
    You can use dynamic SQL to embed that 9-character string in part of your query, where it will be interpreted as two 2-character strrings.
    [Oracle Base|http://www.oracle-base.com/articles/misc/DynamicInLists.php] and AskTom have good pages on the subject of dynamic IN-lists.
    Of you can use INSTR or LIKE:
    where INSTR ( get_codes
                , '''' || code || ''''
                ) > 0

  • Can we use EXISTS in where condition

    hi all,
    can we use EXISTS (instead of IN) in where condition of a query which is not part of a subquery ?
    for e.g:
    update gpf_vou_sm set up_amt=0 where src_cd exists ('1101','1201');
    the query works fine with the IN operator in place of EXISTS.
    anybody please help.
    thomas k prakash

    Hi:
    You can use EXISTS in where clause but not in that syntax.
    UPDATE gpf_vou_sm g
       SET up_amt = 0
    WHERE EXISTS (SELECT 1
                     FROM gpf_vou_sm
                    WHERE src_cd IN ('1101', '1201') AND id = g.id);Using IN in your case is better...
    Saad,

  • How can i make a slideshow to use in muse where each slide has its own hyperlink

    I want to make a slideshow to use in muse where each slide has its own hyperlink to another page in the site.
    example here: Genesis Bicycles - Easton PA
    I see how slideshows can be made in muse, but haven't seen where you can assign a hyperlink to each image. 
    I would like it to be html5 compatible.
    Thanks ,
    mark

    Hey Mac, thanks for the feedback. I did some research on composition widget, still not finding how I can use that to make a slide show like the one on www.Genesisbicycles.com home page , could you elaborate on how to or maybe link a tutorial for me.  It would be a big help.
    mark

  • I have microsoft outlook installed on my Mac book pro, I can only use the outlook with the office server where it was setup, I can't use outlook else where, is there any way I can reset the settings in order to be able to use outlook every where?

    I have microsoft outlook installed on my Mac book pro, I can only use the outlook with the office server where it was setup, outlook won't work out of office, is there any way I can reset the settings in order to be able to use outlook every where?

    I can see my folders by clicking the X next to my name on the Inbox Folder.  So I have my folders now, just cannot see them in the left colum or see multiple windows on Outlook.  At this point, I can use the folders, just with limited functionality.  Thanks -Gina

  • When I click a link on a webpage to send the webpage an e-mail, a blank e-mail automatically opens in mail. I use Outlook. Where do I change the default to automatically open to an Outlook email?

    When I click a link on a webpage to send the webpage an e-mail, a blank e-mail automatically opens in Mac mail. I use Outlook. Where do I change the default to automatically open to an Outlook email (if such a thing exists?).
    I have a MacBook Air, running OS X 10.8.5.
    Thanks

    Mail>Preferences>General>Default email Reader:

  • Using Date in where clause

    Hello all,
    I am new to Oracle, currently using 10G + aspvbscript.
    I've been trying to query data using date in where clause but nothing seems to work.
    The column is in date format.
    It gets printed out like this: 5/1/2010 11:21:19 AM
    I tried using this query:
    SELECT * from table where TRUNC(user_date) > to_date('FEB-01-2010:00:00:00','mm-dd-yyyy:HH24:MI:SS') order by user_date asc.
    It does return an output but it returns everything in table and does not take WHERE clause into consideration however, it does sort the date in ascending order.
    I've tried getting rid of TRUNC tried to format date in a different way but no such luck.
    Please point me to the right direction.
    Thanks.

    Welcome to the forums!
    In cases like this it is helpful if you can provide the following information:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    I'll try and take a stab at your request based on the data given. What your query says is that it will return all rows that have a date greater then 2/1/2010 (MM/DD/YYYY). If your query is returning all rows then maybe the possibility exists that all the dates in the table are greater then 2/1/2010. Have you checked all dates to see if this is the case?
    Also, one note about your TO_DATE() function.to_date('FEB-01-2010:00:00:00','mm-dd-yyyy:HH24:MI:SS')The date format does not match the string you are using with respect to month. Your string has 'FEB' but the format is 'MM' which is the numeric representation of the month. Although Oracle was able to convert it to the proper date on my system you should try and maintain consistency between the string and the date format used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using distinct in where clause

    Greedings,
    I am trying to execute some kind of distinct using rowid in where clause but for some reason im not getting the appropriate result. Any guidance is welcome
    SELECT acnt_code,cat,cat_desc,buc FROM so_budgets_cat where
    Trim(buc)='S03'
    and
    NOT exists (SELECT  1
                       from   so_budgets_cat tab2
                       where  (  tab2.cat     =  so_budgets_cat.cat )
                       and    tab2.ROWID  > so_budgets_cat.ROWID
    ORDER BY cat,so_budgets_cat.rowidThanks in advance

    Additionally to the fact that we don't have an idea on the expected output, I can't understand the comparison of ROWIDs in your query. These are the logical addresses where the data reside in the disks, comparing them doesn't make sense to me; Oracle DB defines where to store, based on space availability in the disk allocation to the database occupation - and NOT in a logical sequence.
    Maybe the existing row is stored in an address that is not a higher number than other, and so it is not being retrieved in your sub-query - hence your test for distinction is failing.

  • I'm trying to use Dictation.  Where does the text go, and how can I retrieve it?  Thank you.

    I'm trying to use Dictation.  Where does the text go, and how can I retrieve it?  Thank you.

    You dictate after you open a blank page in any text editor. The text goes on the page.
    You can use Text Edit for example (in your applications folder).
    With the blank page open, go to the Edit menu and select Start Dictation. When you are finished, you save the file as you would any other document. You can retrieve it, edit it or anything else you want, because it is a file like any other you create with that text editor.

Maybe you are looking for

  • How do I play music bought on one computer on another authorized PC

    I am unable to figure out how to play some songs i bought on iTunes with my wife's computer on another computer that i have authorized.

  • Unable to get more than 1080p on an external display

    Hi, I have an X1 Carbon (not sure what model version - if that's important, someone please tell me how to get it and I'll post). Its display is 2560x1440 and has both HDMI and miniDP to drive an external monitor. I have a Dell U2713M as an external m

  • Mapping links wont work in Opera and IE but do work in Safari.

    Hi, What can I do to fix the code below? The links wont work in IE and Opera, but OK in safari. The error message is: in tag: map the following required attributes are missing: id[XHTML 1.0 Transitional] Code <div id="mainContentLeft1b"> <div id="mai

  • How to export two diferents DB to one unique DB

    Hi people, I doubt whether it is possible to export two different databases, each of them a central instance in different machines, one machine where the two instances together and merge these data bases on a single BD.Data from both database consoli

  • ITunes not responding on start up

    HELP! I am completely perplexed, my itunes was working fine yesterday and now when I start it up, within seconds of it coming up on the screen it has the dreaded "not responding" hiccup! The error messages is as: Description: A problem caused this pr