IN clause of oracle

Hi Everyone,
I have a column A defined as VARCHAR2 in table1 which will contain numeric data separated by Comma(,). I have to pull data from another table by using the values present in column A of Table A.
Table 1:
A ID
1,2,3 123
Table B
A_A Name
1 test1
2 test2
query:
select * from Table_B where A_A in ( select A from Table_1 where ID=123).
Issue: Sub query returning Character value. So the query is returning NULL.
Can somebody help me on this.
Thanks in advance !!!
Edited by: 871132 on Aug 18, 2011 9:26 AM

You'd need to parse the string stored in A into a collection of numbers. Something like Tom Kyte's str2tbl function. Something like
SQL> create or replace type myTableType as table of number;
  2  /
Type created.
SQL> ed
Wrote file afiedt.buf
  1  create or replace function str2tbl( p_str in varchar2 ) return myTableType
  2    as
  3        l_str   long default p_str || ',';
  4        l_n        number;
  5        l_data    myTableType := myTabletype();
  6    begin
  7        loop
  8            l_n := instr( l_str, ',' );
  9            exit when (nvl(l_n,0) = 0);
10            l_data.extend;
11            l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
12            l_str := substr( l_str, l_n+1 );
13        end loop;
14        return l_data;
15*   end;
SQL> /
Function created.
SQL> ed
Wrote file afiedt.buf
  1  with t1 as (
  2    select '1,2,3' a, 123 id from dual
  3  )
  4  ,t2 as (
  5    select 1 a_a, 'test1' name from dual
  6    union all
  7    select 2, 'test2' from dual
  8  )
  9  select *
10    from t2
11   where a_a in (select *
12                   from table(select str2tbl(a)
13                                from t1
14*                              where id=123))
SQL> /
       A_A NAME
         1 test1
         2 test2Justin

