Creating Table from Multiple Colon Separated Values

I have a DB table with a field that stores values that may be colon separated as resulting from a checkbox page item.
1:2
3:4
5:6
My ultimate goal is to turn those values into a table of singular values.
1
2
3
4
5
6
I've gotten close, but can't figure out how to finish the last step. My first step was to create a single query that concatenated all values into one long string. I am able to get
1:2:3:4:5:6
as a result of using the LISTAGG function in the query. My next step was to use a function, STRTAB, that I sourced from this forum to convert the colon delimited string into a result set using the query:
select * from table( strtab( '1:2:3:4:5:6' ))
where the string was derived from the LISTAGG query. The query works when I pass the above string, but if I try to insert the actual LISTAGG query it fails with missing expression. My actual query looks like this:
select * from table( strtab(
select listagg( RESTRICTED, ':' ) WITHIN GROUP ( order by RESTRICTED ) as ID
from SZ_LINKED_PROFILES
where RESTRICTED is not null
and PROFILE in ( select ID
from SZ_PROFILES
where ACCOUNT = :APP_ACCOUNT )))
Anyone know how I can complete the last step? I know I can do this with pl/sql, but I need this to be a single query as I'm using it as the criteria in an IN expression of a larger query.
Thanks in advance for your help!
-Jeff

Hi
This should be a lot quicker than using piplelined functions (or any PL/SQL for that matter)...
CREATE TABLE str2tbl
AS SELECT '1:2' str
   FROM dual
   UNION ALL
   SELECT '3:4'
   FROM dual
   UNION ALL
   SELECT '5:6'
   FROM dual;
WITH t_str AS
SELECT  str||':'                                     AS str,
         (LENGTH(str) - LENGTH(REPLACE(str,':'))) + 1 AS no_of_elements
FROM    str2tbl
),   t_n_rows AS
SELECT  LEVEL AS i
FROM    dual
CONNECT BY LEVEL <= (SELECT SUM(no_of_elements) FROM t_str)
SELECT RTRIM(str,':')                               AS original_string,
       SUBSTR(str,start_pos,(next_pos - start_pos)) AS single_element,
       element_no
