Help on 'IN' part of SQL

I need to run a query, like
select * from <table> where <column1> in (<some 76000 values>);
I am not sure, wether there is a limitaion on the number of values we can place in the right of the 'IN' clause (I have some 76000 values to compare). Can somebody help on this!

Hi,
You have another solution.....
It is divided into two portions....
1) write a function tht will take as input, all of your values in the text file.
I hope the values are seperated by comma or some seperator and might be enclosed by some character. not an issue even if it is not.
2) Call this function in ur sql statement.
The function looks like this...
FUNCTION get_msv_string(
pc_string IN VARCHAR2,
pc_seperator IN VARCHAR2,
pc_enclosedby IN VARCHAR2)
RETURN ms_string DETERMINISTIC PIPELINED IS
lc_string VARCHAR2(1000);
ln_n1 NUMBER := 0;
ln_n2 NUMBER := 0;
ln_data bpsicc_ms_string := bpsicc_ms_string();
ln_n NUMBER := 0;
ln_cnt NUMBER := 0;
ln_loop NUMBER := 0;
ex_errors EXCEPTION;
BEGIN
IF pc_string IS NULL THEN
NULL;
ELSIF pc_seperator IS NULL THEN
ln_data.EXTEND;
ln_data(ln_data.COUNT) := pc_string;
ELSE
IF pc_string = pc_enclosedby THEN
RAISE ex_errors;
ELSIF pc_string = pc_seperator THEN
RAISE ex_errors;
END IF;
lc_string := pc_string || pc_seperator;
ln_cnt := LENGTH(lc_string);
LOOP
ln_loop := ln_loop + 1;
EXIT WHEN lc_string IS NULL;
IF pc_enclosedby IS NOT NULL THEN
ln_n1 := INSTR(lc_string, pc_enclosedby);
ln_n2 := INSTR(lc_string,
pc_enclosedby,
ln_n1 + 1,
1);
IF NVL(ln_n2, 0) = 0 THEN
ln_n2 := LENGTH(lc_string) - 1;
END IF;
ln_data.EXTEND;
ln_data(ln_data.COUNT) :=
TRIM(pc_enclosedby FROM SUBSTR(lc_string,
ln_n1,
ln_n2));
lc_string := SUBSTR(lc_string, ln_n2 + 2);
ELSE
ln_n := INSTR(lc_string, pc_seperator);
IF ln_n > 0 THEN
ln_data.EXTEND;
ln_data(ln_data.COUNT) := SUBSTR(lc_string,
1,
ln_n - 1);
lc_string := SUBSTR(lc_string, ln_n + 1);
END IF;
END IF;
IF ln_loop > ln_cnt THEN
RAISE ex_errors;
END IF;
PIPE ROW(ln_data(ln_data.COUNT));
END LOOP;
END IF;
RETURN;
EXCEPTION
WHEN ex_errors THEN
RETURN;
END get_msv_string;
And the query looks like this....
WHERE source_type_code IN(
SELECT COLUMN_VALUE
exclude_source
FROM TABLE
(CAST
(get_msv_string
(:p_exclude_source_id,
NULL) AS ms_string))))
Here, the :p_exclude_source_id will have your 76000 values from the text file.
But, you should be able to give all the values to this function as a parameter.
I only gave the where clause of the query i used.
the function signature is self explanatory when u c the query where the function is called.
Here there is no need to create a global temporary table.
ATB
KK