Similar Messages

  • Unable to use the with clause in oracle 9.0.2

    Hi,
    I need to use oracle SQL with clause in oracle 9.0.2 database. Its a 9i feature but i am unable to use it.
    It is giving internal error, when i try to execute it.
    Even for simple query:
    WITH acct_summary as ( select TOT_COLL_AMT from tdc_acct)
    select TOT_COLL_AMT from acct_summary WHERE TOT_COLL_AMT>100;
    Error message while using 8.0.5 sql plus client:
    SP2-0642: SQL*Plus internal error state 2091, context 0:0:0
    Unsafe to proceed
    Please help to find out why i am not able to use the sql with clause in oracle 9.0.2 database.
    Thanks and regards,
    Raajkathir

    Hi Jens Petersen,
    Yes, You are correct. Thank you very much.
    Regards,
    Raja

  • Bug in WITH clause (subquery factoring clause) in Oracle 11?

    I'm using WITH to perform a set comparison in order to qualify a given query as correct or incorrect regarding an existing solution. However, the query does not give the expected result - an empty set - when comparing the solution to itself in Oracle 11 whereas it does in Oracle 10. A minimal example os posted below as script. There are also some observations about changes to the tables or the query that make Oracle 11 returning correct results but in my opinion these changes must not change the semantics of the queries.
    Is this a bug or am I getting something wrong? The Oracle versions are mentioned in the script.
    -- Bug in WITH clause (subquery factoring clause)
    -- in Oracle Database 11g Enterprise Edition 11.2.0.1.0?
    DROP TABLE B PURGE;
    DROP TABLE K PURGE;
    DROP TABLE S PURGE;
    CREATE TABLE S (
         m     number NOT NULL,
         x     varchar2(30) NOT NULL
    CREATE TABLE K (
         k char(2) NOT NULL,
         x varchar2(50) NOT NULL
    CREATE TABLE B (
         m     number NOT NULL ,
         k char(2) NOT NULL ,
         n     number
    INSERT INTO S VALUES(1, 'h');
    INSERT INTO S VALUES(2, 'l');
    INSERT INTO S VALUES(3, 'm');
    INSERT INTO K VALUES('k1', 'd');
    INSERT INTO K VALUES('k2', 'i');
    INSERT INTO K VALUES('k3', 'm');
    INSERT INTO K VALUES('k4', 't');
    INSERT INTO K VALUES('k5', 't');
    INSERT INTO K VALUES('k6', 's');
    INSERT INTO B VALUES(1, 'k1', 40);
    INSERT INTO B VALUES(1, 'k2', 30);
    INSERT INTO B VALUES(1, 'k4', 50);
    INSERT INTO B VALUES(3, 'k1', 10);
    INSERT INTO B VALUES(3, 'k2', 20);
    INSERT INTO B VALUES(3, 'k1', 30);
    INSERT INTO B VALUES(3, 'k6', 90);
    COMMIT;
    ALTER TABLE S ADD CONSTRAINT S_pk PRIMARY KEY (m);
    ALTER TABLE K ADD CONSTRAINT K_pk PRIMARY KEY (k);
    ALTER TABLE B ADD CONSTRAINT B_S_fk
    FOREIGN KEY (m) REFERENCES S(m) ON DELETE CASCADE;
    CREATE OR REPLACE VIEW v AS
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC;
    -- Query 1: Result should be 0
    WITH q AS
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    SELECT COUNT(*)
    FROM
    SELECT * FROM q
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM q
    -- COUNT(*)
    -- 6
    -- 1 rows selected
    -- Query 2: Result set should be empty (Query 1 without counting)
    WITH q AS
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    SELECT *
    FROM
    SELECT * FROM q
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM q
    -- M N
    -- null 10
    -- null 30
    -- null 40
    -- 1 40
    -- 3 10
    -- 3 30
    -- 6 rows selected
    -- Observations:
    -- Incorrect results in Oracle Database 11g Enterprise Edition 11.2.0.1.0:
    -- Query 1 returns 6, Query 2 returns six rows.
    -- Correct in Oracle Database 10g Enterprise Edition 10.2.0.1.0.
    -- Correct without the foreign key.
    -- Correct if attribute x is renamed in S or K.
    -- Correct if attribute x is left out in S.
    -- Correct without the ORDER BY clause in the definition of q.
    -- Only two results if the primary key on K is left out.
    -- Correct without any change if not using WITH but subqueries (see below).
    -- Fixed queries
    -- Query 1b: Result should be 0
    SELECT COUNT(*)
    FROM
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    -- COUNT(*)
    -- 0
    -- 1 rows selected
    -- Query 2b: Result set shoud be empty (Query 1b without counting)
    SELECT *
    FROM
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    MINUS
    SELECT * FROM v
    UNION ALL
    SELECT * FROM v
    MINUS
    SELECT * FROM
    SELECT S.m, B.n
    FROM S JOIN B ON S.m=B.m JOIN K ON B.k=K.k
    WHERE K.x='d'
    ORDER BY B.n DESC
    -- M N
    -- 0 rows selected

    You're all gonna love this one.....
    The WITH clause works. But not easily.
    Go ahead, build the query, (as noted in a recent thread, I, too, always use views), set the grants and make sure DISCOVERER and EULOWNER have SELECT privs.
    1. Log into Disco Admin as EULOWNER. Trust me.
    2. Add the view as a folder to the business area.
    3. Log into Disco Desktop as EULOWNER. Don't laugh. It gets better.
    4. Build the workbook and the worksheet (or just the worksheet if apropos)
    5. Set the appropriate "sharing" roles and such
    6. Save the workbook to the database.
    7. Save the workbook to your computer.
    8. Log out of Desktop.
    9. Log back into Desktop as whatever, whoever you usually are to work.
    10. elect "open existing workbook"
    11. Select icon for "open from my computer". See? I told you it would get better!
    12. Open the save .dis file from your computer.
    13. Save it to the database.
    14. Open a web browser and from there, you're on your own.
    Fortran in VMS. Much easier and faster. I'm convinced the proliferation of the web is a detriment to the world at large...On the other hand, I'm also waiting for the Dodgers to return to Brooklyn.

  • What is equivalent to 'with clause' in oracle

    what is equivalent to 'with clause' in oracle
    thanks

    My reqirement is :
    I have a table named egroup. I have to find the name of the egroup different from "other" that can be found in the most countries in Africa
    create table EGROUP(
         c_id     char(2), -- country id
         egroup     varchar2(40), -- name of the ethnic group
         percent number(4,2), -- percentage of population
         constraint egroup_fk foreign key(c_id) references COUNTRY,
         constraint egroup_pk primary key(c_id,egroup)
    insert into egroup values('AF','Pashtun', 42 );
    insert into egroup values('AF','Tajik',27 );
    insert into egroup values('AF','Hazara',9 );
    insert into egroup values('AF','Uzbek',9 );
    insert into egroup values('AF','Aimak',4 );
    insert into egroup values('AF','Turkmen',3 );
    insert into egroup values('AF','Baloch',2 );
    insert into egroup values('AF','other',4 );
    insert into egroup values('AL','Albanian', 95 );
    insert into egroup values('AL','Greek',3 );
    insert into egroup values('AL','other',2 );
    insert into egroup values('AG','Arab-Berber', 99 );
    insert into egroup values('AG','European',1 );
    insert into egroup values('AQ','Samoan (Polynesian)', 89 );
    insert into egroup values('AQ','Caucasian',2 );

  • Can't use ";" in sql clause with Oracle 8.X

    Can't use ";" in sql clause with Oracle 8.X
    I can't use ";" at the ending of sql clause in VB program. First this program can use with Oracle 7.3.4 database. But now i need to upgrade DB to Oracle 8.1.7 ,program can't operate. It show error Runtime 40002
    and 37000:ODBC driver for oracle/invalid charactor
    Thankyou

    I've seen a lot of discussion about semicolons in SQL
    sent from 3rd party applications. A web search should
    bring up the discussions.
    Also you might get more response if you ask this question
    somewhere else. This is not a VB forum, so you may
    not reach relevant people.
    -- CJ

  • How to avoid repeat where clause in oracle sql

    Hi,
    Please find my query below, I need a help to avoid duplication of **where** clause in my query.
    In my below query, **JOIN** condition is same for both the queries and **WHERE** condition also same except this clause "and code.code_name="transaction_1"
    In **IF ** condition only credit and debit is swapped on both queries, due to this **Credit and Debit** and this where clause "and code.code_name="transaction_1" I am duplicating the query. Can you please give some solution to avoid this duplication. I am using oracle 11g
    select DAY as business_date,sum(amount) as AMOUNT, type_amnt as amount_type,test_code as code_seg
    from
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'credit'
    ELSE 'debit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_1"
    UNION ALL
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'debit'
    ELSE 'credit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_2"
    group by DAY, test_code,type_amnt
    Thanks

    user10624672 wrote:
    Hi,
    Please find my query below, I need a help to avoid duplication of **where** clause in my query.
    In my below query, **JOIN** condition is same for both the queries and **WHERE** condition also same except this clause "and code.code_name="transaction_1"
    In **IF ** condition only credit and debit is swapped on both queries, due to this **Credit and Debit** and this where clause "and code.code_name="transaction_1" I am duplicating the query. Can you please give some solution to avoid this duplication. I am using oracle 11g
    select DAY as business_date,sum(amount) as AMOUNT, type_amnt as amount_type,test_code as code_seg
    from
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'credit'
    ELSE 'debit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_1"
    UNION ALL
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'debit'
    ELSE 'credit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_2"
    group by DAY, test_code,type_amnt
    ThanksA very brief glance and it looks to me like the only difference between the 2 queries are
    and code.code_name="transaction_1"In the first portion and
    and code.code_name="transaction_2"So if that's all that is difference, you'd just want to use a single query (no union's) with
    and code.code_name in ('transaction_1', 'transaction_2')Cheers,

  • Clarification on using function in where clause of oracle sql query

    I have an issue in regarding function using where clause of sql query..
    We are facing performance issue while executing query, so in what ways to improve the performance of the query which i have posted below.
    select col ,case when my_function(parameter)
    from tab1 a ,tab2 b,tabl3 c
    where a.column1=b.column2
    and b.column3 =c.column6
    and my_function(parameter)>0
    Regards
    Dinesh
    Edited by: wild fire on May 18, 2012 4:15 PM

    Dinesh,
    remind that when you use a function in the where clause it normally will get started for each record in the table.
    So your answer is two-fold:
    1. make the function only start when needed by adding a function based index on the table (this will make inserts and updates slower)
    2. make the function faster by adding the DETERMINISTIC clause if possible. this will make Oracle "cache" the result of the function.
    Regards,
    Richard
    blog: http://blog.warp11.nl
    twitter: @rhjmartens
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Order By clause in Oracle

    Hello,
    Sorry I am posting it for the second time
    In Oracle , the order by clause does not return the expected query result, if any of the field value in the order by clause has an empty string.
    Oracle treats the empty string as null value and ORDER BY gives a result with the empty string field values listed at last.
    For example :
    test is a sample table containing "name" field.
    Query: "select name from test order by name"
    In SQL Server/Access
    Result (1)
    NAME
    (blank)
    (blank)
    User1
    User2
    User3
    In Oracle
    Result (2)
    NAME
    User1
    User2
    User3
    (blank)
    (blank)
    I know some of the Work arounds for this as listed below :
    1) To use NVL in Order By Clause.
    i.e., the modified query
    "select name from test order by nvl(name,0)"
    gives the result same as Result (1).
    2) To have single blank space in the field value if it is empty.
    I dont want to use either of these two options b'se it would lead to a mass change in my existing code.
    Is there any way i can do a
    collation order settings in the Oracle databases to get the results as in MS SQL/Access.
    Or Is there any other way that i can set the
    option once for this and need not worry abt it afterwards?
    Can Any help me out in Solving this?
    Thanks
    Devi
    null

    For fun and out of curiosity, I tried :
    SQL> select /*+ leading(t) use_nl(e t) */
      2         e.deptno
      3       , e.empno
      4  from scott.emp e
      5     , table(sys.odcinumberlist(30,10,20)) t
      6  where e.deptno = t.column_value
      7  ;
    DEPTNO EMPNO
        30  7499
        30  7521
        30  7654
        30  7698
        30  7844
        30  7900
        10  7782
        10  7839
        10  7934
        20  7369
        20  7566
        20  7902
    12 rows selected
    It "seems" to work but of course we can't expect a consistent behaviour, or can we? ;)

  • Group By clause in oracle 10g help needed

    Hi
    we have a requirement that get the AR aging details at customer level.I have written the following query to fetch the correct rows at invoice level.But now i need to sum the amounts and i should show at invoice level and customer level.Could you please help me how can i group by customer level.
    Here is the query i used
    select ps.org_id
    , sob.SET_OF_BOOKS_ID
    , sob.CHART_OF_ACCOUNTS_ID
    , gcc.SEGMENT1 Company
    , gcc.SEGMENT2 Location
    , gcc.SEGMENT3 Department
    , gcc.SEGMENT4 Account
    , gcc.SEGMENT5 Future_1
    , gcc.SEGMENT6 Future_2
    , gcc.SEGMENT7 Future_3
    , gcc.CONCATENATED_SEGMENTS gl_cc_concat_kff
    , ps.trx_number
    , ps.trx_date
    , ps.due_date
    , ps.invoice_currency_code
    , sob.currency_code SOB_Currency_Code
    , ps.class
    , ps.amount_due_original
    , ps.amount_due_original * nvl(ps.exchange_rate, 1) acctd_amount_due_original
    , ps.amount_due_remaining
    , ps.acctd_amount_due_remaining
    , ps.status
    , ps.cust_trx_type_id
    , ps.customer_site_use_id
    , ps.customer_trx_id
    , ps.cash_receipt_id
    , ps.gl_date
    , rctlda.CODE_COMBINATION_ID
    , ps.customer_id
    , nvl(rcta.ATTRIBUTE5,ps.CUSTOMER_ID) End_Customer_Id
    , rc.customer_number
    , rc2.CUSTOMER_NUMBER Brand_Cust_no
    , round((sysdate-ps.due_date))
    from gl_sets_of_books sob
    , hr_operating_units ou
    , ar_payment_schedules_all ps
    , ra_customers rc
    , ra_cust_trx_line_gl_dist_all rctlda
    , gl_code_combinations_kfv gcc
    , ra_customer_trx_all rcta
    , ra_customers rc2
    where sob.set_of_books_id = ou.set_of_books_id
    and ou.organization_id = ps.org_id
    and ps.status = 'OP'
    and ps.org_id is not null
    and ps.CUSTOMER_ID=rc.CUSTOMER_ID
    and ps.CUSTOMER_TRX_ID=rctlda.CUSTOMER_TRX_ID
    and rctlda.ACCOUNT_CLASS='REC'
    and rctlda.latest_rec_flag = 'Y'
    and rctlda.CODE_COMBINATION_ID=gcc.CODE_COMBINATION_ID
    and ps.CUSTOMER_TRX_ID=rcta.CUSTOMER_TRX_ID
    and gcc.CODE_COMBINATION_ID=39446
    -and ps.trx_number = '1-15O0A8O'
    --and    rc.CUSTOMER_NUMBER='1-10PA5KX'
    and nvl(rcta.ATTRIBUTE5,ps.CUSTOMER_ID)=rc2.CUSTOMER_ID
    Could any one help me how to get the same columns with sum( ps.amount_due_original ) for each customer.I tried to use group by clause but it is again giving invoice level.
    But my req is for each customer invoice amount should be summed and it should give the total
    Thanks
    Y

    if you need to have the sum of invoice related to each customer then may also need to check for the
    CUBE
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#sthref9448
    and example here
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#i2066443
    and ROLLUP
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#sthref9445
    I couldn't follow with all your SQL statement, or I could rewrite it for you again
    Thanks
    Edited by: user9532576 on Jul 21, 2009 9:24 AM

  • Curious about this From clause in Oracle XE

    SQL view of query Builder gives the following:
    select     "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
         "EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
         "EMPLOYEES"."LAST_NAME" as "LAST_NAME"
    from     "EMPLOYEES" "EMPLOYEES"
    Why does the from clause showing "EMPLOYEES" "EMPLOYEES"?
    In the SQL Commands of the SQL the folowing query
    select     "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
         "EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
         "EMPLOYEES"."LAST_NAME" as "LAST_NAME"
    from     "EMPLOYEES
    gives the same result and so does
    select     "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
         "EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
         "EMPLOYEES"."LAST_NAME" as "LAST_NAME"
    from     "EMPLOYEES" "EMPLOYEES"
    What is the significence of the second "Employees" in the FROM clause.

    Other interesting feature is the double quotes
    although the one above works as well.
    Why is this?Habit.
    Some developers come from environments that support mixed case identifiers (table and column names). These developers sometimes go out of their way to force Oracle to use mixed case identifiers, and that requires double quotes.
    So Oracle seems to have gotten into the habit of surrounding all identifiers (coming from generated code) with double quotes to keep these developers (who usually have other porting issues anyway) from having to trace those identifier issues.

  • Using OR operator in the WHERE clause in Oracle BI

    Hi, i am using Oracle BI EE 10.1.3.3.3.
    I construct the simple report in BI Answers on the Accounts presentation layer, and use the following filter clause:
    "WHERE (AccountNum BETWEEN '441' and '473') OR (БалСчет1Порядка BETWEEN '501' and '519')"
    Then i look in the cursor cache and find the real query which is going to database, and it's "where" clause now is:
    "where ( (T45172.BA >= '441' or T45172.BA >= '501') and
    (T45172.BA >= '441' or T45172.BA <= '519') and
    (T45172.BA >= '501' or T45172.BA <= '473') and
    (T45172.BA <= '473' or T45172.BA <= '519') ) "
    Why BI create so many expressions instead of the source 2 expressions?
    How can i force BI to use the source expressions?

    I have the same settings too.
    I post the following query in the Administration web interface, and set the maximum logging level (7):
    SELECT "Plan Account"."Balance Account" saw_0
    FROM "Plan Account"
    WHERE ("Plan Account"."Balance Account" between '441' and '473')
    OR ("Plan Account"."Balance Account" between '501' and '519')
    ORDER BY saw_0
    And got the following BI execution plan:
    RqList <<5619441>> [for database 0:0,0] distinct D1.c1 as c1 [for database 3023:44913,46]
    Child Nodes (RqJoinSpec): <<5619450>> [for database 3023:44913:DB,46]
    RqList <<5619277>> [for database 3023:44913:DB,46]
    D1.c1 as c1 GB [for database 3023:44913,46]
    Child Nodes (RqJoinSpec): <<5619360>> [for database 3023:44913:DB,46]
    RqList <<5619284>> [for database 3023:44913:DB,46]
    Dim - Plan Account.BA as c1 GB [for database 3023:44913,46]
    Child Nodes (RqJoinSpec): <<5619350>> [for database 3023:44913:DB,46]
    TB_PLAN_ACCOUNT T45172
    DetailFilter: (not Dim - Plan Account.BA < '441' or not Dim - Plan Account.BA < '501') and (not Dim - Plan Account.BA < '441' or not '519' < Dim - Plan Account.BA) and (not Dim - Plan Account.BA < '501' or not '473' < Dim - Plan Account.BA) and (not '473' < Dim - Plan Account.BA or not '519' < Dim - Plan Account.BA) [for database 0:0]
    ) as D1
    ) as D1
    OrderBy: c1 asc [for database 0:0,0]
    and following query sent to database:
    -------------------- Sending query to database named DB (id: <<5619277>>):
    select distinct D1.c1 as c1
    from
    (select distinct T45172.BA as c1
    from
    TB_PLAN_ACCOUNT T45172 /* Dim - Plan Account */
    where ( (T45172.BA >= '441' or T45172.BA >= '501') and (T45172.BA >= '441' or T45172.BA <= '519') and (T45172.BA >= '501' or T45172.BA <= '473') and (T45172.BA <= '473' or T45172.BA <= '519') )
    ) D1
    So, i got the same bad where clause...
    What can you advice?

  • For Update Query with Wait Clause from ORACLE Forms

    Hi
    We are using Oracle Forms 10g running with 10g database 10.2.0.1.0. We happend to see a query which is getting generated in AWR report like Select rowid, all_columns from TableName for Update of C1 Nowait. But no such query is really written in forms and we are aware that, Any query prefixed with rowid is definitely executing from Forms. But how the ForUpdate and Nowait clause is appended to the query.
    We have checked the following properties in the database Block
    *1) Locking Mode is set to Automatic*
    *2) Update Changed Columns only is set to YES*
    *3) Query all records is set to No (Though this particular property may not be relevant to the issue)*
    What is the property or setting which might trigger such a query from ORACLE Forms with ForUpdate and Nowait clause.
    Any ideas/suggestions on why such behaviour. Please have a healthy discussion on this. Thanks in advance.

    Why have you started another thread on the same thing?
    FOR UPDATE cursor is causing Blocking/ Dead Locking issues
    Just use one thread to avoid confusion.
    The fact that nobody has answered on the other thread for a couple of days could be to do with it being the weekend and most people are not at work.
    Either be patient or, if it's more "urgent" than that, raise a SR/Tar with Oracle metalink.

  • Comma separated data into IN clause in oracle report query

    i have a field on form as order number it takes more than one value as 1,2,3
    now i want to fetch data in report query for where order no in 1,2 and 3...
    but field takes value as 1,2,3...
    how can i separte the comma from value and how can i pass value in IN clause...or
    how can i get all records with order no 1,2,3...
    please suggest how can i achieve the same....

    Hi Maddy....
    Try this :
    declare
    var varchar2(10);
    v1 varchar2(5);
    v2 varchar2(5);
    v3 varchar2(5);
    vRegExp varchar2(5);
    begin
    var:='1,2,3'; 
    vRegExp:='[^,]+';
    FOR i IN 1..length (regexp_replace (var,vRegExp))  + 1
    LOOP
                v1 := REGEXP_SUBSTR (var,vRegExp);
                v2 := REGEXP_INSTR(var,vRegExp,1,2);
                var := substr(var,v2);
               // here fetch you data from report by passing v1 as a parameter;
          EXIT WHEN v2 = 0;
    END LOOP;
    end;
    Hope this will resolve your question..
    Thanks

  • With clause in oracle

    how is it possible
    suppose i have a query like select name ,count(),date
    where <condition>
    group by name,date
    it return summary information like
    a,2,11-nov-2007
    b,4,11-nov-2007
    that means it store summary info
    i want to store detail info into other table
    select name ,count(),date
    where <same condition of above>
    like a,xyz,11-nov-2007
    a,abc,11-nov-2007
    b,sts,11-nov-2007
    b,pqs,11-nov-2007
    b,stt,11-nov-2007
    b,bts,11-nov-2007
    so can i use WITH clause AS here.<basically i want to store summay info to a table and detail info to other table>
    please help me .

    After reading your post four times I still don't know what are you talking about.
    select name
    ,count(),date
    where <condition>
    group by name,dateWhere is from clause?
    select name ,count(),date
    where <same condition of above>
    like a,xyz,11-nov-2007
    a,abc,11-nov-2007
    b,sts,11-nov-2007
    b,pqs,11-nov-2007
    b,stt,11-nov-2007
    b,bts,11-nov-2007Why count() returns something like abc, sts, and again - where is from clause?

  • Using in clause in oracle

    Hi,
    I am facing the following issue when trying to retrieve the data from a view.If i specify literals inside the in clause (example id's inside in clause) it's working fine,but when i try to use the subquery inside in clause to retrieve the id's from the base table it's taking longer time and no results are observed.I am trying to give the subquery inside in clause due to the in clause cannot handle literals(id's) more than 1000.
    Any suggestions on this will help me a lot for this.

    user13469868 wrote:
    ... due to the in clause cannot handle literals(id's) more than 1000.
    Any suggestions on this will help me a lot for this.I often do a simple approach. If I need an IN list with more then 1000 values, then simply use two more more in lists and the OR operator.
    Example: instead of
    select * from emp
    where id in
    ( 1,
      2,
      3,
      1000,  /* problem point */
      1001,
      2000,  /* problem point */
      2001,
    )I write the statement like this:
    select * from emp
    where (id in  /* see the addition starting parenthesis! */
    ( 1,
      2,
      3,
       999)
    OR id in  /* start of the second list */
      (1000,
      1001,
       1999)
    OR id in   /* start of the next list */
    (2000,
      2001,
    ) /* remember to add the closing parenthesis */Edited by: Sven W. on Jun 28, 2011 4:39 PM - formatting

  • Using MIN clause in Oracle to get a ticket number with an oldes date

    i am stuck with the following simple syntax..
    i need to pull the oldest billnumber ..ultimately i need to see the ticket number with the oldest date .
    here is my select statement using an openquery from SQL server to oracle..
    (SELECT * FROM OPENQUERY(B_COUNT,
    'SELECT
    TICKETID,
    MIN(CREATE_DATE)
    FROM TABLE
    WHERE
    CREATE_DATE >= ''1262304001'' AND CREATE_DATE < (trunc(SYSDATE) - to_date(''01-JAN-1970'',''DD-MON-YYYY'')) * (86400) AND
    STATUS = ''0''
    any help will be appreciated
    thanks

    938115 wrote:
    I also got this text file after the command was executed along with the GIS.bad file
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Jun 1 09:56:52 2012
    Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
    Control File: bill.ctl
    Data File: GIS.csv
    Bad File: GIS.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    I have thousands of records in this file and only 64 of them updated.How many record were in the table before and after? I doubt the difference is 64, unless you have exactly 64 rows but you said thousands. I believe you are probably misinterpreting the log file. can you share the full log file? As a test, create a empty table, use the same script and load same data file in this empty table. Once loading is complete, check if it has 64 rows or more. I believe what log file is saying, it is 'commiting after every 64 rows', not 'stopping after loading 64 rows'.
    So, unless you show us the log file there is no way to be certain, feel free to mask confidential info, at-least top 15 and bottom 15 lines ?

Maybe you are looking for

  • Auditing BPM Processes

    Hello all, Is there a way to audit BPM processes in SAP CE?  Lets say I have an approval process for vendors built in BPM.  There are plenty of reasons why I may need to go back and show when and who approved a particular vendor.  I think there are s

  • Throws Exception

    Dear Expert, May I know how to throw Exception from a thread back to calling program ? As I always get the following message when compiling the code cannot override run() in java.lang.Thread; overridden method does not throw java.lang.Exception publi

  • Assigning ports on the ps3

    I've got a WRT54G wireless routeur that was working pretty well with my PS3, I had done something with a tutorial to make it work find. Now that I changed the WEP key of the routeur I need to reconfigure the ps3 and I can't remember how I did. I reme

  • Signal processing of AFM (DC) signals using labview

    I am trying to conduct FFT analysis on DC signals from the thermal fluctuations of a cantilever (liquid operation) from a Nanoscope III multimode AFM. Our DAQ board is PC6110E. I am using one of the available signal processing examples to process the

  • Please help! How to populate a JList?

    1) I have a vector which initialy is null. 2) When I press a button, a method is called, which populates the vector. 3) A JList then displays the contents of the vector. Can anyone tell me the best way of implementing this? So far I have been unsucce