FROM   (
        SELECT t_str.str,
               nt.i AS element_no,
               INSTR(t_str.str,':',DECODE(nt.i,1,0,1),
                                   DECODE(nt.i,1,1,nt.i - 1)) + 1 AS start_pos,
               INSTR(t_str.str,':',1,DECODE(nt.i,1,1,nt.i))       AS next_pos
        FROM   t_str JOIN t_n_rows nt
                       ON nt.i <= t_str.no_of_elements
ORDER BY 1, 3;
Table created.
ORIG SINGLE_ELEME ELEMENT_NO
1:2  1                     1
1:2  2                     2
3:4  3                     1
3:4  4                     2
5:6  5                     1
5:6  6                     2
6 rows selected.?
Cheers
Ben

Similar Messages

  • Create view from multiple days tables

    Hi,
    I'm having existing oracle db with daily stat data, tables strangely named data_mon, data_tue, data_wed.. For my batch processing I plan to use view with multiple day data, let say for last 5 days.
    Not sure how better implement my sql statement, with those _mon suffixes to make it more or less dynamic.
    I also never create View from multiple tables, so probably I can do something that will add fresh daily data and delete 5 days old data?
    Will appreciate you comments on details and whole concept. I have prev sql server experience.
    Thanks
    T

    user12943718 wrote:
    Hi,
    I'm having existing oracle db with daily stat data, tables strangely named data_mon, data_tue, data_wed.. For my batch processing I plan to use view with multiple day data, let say for last 5 days.
    Not sure how better implement my sql statement, with those _mon suffixes to make it more or less dynamic.
    I also never create View from multiple tables, so probably I can do something that will add fresh daily data and delete 5 days old data?
    Will appreciate you comments on details and whole concept. I have prev sql server experience.
    Thanks
    TChange the data model so you don't have 1 table for a day.
    You just have a DATA table, and a column to denote the day of applicability.
    Then you don't need a view, don't need anything dynamic, don't need to smash your head against a wall for a simple query ... etc.

  • Create pivot table from multiple sheets

    How to Create single pivot table from multiple sheets

    Hello,
    Debra Dahlgleish has a tutorial video on her site: 
    http://blog.contextures.com/archives/2010/04/16/how-to-create-an-excel-pivot-table-from-multiple-sheets/
    This Office support article also covers the steps:
    http://office.microsoft.com/en-001/excel-help/consolidate-multiple-worksheets-into-one-pivottable-report-HA010226585.aspx
    Both the video and the article relate to Excel 2007 but the steps will be similar in current versions.
    cheers, teylyn

  • SQL Loader to Load Multiple Tables from Multiple Files

    Hi
    I wish to create a control file to load multiple tables from multiple files
    viz.Emp.dat into emp table and Dept.dat into Dept table and so on
    How could I do it?
    Can I create a control file like this:
    OPTIONS(DIRECT=TRUE,
    SKIP_UNUSABLE_INDEXES=TRUE,
    SKIP_INDEX_MAINTENANCE=TRUE)
    UNRECOVERABLE
    LOAD DATA
    INFILE 'EMP.dat'
    INFILE 'DEPT.dat'
    INTO TABLE emp TRUNCATE
    FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
    (empno,
    ename,
    deptno)
    INTO TABLE dept TRUNCATE
    FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
    (deptno,
    dname,
    dloc)
    Appreciate a Quick Reply
    mailto:[email protected]

    Which operating system? ("Command Prompt" sounds like Windows)
    UNIX/Linux: a shell script with multiple calls to sqlldr run in the background with "&" (and possibly nohup)
    Windows: A batch file using "start" to launch multiple copies of sqlldr.
    http://www.pctools.com/forum/showthread.php?42285-background-a-process-in-batch-%28W2K%29
    http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true
    Edited by: Brian Bontrager on May 31, 2013 4:04 PM

  • How to create table from method

    Hello -
    Could anyone please tell me how can I create af:table with more than one column from an AppsModule method.
    When I have a 1d array return eg:
    public String[] createTable(){
    String[] str = new String[1];
    return str;
    I can drop it as a table and one column gets created. But how can I get mutiple columns in a table. I want to write a method, which when dropped on jsp page create table with multiple columns.
    I am using ADF 11g.
    Please suggest.
    Regards -
    Rohit

    Hi,
    for this you use an array or array list of objects. The object represent the row content, e.g. Person. The Person class then has setter/getter for each of the properties that you want to show in a column
    Frank

  • How to setup Compressor to create video from multiple sequences within FCP?

    I am wondering how I can set compressor up to create videos from multiple sequences within FCP. When I click file -> export - > compressor for a sequence and go into the program, it doesn't allow me to go back into FCP. I just get a spinning beach ball. Is there no way to set it up so I can prep a bunch of fcp sequences within compressor and then click submit and walk away? I have over 100 sequences that need to be exported so it would be a little difficult to do this one at a time. Thanks.

    Batch processing
    *Step one. Make sure everything in every sequence is rendered.*
    *Step two. Make a folder somewhere and name it something relevant.*
    *Step three. In FCP select all you sequences that you want to compress and right click (option), choose Batch Export from the contextual menu.*
    *Step three point one. In the batch export window click on settings and choose the folder you made in step two for the destination. Make sure Make Self-Contained is not check and include Audio and Video.*
    *Step four. Click export in the batch window.*
    Once that is done you can close FCP.
    Now in Compressor
    *Step five. Make a setting that will give you the output that you want (mpeg2, AC3, h.264, whatever). Make a destination for where you want to save the output.*
    *Step six. Make a droplet from the settings you made in step five.*
    You can quit Compressor now.
    *Step seven. Take the files that you batch exported from FCP in step three and four and drop them on the droplet you made in step six.*
    o| TOnyTOny |o

  • Consistency check error 38011: Logical tables from multiple subject areas..

    I received multiple 38011 errors when performing a consistency check after merging repositories:
    For example:
    Logical tables from multiple subject areas associated, OHRP and Enterprise Warehouse
    (OHRP and Enterprise Warehouse refer to different business models)
    I'm really not sure what this means, and Metalink and Google aren't turning up anything.
    Thoughts?
    -John

    John,
    Does it say anything about Assertion Failure? Also, this is straight up from help regarding import (through file menu) "Use this option when the objects you import are unrelated to objects already in the repository such as when the business model and physical layer objects do not exist. If an object of the same name and type exists, the import process overwrites the existing object with the new object. When you import objects from one repository into another, the repository from which you are importing must be consistent."
    Sometimes Merge does bring unexpected (and unwanted results) - especially if there're presentation aliases, duplicate business models, or naming conflicts. If it's not too late, I suggest you use Import,rather than Merge, also, preferably starting with a new RPD file. This would enable you to bring items piece-by-piece and hopefully would allow you to isolate the problem.
    Also, depending on the size - it's sometimes preferable to just reproduce missing part(s). I hope this is helpful.
    Also, I forgot to say - the Import is deprecated and not supported. They suggest you use Project Extract and Merge. If Merge isn't working out for you and Import isn't an option - maybe you could try Project.
    Edited by: wildmight on Mar 9, 2009 7:58 AM

  • Creat new table from multiple tables in same DB?

    Trying to create a new table bringing in all the records from
    3 old tables. All three old tables have common foreign key fields.
    I'm not sure how the syntax would look like, but something
    like:
    <cfquery name="qCreateTable" datasource="somedb">
    CREATE TABLE newtable
    AS
    SELECT old_ID as new_ID,
    FROM oldtable1, oldtable2, oldtable3 etc.</cfquery
    Is this possible in one step, or would I need to create the
    new table with data from oldtable1, then update with data from 2, 3
    etc.? BTW I already tried that with no success (syntax errors).
    For now, this is in Access.
    Thanks for your help.
    rinorman

    Phil:
    <cfquery name="qCreateTable" datasource="somedb">
    CREATE TABLE vendor_new2
    AS
    SELECT
    vendor_ID as old_vendor_ID,
    company_name as vendor_company,
    DBA_name as vendor_dba,
    web_URL as vendor_url,
    AdminID as old_admin_ID,
    Comment as old_comment,
    BillingLocationID as old_billing_ID
    FROM vendor_old
    UNION
    SELECT
    UserID as old_user_ID,
    EmailAddress as vendor_email,
    Password as vendor_pw,
    LastName as contact_lname,
    FirstName as contact_fname,
    PhoneNum as contact_tele,
    PhoneExt as vendor_phonex,
    FaxNum as contact_fax
    FROM main_contact
    UNION
    SELECT
    PhysicalLocationID as old_location_ID,
    Street1 as vendor_address1,
    Street2 as vendor_address2,
    City as vendor_city,
    StateID as vendor_state,
    Zip as vendor_zip,
    Zip4 as vendor_zip4,
    Phone as vendor_tele,
    Fax as vendor_fax
    FROM PhysicalLocation
    </cfquery>
    Result: Syntax error in CREATE TABLE statement.

  • Getting error while creating table from one database to other.

    Hi,
    We are getting below error while creating the table from one database to other.
    SQL> create table fnd_lobs parallel compress as select * from [email protected];
    create table fnd_lobs parallel compress as select * from [email protected]
    ERROR at line 1:
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    Regards,
    Bhatia

    hi
    what are the apps version local and remote database???
    Snapshot too old errors occur because Oracle can 't reconstruct a consistent
    image of a block for the purposes of a consistent read.
    I feel at remote database, you are using UNDO, it will be rather easy to iincrease the undo retention time or increase the undo tablespace size.. if you are dealing with roll back segments, you may have rollback segments whose optimal values are too small...
    increase roll back segments size and select again then
    the following metalink notes might be helpful
    ORA-01555 "Snapshot too old" - Detailed Explanation Doc ID: 40689.1
    How To Avoid ORA-01555: Snapshot Too Old When Running PAAPIMP Doc ID: 603259.1
    OERR: ORA 1555 "snapshot too old (rollback segment too small)" Doc ID: 18954.1

  • Create table from external data with dates

    I have a CSV that looks somewhat like this:
    abcuser,12345,5/12/2012,5,250.55
    xyzuser,67890,5/1/2012,1,50
    ghjuser,52523,1/1/1900,0,0
    When I create the external table, then query it I get a date error:
    CREATE TABLE xtern_ipay
    userid VARCHAR2(50),
    acctnbr NUMBER(20, 0),
    datelastused DATE,
    number_rtxns NUMBER(12, 0),
    amtused NUMBER(12, 0)
    organization external ( TYPE oracle_loader DEFAULT directory "XTERN_DATA_DIR"
    ACCESS parameters (
    records delimited BY newline fields terminated BY "," )
    location ('SubscriberStatistics.csv') ) reject limit UNLIMITED;
    Error I see in the reject log:
    Field Definitions for table XTERN_IPAY
    Record format DELIMITED BY NEWLINE
    Data in file has same endianness as the platform
    Rows with all null fields are accepted
    Fields in Data Source:
    USERID CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    ACCTNBR CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    DATELASTUSED CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    NUMBER_RTXNS CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    AMTUSED CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    error processing column DATELASTUSED in row 1 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    error processing column DATELASTUSED in row 2 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    error processing column DATELASTUSED in row 3 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    Any ideas on this? I know I need to tell oracle the format of the date on the external file, but I can't figure it out.

    Try this:
    CREATE TABLE xtern_ipay
       userid         VARCHAR2 (50)
    , acctnbr        NUMBER (20, 0)
    , datelastused   DATE
    , number_rtxns   NUMBER (12, 0)
    , amtused        NUMBER (12, 2)
    ORGANIZATION EXTERNAL
        ( TYPE oracle_loader DEFAULT DIRECTORY "XTERN_DATA_DIR"
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY "," MISSING FIELD VALUES ARE NULL
    (   userid
      , acctnbr
      , datelastused DATE 'mm/dd/yyyy'
      , number_rtxns
      , amtused)
    location ('SubscriberStatistics.csv') ) reject LIMIT unlimited;
    select * from xtern_ipay;
    USERID                                                ACCTNBR DATELASTU NUMBER_RTXNS    AMTUSED
    abcuser                                                 12345 12-MAY-12            5     250.55
    xyzuser                                                 67890 01-MAY-12            1         50
    ghjuser                                                 52523 01-JAN-00            0          0
    {code}
    Sorry I had to correct the previous statement again for the date format and for the column amtused that was defined without decimals.
    Regards
    Al
    Edited by: Alberto Faenza on May 31, 2012 6:34 PM
    wrong date format mm/dd/yy instead of dd/mm/yy
    Edited by: Alberto Faenza on May 31, 2012 6:40 PM
    Fixed again the date format and the amtused defined with 2 decimals                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Create PDF from Multiple Files Error

    Running Acrobat 8.1.2 and InDesign CS3 8.0.2
    When trying to create a PDF from multiple files, I am getting an error with each file as it is opened by Acrobat to create the PDF file. The error reads:
    Invalid value for parameter 'using' of event 'exportFile'. Expected PDFExportPreset, but received "Standard".
    The files are also left open in InDesign afterward instead of being closed. Does anyone have any idea what might be causing this?
    Thanks.

    Did you upgrade your Office / Word installation?
    PDFMaker-compatible applications for Acrobat 7 with regards to MS Office:
    --| Office 2000
    --| Office XP
    --| Office 2003
    See:
    http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html 
    Be well...

  • Problem creating pdf from multiple files

    Hello,
    I'm running Windows XP SP3 with Adobe Acrobat Standard 8.2.1.  When I try to create a one pdf from multiple files in Adobe Standard 8.2.1 the application just closes.  The two files I'm trying to combine into 1 pdf file are word files.   I'm able to create a single pdf of each word file by opening them separately in word and sending them to the acrobat printer.  I've tried combining other files also, but had no luck.  Windows events doesn't log anything under applications and no error message pops up when the application closes.
    Anybody have any ideas how to troubleshoot this issue or what could be causing the applicaton to just close? 

    I've read many discussions about Acrobat and problems with server files, with the general solution being what you are doing... copy the files to a local hard drive

  • Loading to target table from multiple source table

    Hi forum,
    I have some doubts regarding selecting data by joining 2 or 3 tables and populate the target table in same schema(ora 10g).The way i need to load is first extract the data and do some some transformations(like derive new value based on existing column value ,eg: arithmetic operations) and then load data to target table in same schema...
    GIve me a suggestion to do the same in best possible way..since the entire activity to be finished in 3 hrs and volume in each table is 377 million , 122 million and 120 million.
    Thanks ,
    Aneesh A

    It is Rob who spend his freetime in answering you - not "bob".
    > Can u explain me the time-lines for the mentioned volume...?
    You mean "you" and not "u"? This is not a MXIT forum where IM SPEAK is the norm.
    As for time-lines.. it is silly to expect anyone to give you estimated run times when the hardware platform, types of disks, o/s configuration, Oracle configuration, average loads and so on are unknown.
    What Rob showed you is the most optimal way to write SQL to transform data from one or more source tables and insert these results into a destination table - using direct path inserts and parallel query. The only faster method would be a CTAS - Create Table As Select as oppose to an Insert Table with select.

  • Creating pdf from multiple docs in PS8

    i need to create a multi page PDF docs from multiple docs using photoshop elements 8. source docs will be other formats (e.g. MS WORD), but i could convert to pdf.
    any help would be greatly appreciated.

    Yes you can open Writer (the word processing/text module) and use it like a blank word document. You can copy and paste from other sources, import image files, tables and objects and save as PDF.
    This is how it looks:
    Click to enlarge

  • "Create Table from select Query" Vs "Insert into"

    Hi
    Schenaio:
    My Select Query returns more than 10 million records, these records needs to be inserted into another table.
    Approach 1:
    I created table called TABLE1, and inserted the records using INSERT statement as a batch (batch size is 5000).
    Approach 2:
    I create table like,
    CREATE TABLE TABLE1 AS <SELECT QUERY>
    Here Apporach-1 took almost 40 minutes to complete the insert but Approach-2 took only 6 minutes.
    If anybody knows why it is? And is there any way to improve the performance of Approach-1?.
    Thanks
    Nidhi

    Most "batch" methods execute the same query multiple times. Row filtering is done after the rows are fetched from the source. The process of fetching all the rows could be a FullTableScan.
    Therefore, a FullTableScan is executed for each batch of 5000 rows.
    However, your query and batch definitions may well be different. We haven't seen the query and the execution plan.
    Another point : How are you "filtering" the rows (i.e the second execution inserts rows 5001 to 10000 and does not attempt to reinsert rows 1 to 5000) ?
    What is the overhead imposed by the filter ? (does the third execution have to exclude rows 1 to 10000 and inserts rows 10001 to 15000 and so on)
    Hemant K Chitale

Maybe you are looking for

  • I am having terrible lag issues with my 2011 mac mini

    Hi, I am fairly new to the Mac worl. I have had iphones and ipads but this is my first Mac here are the specs... Yosemite 10.10.1 2.3ghz intel core i5 16gb 1333 MHz ddr3 intel HD Graphics 3000 512 MB Every time I try to do something I get the pin whe

  • Safari's Google-search bar in Dutch ***?!?!

    I have a Macbook pro, Lion all up tp date, and recently I discovered that when I use Safari's google search bar it uses the Dutch google (i.e. goole.nl). I haven't changed any settings. I am in China atm, but have a UK VPN and even when I've just bee

  • Can't change fps in project properties

    I can't change the fps in the project properties in Motion 3. I can change everything else, but that. It is stuck at 29.97 but I want it to be at 23.98. Even when I change the preset to, say, 720p24, the fps is still at 29.97. Is this a bug, or is th

  • First time in windows environment

    I've downloaded and installed SDK and JRE 1.4.2 beta but its my first time programming java in a windows environment. my question is how to link the commands so i can use java in from dos ie)c:\javac prog.java c:\java prog something to do with linkin

  • Panther 10.4.11 and active directory

    Hello Mac friends, I am learning IT network as a trainee and in my training company, we are desperately trying to bind a powerbook using MAC OS 10.4.11 to the Active Directory's company. I have gathered some precious information on the subject. I kno