Similar Messages

  • On my MacBook with Lion Safari does start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library did not help. Where can I find and remove all components (LastSession ...)?

    How can I reset Safari with all components? On my MacBook with Lion, Safari does not start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library does not help. Where can I find and remove all components as LastSession and TopSites?

    The only way to reinstall Safari on a Mac running v10.7 Lion is to restore OS X using OS X Recovery
    Instead of restoring OS X in order to reinstall Safari, try troubleshooting extensions.
    From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
    If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.
    If it's not an extensions issue, try troubleshooting third party plug-ins.
    Back to Safari > Preferences. This time select the Security tab. Deselect:  Allow plug-ins. Quit and relaunch Safari to test.
    If that made a difference, instructions for troubleshooting plugins here.
    If it's not an extension or plug-in issue, delete the cache.
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.

  • Help required in writing an sql to fetch the the difference of the data.

    Hi Gurus,
    Could some one help me in writing an sql to pull data the difference between two same structured tables from two different database and to store that data in an temperory table.
    many many thanks in advance

    Lets say you have two db SOURCE and DEST
    SOURCE is the DB that you have Logged in into. Now you do the following.
    1. Createa DBLink to DEST database.
    2. Check if the DBLink works properly.
    3. Then execute the following sql.
    select <column_list> from <table_name>
    minus
    select <column_list> from <table_name>@<dblink>
    union all
    select <column_list> from <table_name>@<dblink>
    minus
    select <column_list> from <table_name>

  • How to display a help page as part of a extension

    Jdev team, Any extension developer,
    I am in the process of building an extension for JDev 10.1.3.
    I have seen showdialog extension sdk samples project, that has some code for displaying help but it doesn't work if I deploy.
    Can anyone let me know the details how I can show a help page (a single html page with some images in the same directory) when user clicks "Help" button (as part of OnePageWizardDialog)
    The complete set of details are highly appreciated.
    Oracle's Java Help I believe is not required for simple non-index based html page display.

    Hi Jimmy:
    You can try something like this:
    CREATE OR REPLACE PROCEDURE UPDATE_OLD_VALUES IS
    CURSOR GET_OLD_DATA is SELECT ID, COS, PROD_A, PROD_B
    FROM TEST
    WHERE PROD_A IS NULL;
    BEGIN
    FOR x IN GET_OLD_DATA LOOP
    INSERT INTO TEST (ID, COS, PROD_A, PROD_B)
    VALUES (X.ID+1, X.COS, new_prod_a_value, X.PROD_B);
    COMMIT;
    END LOOP;
    EXCEPTION
    WHEN TOO_MANY_ROWS OR NO_DATA_FOUND THEN
    NULL;
    END;
    Hope this works.
    Abdel

  • My iPod has not been working for a month now and i was hoping that you could help me.The part where you charge and sync the iPod is not connecting.There is defiantly not the lead as we use it for the iPhone and that works please could you help!

    my iPod has not been working for a month now and i was hoping that you could help me.The part where you charge and sync the iPod is not connecting.There is defiantly not the lead as we use it for the iPhone and that works please could you help!
    yours sincerly
    jackfromsurrey

    What I am saying is ..........
    The iPhone HAS to be active making calls on the UK carrier network for the carrier to identify as "theirs" and therefore eligible for the Carrier to unlock
    The way to achieve this is to use a PAYG sim making and receiving calls to establish a customer relationship  with the Carrier and then follow the Carrier's process to unlock
    With a PAYG it usually means adding a specified (by the carrier ) amount  usually £15 /£20 depending on the carrier
    This is how O2 function and according to Gemma  this is how Vodafone work

  • Please help me in writing the SQL

    Hi,
    I am new to oracle.. Can you please help me in writing a SQL
    I have a table which has the following columns
    Start_date m1 ---- Start month of each quarter (Jan,Apr,Jul,oct)
    end_date m3---- End month of each quarter
    m1_start_date,
    m1_end_date,
    m2_start_date,
    m2_end_date,
    m3_start_date,
    m3_end_date,
    M1_act_rev,
    m2_act_rev,
    m3_act_rev
    If a user selects the dates from Jan,2011 to Jun, 2011
    I should get the aggregate of the revenues (m1+m2+m3+m1+m2+m3)

    Hi Gurus,
    Will this work
    select
    b.DISTRICT_NAME,
    count(c.CONTRACT_NUMBER),
    sum(C.M1_ACT_REV),
    sum(C.M2_ACT_REV),
    sum(C.M3_ACT_REV),
    sum(C.M1_EXP_PRICE),
    sum(C.M2_EXP_PRICE),
    sum(C.M3_EXP_PRICE)
    from
    clm_mn_compliance_data c,
    CLM_MN_CUSTOMER_ALIGNMENT_DATA b
    where
    ((m1_start_date between '01-01-2011' and '03-31-2011' ) and (m1_end_date between '01-01-2011' and '03-31-2011')) or
    ((m2_start_date between '01-01-2011' and '03-31-2011' ) and (m3_end_date between '01-01-2011' and '03-31-2011')) or
    ((m3_start_date between '01-01-2011' and '03-31-2011' ) and (m3_end_date between '01-01-2011' and '03-31-2011')) and
    b.CUSTOMER_ID = C.CUST_CTRT_ID
    group by
    B.DISTRICT_NAME;

  • Is the query analyzer part of SQL Server?

    Hey all,
    I have installed SQL Server 2005 on windows 2003 server. It did not install the query analyzer.
    Is the query analyzer part of SQL Server or do we need to install it separately?
    Thank you,
    Bye.

    Is there something about this question that is related to Oracle? It would appear that you'd want to ask this over in an appropriate Microsoft SQL Server forum...
    Justin

  • Is the query analyzer part of sql server database?

    Hey all,
    I have installed SQL Server 2005 on windows 2003 server. It did not install the query analyzer.
    Is the query analyzer part of SQL Server or do we need to install it separately?
    Thank you,
    Bye.

    Why not ask it in a Microsoft forum ?
    Nicolas.

  • Help with escape option in sql

    SQL> select sname from shares where sname like 'VIS_%';
    SNAME
    VISAKAIND
    VISASTEEL
    VISESHINFO
    VISHALEXPO
    VISHALRET
    VISUINTL
    VIS_SIN
    7 rows selected.
    SQL> select sname from shares where sname like 'VIS\_%';
    SNAME
    VISAKAIND
    VISASTEEL
    VISESHINFO
    VISHALEXPO
    VISHALRET
    VISUINTL
    VIS_SIN
    7 rows selected.
    SQL> select sname from shares where sname like 'VIS_\%';
    SNAME
    VISAKAIND
    VISASTEEL
    VISESHINFO
    VISHALEXPO
    VISHALRET
    VISUINTL
    VIS_SIN
    7 rows selected.
    could u people please help me to get the row with the sname vis_sin only....

    Hi Sybrand - here it is - please point to the error
    if you see it...
    Thanks.
    Connected to:
    Oracle Database 10g Enterprise Edition Release
    10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select table_name from dba_tables where
    table_name like 'PS\_%' and rownum<10 escape '\';
    select table_name from dba_tables where table_name
    like 'PS\_%' and rownum<10 escape '\'
    ERROR at line 1:
    ORA-00933: SQL command not properly endedselect table_name from dba_tables where table_name like 'PS\_%' escape '\' and rownum < 10;
    the 'escape' is part of the like condition so you need it contiguous to the like clause.

  • Help!!!: catalog.sql and catproc.sql damage my db

    after running the file my.sql (see below), i encounter some error:
    when i try to edit the table data, the following error displayed:
    ORA-04045 ... SYS.DBMS_OUTPUT
    ORA-06508 ...
    ORA-06512 ...
    ORA-06508 ...
    ORA-06512 ...
    then i go to the package SYS.DBMS_OUTPUT, the status is "invalid", i try to recompile it, the following error displayed:
    ORA-04045 ... SYS.CDC_ALTER_CTABLE_BEFORE
    ORA-06508 ...
    ORA-06512 ...
    ORA-06508 ...
    ORA-06512 ...
    my db works well before running the file my.sql. it seems the execution of catalog.sql and catproc.sql cause the error. i am using 9i, and the document histories show that the catalog.sql and catproc.sql are last updated in Apr,2001.
    my questions are:
    1.with 9i db, do i need to run the two files?
    2.how can i recover my db?(i don't have backup, can i use redoXX.log?)
    ***my.sql***
    connect sys/change_on_install@orcl as sysdba
    @/opt/oracle/rdbms/admin/catalog.sql
    connect sys/change_on_install@orcl as sysdba
    CREATE database mydb
    @/opt/oracle/rdbms/admin/catproc.sql
    ***my.sql***

    how can i get my db work properly just as it was?
    what do you mean by "create database script"?
    Database configuration assistant allows you to create the database template and then save it as a set of scripts that you
    can later customize and run to create the database. If you created your "create database scripts" using this option then
    these scripts automatically run the catproc.sql and catalog.sql scripts along with several other scripts.
    If you use Database configuration assistant to create such a set of DB creation scripts, than look at the
    CreateDBCatalog.sql script, as you can see it runs both the scripts. so, if you do it this way, you do not need to do any
    extra steps (apart from your custom scripts that may be part of your post install steps).
    A sample of such DB creation script will be as below (for your reference):
    ===================================================================
    connect SYS/change_on_install as SYSDBA
    set echo on
    spool /home/oracle/Ora9i/assistants/dbca/logs/CreateDBCatalog.log
    @/home/oracle/Ora9i/rdbms/admin/catalog.sql;
    @/home/oracle/Ora9i/rdbms/admin/catexp7.sql;
    @/home/oracle/Ora9i/rdbms/admin/catblock.sql;
    @/home/oracle/Ora9i/rdbms/admin/catproc.sql;
    @/home/oracle/Ora9i/rdbms/admin/catoctk.sql;
    @/home/oracle/Ora9i/rdbms/admin/owminst.plb;
    connect SYSTEM/manager
    @/home/oracle/Ora9i/sqlplus/admin/pupbld.sql;
    connect SYSTEM/manager
    set echo on
    spool /home/oracle/Ora9i/assistants/dbca/logs/sqlPlusHelp.log
    @/home/oracle/Ora9i/sqlplus/admin/help/hlpbld.sql helpus.sql;
    spool off
    spool off
    exit;
    ===========================================================================

  • Need help in writing a tricky sql/PL/Sql Procedure

    Hi,
    I have a Branch table with just two fields in it node1 and Node2, The table looks like this
    node1 | node2
    -------|---------
    1 | 2
    3 | 2
    3 | 4
    4 | 5
    1 | 5
    1 | 6
    5 | 6
    in the above data if you draw lines between node_1 and node_2 you will see that there are 3 different paths to get from 1 to 5, as follows
    /--------6-------\
    1----------------------5
    \2------3-------4/
    Now I need to Find all the nodes between 1 and 5 or all the possible paths from node 1 to node 5 in this case I have 3 possible paths they are as follows
    1-2-3-4-5
    1-3-5
    1-5
    Now I know if this data was stored in a hierarchical manner I can get the results i want by using CONNECT BY and SYS_CONNECT_BY_PATH.
    Is there a way to transform this data into a hierarchcal manner so that I can use the CONNECT BY or can somebody give me an Idea as to how to write a PL/SQL procedure to get the result I want.
    Any help will be greatly appreciated

    Hi!
    1.Create another table Branch1 to hold 'transformed data'.
    2.Use the following procedure to insert data into branch1 table.
    declare
    cursor n is select * from branch;
    begin
    for nrec in n loop
    if nrec.node1 = 5 then
         insert into branch1(node1,node2) values(nrec.node2,nrec.node1);
    elsif nrec.node2= 5 then
         insert into branch1(node1,node2) values(nrec.node1,nrec.node2);
    else
    if      nrec.node2> 5      then
         insert into branch1(node1,node2) values(nrec.node1,nrec.node2);
    elsif nrec.node1> 5 then
         insert into branch1(node1,node2) values(nrec.node2,nrec.node1);
    elsif (nrec.node1 < nrec.node2 ) then
         insert into branch1(node1,node2) values(nrec.node1,nrec.node2);
    else
         insert into branch1(node1,node2) values(nrec.node2,nrec.node1);
    end if;
    end if;
    end loop;
    commit;
    end;
    3.Then execute the following connect by query:
    SQL> select lpad(' ',level*2,' ')||node1 from branch1
    2 start with node1=1
    3 connect by prior node2=node1;
    Hope this is satisfactory.
    Thanks!

  • Help Required -- Can we use SQL Query to READ data from SAP MDM Tables

    Hi All,
    Please help.........
    Can we use SQL Query to READ(No Creation/Updation/Deletion  just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
    Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
    Thanks in Advance
    Regards

    All the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
    Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
    But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
    BR,
    Alok

  • Help, findind a part piece number and seller

    Hi I have a HP LaserJet Enterprise 500 M525f MFP, I have an aditional tray, but a few days we moved from a place to another the whole printer and the "port" where the extra tray connects got broken while trying to plug it back. I don't know whats the name of that port, and where can I purchase a replacement for it. 
    That is the "port" which got broken, is located behind the printer, and there is where the addional tray is connected.
    Thanks in advance.

    Good afternoon.
    Welcome to the community.
    I looked through the HMM also, to see if there was any notation for the part you describe and found none either. In my previous experience, those types of parts may be included in a package called System Miscellaneous Parts Kit. Looking at the X230 FRU Parts List, page 3 shows such an item (FRU P/N 04W1418), but I have no way of knowing what's included in it.
    Checking the FRU P/N on the Maintenance Parts Site, shows the kit is available for $19.50 + shipping, if you feel like taking a chance on it. Hopefully, another member will weigh in with additional details.
    Hope this helps a bit.
    Edit: typo.
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество
    Community Resources: Participation Rules • Images in posts • Search (Advanced) • Private Messaging
    PM requests for individual support are not answered. If a post solves your issue, please mark it so.
    X1C3 Helix X220 X301 X200T T61p T60p Y3P • T520 T420 T510 T400 R400 T61 Y2P Y13
    I am not a Lenovo employee.

  • Need help on syntax of PL/SQL Table type

    Hi Everyone
    I have the following Procedure
    DECLARE
    TYPE ln_empno IS TABLE OF NUMBER;
    ln_empno1 ln_empno;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT (dml_errors, -24381);
    ERRORS NUMBER;
    BEGIN
    UPDATE emp
    SET empno = empno
    RETURN empno
    BULK COLLECT INTO ln_empno1;
    FORALL idx IN 1 .. ln_empno1.COUNT SAVE EXCEPTIONS
    INSERT INTO t1
    VALUES (ln_empno1 (idx));
    EXCEPTION
    WHEN dml_errors
    THEN
    ERRORS := SQL%BULK_EXCEPTIONS.COUNT;
    FOR i IN 1 .. ERRORS
    LOOP
    DBMS_OUTPUT.put_line ( 'Error '
    || i
    || ' occurred during '
    || 'iteration '
    || SQL%BULK_EXCEPTIONS (i).ERROR_INDEX
    DBMS_OUTPUT.put_line ( 'Oracle error is '
    || SQLERRM (-SQL%BULK_EXCEPTIONS (i).ERROR_CODE
    END LOOP;
    END;
    This will collect the single column, I am not able to get the syntax to create a record containg empno and ename and bulk collect into a collection type.
    Can anyone help me to execute this procedure for ln_empno as a record of empno and ename.
    Thanks in Advance
    -Ahmed

    Also,
    If you want it as an update then why not just alter as per my example... e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2    TYPE lt_emp_rec IS RECORD (empno NUMBER, deptno NUMBER);
      3    TYPE lt_emp IS TABLE OF lt_emp_rec INDEX BY PLS_INTEGER;
      4    lr_emp lt_emp;
      5  BEGIN
      6    UPDATE emp
      7    SET deptno = deptno+10
      8    RETURNING empno, deptno
      9    BULK COLLECT INTO lr_emp;
    10    FOR idx IN 1 .. lr_emp.COUNT
    11    LOOP
    12      DBMS_OUTPUT.PUT_LINE('EmpNo: '||to_char(lr_emp(idx).empno)||' ::: DeptNo: '||to_char(lr_emp(idx).deptno));
    13    END LOOP;
    14* END;
    SQL> /
    EmpNo: 7369 ::: DeptNo: 30
    EmpNo: 7499 ::: DeptNo: 40
    EmpNo: 7521 ::: DeptNo: 40
    EmpNo: 7566 ::: DeptNo: 30
    EmpNo: 7654 ::: DeptNo: 40
    EmpNo: 7698 ::: DeptNo: 40
    EmpNo: 7782 ::: DeptNo: 20
    EmpNo: 7788 ::: DeptNo: 30
    EmpNo: 7839 ::: DeptNo: 20
    EmpNo: 7844 ::: DeptNo: 40
    EmpNo: 7876 ::: DeptNo: 30
    EmpNo: 7900 ::: DeptNo: 40
    EmpNo: 7902 ::: DeptNo: 30
    EmpNo: 7934 ::: DeptNo: 20
    PL/SQL procedure successfully completed.
    SQL>Was that so hard?

  • Need help in UPDATE data in SQL Query

    Hi all,
    I am trying to update data in the sql table as per below screenshot but couldn't able to do it. Can anyone help to update the data as I mention in screenshot.Appreciate you help.Thanks.
    Yellow highlighted columns are source
    Green highlighted columns are target
    Colored data should be update as per source data in sql table.Data is not static as it might have more rows to update and query should be bit dynamic.
    Maruthi...

    You have already asked this question once. You did not get any good answers, because you the information you gave was insufficient. And I'm afraid that the information is still in sufficient.
    Or more exactly, from the example you have given, the answer is: can't be done. And the reason it can't be done, is as I explained in response to you first thread: there is no information in the data to from which we can deduce that Clorox Company
    should be under "Week 1-1,K.B,F". The fact that rows are listed in a certain order in the screenshoot is of no importance, because a table is an unordered object.
    But you said in another post that you have a timestamp column. Maybe that column is usable - maybe it is not. But at least it is a key that you have more columns that the ones you show.
    The best way to get help with this type of problems is to post:
    1) CREATE TABLE statement for your table(s).
    2) INSERT statements with sample data.
    3) The desired result given the sample.
    4) A short description of the actual buisness problem you are trying to solve.
    5) Which version of SQL Server you are using.
    This makes it easy to copy and paste into a query window to develop a tested solution. Screenshots with an insufficient amount of data is not going to help you very much.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for