Extracting data from clobs

Hi,
I want to get the first line from a comments field. The data type is set to clob. I use the below section to get the data from the first line
Replace(dbms_lob.substr(comments,instr(comments,chr(10),1),1), Chr(10), '' ) from
The issue I have is it only gets the first line if there is a second comments line due to the character line feed.
Is there a way of just getting the data back from the first line only even if the length of the line varies?
Thanks regards
Adam
Edited by: user3924223 on 30-Jan-2009 06:51

Adam
You can try
select substr ( comments                       -- you want to pull out a varchar
                   , 1                                   -- if you want the very first line
                   ,  case instr(comments,chr(10)) when 0 then 100 else instr(comments,chr(10)) end    -- capture to chr(10) if present, or to 100 chars if not
from   yourtable
/Note: if the CLOB is longer than the max SQL varchar supported on your Oracle version (4000 on 9i iirc), you can use DBMS_LOB.SUBSTR and DBMS_LOB.INSTR. If you are doing this programmatically rather than in SQL, you can save the INSTR result into a local variable
HTH
Regards Nigel

Similar Messages

  • How to extract data from CLOB Datatype having XML values

    Hi,
    I am facing problem in extracting data from a TAble FCT_A where OBJECT_CONTENT field(Datatype CLOB) is having data of XML type.
    Below are the value:
    <ras-cube>
    <jndiDataSourceName>datasource_etl</jndiDataSourceName>
    <dimensions class="vector">
    <string>CUG_IND</string>
    <string>EVENT_DATE</string>
    <string>EVENT_DIRECTION_KEY</string>
    <string>EVENT_TIME_SLOT_KEY</string>
    <string>EVENT_TYPE_KEY</string>
    <string>FAF_IND</string>
    <string>FILTERED_OUT_FLAG</string>
    <string>IN_TG_ID_KEY</string>
    <string>LONG_EVENT_IND</string>
    <string>NE_ID_KEY</string>
    <string>NODE_ADDRESS</string>
    <string>OTHER_MSISDN_DIAL_DIGIT_KEY</string>
    <string>OUT_TG_ID_KEY</string>
    <string>RATING_DELAY_IND</string>
    <string>RI_MISMATCH_IND</string>
    <string>SERVED_MSISDN_DIAL_DIGIT_KEY</string>
    <string>SERVED_MSRN_DIAL_DIGIT_KEY</string>
    <string>SRV_TYPE_KEY</string>
    <string>SUBS_BU_KEY</string>
    <string>SYS_ID_KEY</string>
    <string>TERMINATION_REASON_KEY</string>
    <string>THIRD_PARTY_DIAL_DIGIT_KEY</string>
    <string>ZERO_FLAG_KEY</string>
    </dimensions>
    <measures class="vector">
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>CHARGE</targetName>
    <expression>SUM(FCT_RATED.CHARGE)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>COMPUTED_VOLUME</targetName>
    <expression>SUM(FCT_RATED.COMPUTED_VOLUME)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>DOWNLINK_VOLUME</targetName>
    <expression>SUM(FCT_RATED.DOWNLINK_VOLUME)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>ORIGINAL_DUR</targetName>
    <expression>SUM(FCT_RATED.ORIGINAL_DUR)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>RA_CHARGE</targetName>
    <expression>SUM(FCT_RATED.RA_CHARGE)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>RECORD_COUNT</targetName>
    <expression>COUNT(FCT_RATED.*)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>UPLINK_VOLUME</targetName>
    <expression>SUM(FCT_RATED.UPLINK_VOLUME)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    </measures>
    <dimensionMap class="linked-hash-map">
    <entry>
    <string>FCT_RATED</string>
    <null/>
    </entry>
    </dimensionMap>
    <cubeStorageConfig>
    <partitionColumn>EVENT_DATE</partitionColumn>
    <tableSpaceName>ORV5_ETL_DFLT</tableSpaceName>
    <isLogging>false</isLogging>
    <isCompressed>false</isCompressed>
    <noOfHashPartition>10</noOfHashPartition>
    <partitionScheme>1</partitionScheme>
    </cubeStorageConfig>
    <cubeType>1</cubeType>
    <name>MX_RATED</name>
    <label></label>
    <parentNames>
    <string>FCT_RATED</string>
    </parentNames>
    <otherProperties class="linked-hash-map"/>
    </ras-cube>
    I want to extract expression tag in the above XML types
    Kindly any help will be needful for me
    Thanks and Regards

    9i
    with FCT_A as (
    select xmltype('
    <ras-cube>
    <jndiDataSourceName>datasource_etl</jndiDataSourceName>
    <dimensions class="vector">
    <string>CUG_IND</string>
    <string>EVENT_DATE</string>
    <string>EVENT_DIRECTION_KEY</string>
    <string>EVENT_TIME_SLOT_KEY</string>
    <string>EVENT_TYPE_KEY</string>
    <string>FAF_IND</string>
    <string>FILTERED_OUT_FLAG</string>
    <string>IN_TG_ID_KEY</string>
    <string>LONG_EVENT_IND</string>
    <string>NE_ID_KEY</string>
    <string>NODE_ADDRESS</string>
    <string>OTHER_MSISDN_DIAL_DIGIT_KEY</string>
    <string>OUT_TG_ID_KEY</string>
    <string>RATING_DELAY_IND</string>
    <string>RI_MISMATCH_IND</string>
    <string>SERVED_MSISDN_DIAL_DIGIT_KEY</string>
    <string>SERVED_MSRN_DIAL_DIGIT_KEY</string>
    <string>SRV_TYPE_KEY</string>
    <string>SUBS_BU_KEY</string>
    <string>SYS_ID_KEY</string>
    <string>TERMINATION_REASON_KEY</string>
    <string>THIRD_PARTY_DIAL_DIGIT_KEY</string>
    <string>ZERO_FLAG_KEY</string>
    </dimensions>
    <measures class="vector">
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>CHARGE</targetName>
    <expression>SUM(FCT_RATED.CHARGE)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>COMPUTED_VOLUME</targetName>
    <expression>SUM(FCT_RATED.COMPUTED_VOLUME)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>DOWNLINK_VOLUME</targetName>
    <expression>SUM(FCT_RATED.DOWNLINK_VOLUME)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>ORIGINAL_DUR</targetName>
    <expression>SUM(FCT_RATED.ORIGINAL_DUR)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>RA_CHARGE</targetName>
    <expression>SUM(FCT_RATED.RA_CHARGE)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>RECORD_COUNT</targetName>
    <expression>COUNT(FCT_RATED.*)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    <targetName>UPLINK_VOLUME</targetName>
    <expression>SUM(FCT_RATED.UPLINK_VOLUME)</expression>
    <persist>true</persist>
    </com.connectiva.onereview.rasobjects.cube.CubeMeasure>
    </measures>
    <dimensionMap class="linked-hash-map">
    <entry>
    <string>FCT_RATED</string>
    <null/>
    </entry>
    </dimensionMap>
    <cubeStorageConfig>
    <partitionColumn>EVENT_DATE</partitionColumn>
    <tableSpaceName>ORV5_ETL_DFLT</tableSpaceName>
    <isLogging>false</isLogging>
    <isCompressed>false</isCompressed>
    <noOfHashPartition>10</noOfHashPartition>
    <partitionScheme>1</partitionScheme>
    </cubeStorageConfig>
    <cubeType>1</cubeType>
    <name>MX_RATED</name>
    <label></label>
    <parentNames>
    <string>FCT_RATED</string>
    </parentNames>
    <otherProperties class="linked-hash-map"/>
    </ras-cube>') OBJECT_CONTENT from dual
    SELECT   EXTRACTVALUE(value(d), '//expression/text()', '') exp
    FROM     fct_a t,
             TABLE(XMLSEQUENCE(EXTRACT (
                                 t.object_content,
                                 '//ras-cube/measures/com.connectiva.onereview.rasobjects.cube.CubeMeasure/expression'
                               ))) dEdited by: Beijing on Aug 10, 2009 9:21 AM

  • How to extract data from CLOB and insert them into DB?

    Hi PL/SQL Gurus,
    I have no experience in PL/SQL, but I have a requirement now where I have to use it.
    We have a table with 10 columns, one of them is a CLOB and it holds XML data. The XMLs are very huge in size.
    Two new columns are added to the table and the data has to be filled for the existing records from the corresponding XML. The XML has all the data as attributes. I started searching on the internet and tried if I could extract the data out of XML.
    SELECT extractValue(value(x), '/Order/Package/@Code',
    'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"' )
    FROM ORDER_TABLE A
    , TABLE(
    XMLSequence(
    extract(
    xmltype(A.XML_DATA)
    , '/ns0:Root'
    , 'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"'
    ) x;
    But this isn't working. Could anyone please provide some ideas.
    I just want to confirm that I am able to extract data. Once this is done I would like to create a procedure so that all the existing records can be updated.
    Thanks in advance.
    Regards,
    Fazzy

    Can this be acheived using a SQL statement.Yes, you can do it with the DML error logging clause.
    Here's a quick example I've just set up :
    Base table
    SQL> create table order_table (
      2   order_id number,
      3   package_code varchar2(30),
      4   package_desc varchar2(100),
      5   xml_data clob
      6  );
    Table created
    SQL> alter table order_table add constraint order_table_pk primary key (order_id);
    Table altered
    Adding data...
    SQL> insert into order_table (order_id, xml_data)
      2  values (1, '<?xml version="1.0" encoding="UTF-8"?>
      3  <ns0:Root xmlns:ns0="http://mycompany.com/Order/OrderType.xsd" BookingDate="2009-06-07">
      4  <ns1:OrderKey xmlns:ns1="http://mycompany.com/Order/OrderKeyTypes.xsd" SystemCode="THOMAS" Id="458402-TM1" Version="1"/>
      5  <ns0:Package Code="0001" Desc="ProductName1"/>
      6  <ns0:PromotionGroup Code="DSP" Name="OrderThomasPortal"/>
      7  <ns0:Promotion Code="TH902" Name="OrderThomasPortal" SellingName="OrderThomasPortal" BackOfficeName="OrderThomasPortal"/>
      8  <ns0:FinancialSupplier Code="HHT" Name="NYOrdSupp"/>
      9  <ns0:SellingCurrency Code="EUR" Name="Euro"/>
    10  <ns0:Owner ClientId="02654144" ClientMandator="T" ClientSystem="ROSY"/>
    11  <ns0:Agent PersonInAgency="5254" AgentCode="000009" CommissionAmount="2.8" CommissionDueDate="2009-07-01+02:00" VatOnCommission="0"/>
    12  </ns0:Root>');
    1 row inserted
    SQL> insert into order_table (order_id, xml_data)
      2  values (2, '<?xml version="1.0" encoding="UTF-8"?>
      3  <ns0:Root xmlns:ns0="http://mycompany.com/Order/OrderType.xsd" BookingDate="2009-06-07">
      4  <ns1:OrderKey xmlns:ns1="http://mycompany.com/Order/OrderKeyTypes.xsd" SystemCode="THOMAS" Id="458402-TM1" Version="1"/>
      5  <ns0:Package Code="0002" Desc="ProductName2/>
      6  <ns0:PromotionGroup Code="DSP" Name="OrderThomasPortal"/>
      7  <ns0:Promotion Code="TH902" Name="OrderThomasPortal" SellingName="OrderThomasPortal" BackOfficeName="OrderThomasPortal"/>
      8  <ns0:FinancialSupplier Code="HHT" Name="NYOrdSupp"/>
      9  <ns0:SellingCurrency Code="EUR" Name="Euro"/>
    10  <ns0:Owner ClientId="02654144" ClientMandator="T" ClientSystem="ROSY"/>
    11  <ns0:Agent PersonInAgency="5254" AgentCode="000009" CommissionAmount="2.8" CommissionDueDate="2009-07-01+02:00" VatOnCommission="0"/>
    12  </ns0:Root>');
    1 row inserted
    SQL> commit;
    Commit complete
    {code}
    Note that the second row inserted contains a not well-formed XML (no closing quote for the /Root/Package/@Desc attribute).
    *Creating the error logging table...*
    {code}
    SQL> create table error_log_table (
      2   ora_err_number$ number,
      3   ora_err_mesg$   varchar2(2000),
      4   ora_err_rowid$  rowid,
      5   ora_err_optyp$  varchar2(2),
      6   ora_err_tag$    varchar2(2000)
      7  );
    Table created
    {code}
    *Updating...*
    {code}
    SQL> update (
      2    select extractvalue(doc, '/ns0:Root/ns0:Package/@Code', 'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"') as new_package_code
      3         , extractvalue(doc, '/ns0:Root/ns0:Package/@Desc', 'xmlns:ns0="http://mycompany.com/Order/OrderType.xsd"') as new_package_desc
      4         , package_code
      5         , package_desc
      6    from (
      7      select package_code
      8           , package_desc
      9           , xmltype(xml_data) doc
    10      from order_table t
    11    )
    12  )
    13  set package_code = new_package_code
    14    , package_desc = new_package_desc
    15  log errors into error_log_table ('My update process')
    16  reject limit unlimited
    17  ;
    1 row updated
    SQL> select order_id, package_code, package_desc from order_table;
      ORDER_ID PACKAGE_CODE                   PACKAGE_DESC
             1 0001                           ProductName1
             2                               
    {code}
    One row has been updated as expected, the other has been rejected and logged into the error table :
    {code}
    SQL> select * from error_log_table;
    ORA_ERR_NUMBER$ ORA_ERR_MESG$                                                                    ORA_ERR_ROWID$     ORA_ERR_OPTYP$ ORA_ERR_TAG$
              31011 ORA-31011: XML parsing failed                                                    AAAF6PAAEAAAASnAAB U              My update process
                    ORA-19202: Error occurred in XML processing                                                                       
                    LPX-00244: invalid use of less-than ('<') character (use &lt;)                                                    
                    Error at line 5                                                                                                   
                    ORA-06512: at "SYS.XMLTYPE", line 272                                                                             
                    ORA-06512: at line 1                                                                                              
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Passing XML in CLOB and processing data from CLOB

    Hi All,
    I am facing problem when trying to access xml data from CLOB.
    My stored procedure is as below:
    CREATE OR REPLACE PROCEDURE usp_XMLTEST2
    in_XmlDoc IN CLOB
    IS
    BEGIN
    UPDATE XML_TEST
    SET SETFLAG='N'
    WHERE (ITEMCODE,WAREHOUSE) IN
    SELECT
    TO_NUMBER(EXTRACT(COLUMN_VALUE,'//Entry/@ItemCode')) ,
    TO_NUMBER(EXTRACT(COLUMN_VALUE,'//Entry/@Warehouse'))
    FROM TABLE(XMLSEQUENCE( EXTRACT(XMLTYPE(in_XmlDoc), '//List/*' )))
    END usp_XMLTEST2;
    Exec usp_XMLTEST2('<List Daemon="2"><Entry ItemCode="112333" Warehouse="4101" /><Entry ItemCode="112333" Warehouse="4103" /></List>');
    It gives error:
    ERROR at line 1:
    ORA-22905: cannot access rows from a non-nested table item
    ORA-06512: at "PUBLIX.USP_XMLTEST2", line 8
    ORA-06512: at line 1
    Please devise solution to this problem.
    Regards
    Nitin Bajaj

    Try casting it:
    SELECT TO_NUMBER(EXTRACT(COLUMN_VALUE,'//Entry/@ItemCode'))
    TO_NUMBER(EXTRACT(COLUMN_VALUE,'//Entry/@Warehouse'))
    FROM TABLE(cast( XMLSEQUENCE( EXTRACT(XMLTYPE(in_XmlDoc), '//List/*' )) as XMLSequenceType ) )
    Anton

  • Unable to extract data from an AS/400 system.

    Hello experts.
    We are trying to extract data from an AS/400 system but not having any success until now.
    I´ll write down you the stepts that we have followed until now:
    1.- Create a DB Connect between both systems
    2.- Create a Source System from AS400 in the workbench under DB Connect Directory
    3.- Generate datasources from tebles specified in the schema of the connection
    break point -
    At this point, we had a problem with some tables with at least one fieldname containing character "Ñ".
    After asking some possible solutions to SAP, the told us this is not supported, as the system can´t have any object with character "Ñ", so the transfer structure was unable to activate with this fields in the datasource.
    --- end of brek point --
    4.- After those issues, we´ve decided to implement, in another schema, views from those tables which had the fieldnames with that character "Ñ", changing them to an "N".
    5.- We´ve created another source system with that schema, and user than can see that schema.
    6.- To be able to see those views, in transaction RSDBC, we had to deactivate the two checkboxes in the first window ( Choose tables and Choose views) .
    7.- Right afeter, we could generate correctly the datasources from this logical tables.
    8.- We have designed  the hole dataflow for this datasources and everithing went rigth.
    9.- But wen we tried to execute the infopackage to extract data from those logic tables, we cannot get any registers. Acctualy the charge remains yellow after the job have finished.
    Please, I would appreciate any help you could give us on this problem.
    Thank you very much
    Regards
    Joaquin

    I´d like ti add something to this thread, and maybe clarify a littel bit the question.
    The only way that the BW system recognizes those logical tables, through transaction RSDBC is checking out the two boxes on this transaction, "Select Tables" and "Select Views".
    I don´t know haw these logical tables have been created, bus does this mean that the are not neither tables or views as BW understand them.
    Please, if someone knows anythin about this, answer to this thread.
    Thank you very much.
    Joaquin Sobrido

  • Extracting Data from APO PP/DS to BW

    Hi Gurus,
    I'm trying to extract data from APO PP/DS (SCM 5.1) to BW (BI 7.0). I'm new to SCM and am not sure how the extraction from SCM to BI happens other than that we need to read data from LiveCache.
    The extractor we are interested are
    0APO_PPDS_RESCAPREQ_01
    0APO_PPDS_PROD_CUST_01
    0APO_PPDS_OPERATION_01
    0APO_PPDS_ORDER_01
    Pls kindly help me out with the procedure.
    Thanks in advance.

    Hi
    Have a look at the below urls..
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5f229690-0201-0010-84ba-9ee5a8958a05
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4fe5d590-0201-0010-6c8d-ada86492cf11
    Re: APO to BW Design Question
    Re: APO BW Integration
    Hope it helps
    Thanks
    Teja

  • What key fields should i set in DSO extracting data from 2LIS_02_ITM

    hi experts
    i extract data from 2LIS_02_ITM into a DSO, i know the DSO isn't a must, becoz the 2LIS_02_ITM delta type is ABR, but i want to keep the info in change log.
    so, what the key fields should i set in the dso? just ebeln and ebelp is enough?
    hunger for ur advice and thanks a lot!

    If you extract ITM toa DSO you cannot maintain a log of every change....the data will come ....but when the data must be activated the reference of the ebelp ebeln will remain only a single record....if you want to maintain all the data you must create another field in extractor with you can difference all the changes for one single ebelp ebeln...
    Regards

  • When I extracting data from DSO to Cube by using DTP.

    When i am extracting data from DSO to Cube by using DTP.
    I am getting following erros.
    Data package processing terminated (Message no. RSBK229).
    Error in BW: error getting datapakid cob_pro (Message no. RS_EXCEPTION105).
    Error while extracting from source 0FC_DS08 (type DataStore) - (Message no. RSBK242).
    Data package processing terminated. (Message no. RSBK229).
    Data package 1 / 10/04/2011 15:49:56 / Status 'Processed with Errors'. (Message no. RSBK257).
    This is the brand new BI 7.3 system. Implementing the PSCD and TRM.
    I have used the standard business content objects in FI-CA (dunning history header, item,activities) and standard Datasource (0FC_DUN_HEADER ,0FC_DUN_ITEMS, 0FC_DUN_ACTIVITIES). I have extracted data till the DSO level . when I try to pull the data to info provider level(cube) using DTP . I am getting fallowing error.
    my observation: when ever I use the DSO as source to any target like another DSO or cube. its throwing same kind of error for any flow including simple Flat file .
    please suggest any one whether do I need to maintain basic settings since its a brand new BI 7.3.
    please help me out on this issue . I am not able to move forward .its very urgent

    hello
    Have you solved the problem ?  
    I have the same error...
    as you solve this error,
    can you help me please I have the same error
    yimi castro garcia
    [email protected]

  • How can I join 3 tables while extracting data from SAP R/3?

    I have 3 tables with the following columns
    Emp table (emp)
      emp_id
      emp_name
      emp_add
    Dept table (dept)
      dept_id
      dept_name
      dept_loc
    Location table (loc)
      loc_id
      loc_name
    Now. If I want to select data from loc_id = 10 and emp_id between 2000 and 3000
    How to join these three tables while extracting data from R/3
      join condition
       loc.loc_id = dept.loc_id
    and dept.dept_id = emp.dept_id
    and loc.loc_id =10
    and emp.emp_id between 2000 and 3000.
    Could any one let me know the procedure to extract this data into BW system.

    Hi,
    shouldn't your join condition be:
    loc.loc_id = dept.DEPT_LOC
    and dept.dept_id = ??
    If you can join the three tables then create a generic datasource (RSO) based on a view (create your view with your join in SE11).
    Enable the loc_id and the emp_id as selectable in the datasource so you can then select the values from a BW IPack.
    hope this helps...
    Olivier.

  • Extracting data from Z-table from SAP R/3 to BW

    Hi all
    I want to extract data from a Z-table from SAP R/3 system to Bw system. Currently I am on BW 3.5. Since it is a Z table I dont have a standard extractor for it & I dont knw how to create it. Can anyone provide me with the step-by-step documentation of how to extract data from a non standard SAP table????

    Hi
    You need to create Generic Datasource on the Z-Table you want to get data from
    Go to RSO2 transaction to create generic datasource .
    You need to give technical name of datasource under datasource type you want and click on create. Then you can give descrption and Application component under which u want see the datasource,
    enter the z table name under view/ table and save.
    here you can click on check boxes to make fields hidden or selection fields.
    Regards
    Ravi
    Edited by: Ravi Naalla on Aug 25, 2009 8:24 AM

  • Generate Insert Statement Script to Extract Data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that is running for over 15 years.Every now and then we need to extract data from this table@ ORacle 7i to be imported back to Oracle 10G.
    My thoughts are to create a script of Insert statements in oracle 7 and that to be deployed back to Oracle 10G.
    I found this scripts in Google and not sure how exactly this works.Any explanation on thsi scripts , would be greatly appreciated.I find this scripst may help to generate a set of insert statements from that table to the latest table at 10G.
    <pre>
    -- Step 1: Create this procedure:
    create or replace Function ExtractData(v_table_name varchar2) return varchar2 As
    b_found boolean:=false;
    v_tempa varchar2(8000);
    v_tempb varchar2(8000);
    v_tempc varchar2(255);
    begin
    for tab_rec in (select table_name from user_tables where table_name=upper(v_table_name))
    loop
    b_found:=true;
    v_tempa:='select ''insert into '||tab_rec.table_name||' (';
    for col_rec in (select * from user_tab_columns
    where
    table_name=tab_rec.table_name
    order by
    column_id)
    loop
    if col_rec.column_id=1 then
    v_tempa:=v_tempa||'''||chr(10)||''';
    else
    v_tempa:=v_tempa||',''||chr(10)||''';
    v_tempb:=v_tempb||',''||chr(10)||''';
    end if;
    v_tempa:=v_tempa||col_rec.column_name;
    if instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc:='''''''''||'||col_rec.column_name||'||''''''''';
    elsif instr(col_rec.data_type,'DATE') > 0 then
    v_tempc:='''to_date(''''''||to_char('||col_rec.column_name||',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
    else
    v_tempc:=col_rec.column_name;
    end if;
    v_tempb:=v_tempb||'''||decode('||col_rec.column_name||',Null,''Null'','||v_tempc||')||''';
    end loop;
    v_tempa:=v_tempa||') values ('||v_tempb||');'' from '||tab_rec.table_name||';';
    end loop;
    if Not b_found then
    v_tempa:='-- Table '||v_table_name||' not found';
    else
    v_tempa:=v_tempa||chr(10)||'select ''-- commit;'' from dual;';
    end if;
    return v_tempa;
    end;
    show errors
    -- STEP 2: Run the following code to extract the data.
    set head off
    set pages 0
    set trims on
    set lines 2000
    set feed off
    set echo off
    var retline varchar2(4000)
    spool c:\t1.sql
    select 'set echo off' from dual;
    select 'spool c:\recreatedata.sql' from dual;
    select 'select ''-- This data was extracted on ''||to_char(sysdate,''mm/dd/yyyy hh24:mi'') from dual;' from dual;
    -- Repeat the following two lines as many times as tables you want to extract
    exec :retline:=ExtractData('dept');
    print :retline;
    exec :retline:=ExtractData('emp');
    print :retline;
    select 'spool off' from dual;
    spool off
    @c:\t1
    -- STEP3: Run the spooled output c:\recreatedata.sql to recreate data.
    Source:http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml
    </pre>

    Thanks Justin.
    I get what you are saying,i really wanted to see the output of the codes, because the furtherst i could get from that code is
    SELECT EXTRACTDATA('MYTABLE') FROM MYTABLE;
    and it generated this:
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    I was expecting a string of
    insert into mytable values (19/1/2009,1,1);
    insert into mytable values (19/10/2008,5,10);
    Thanks for the explanation .

  • Extract data from Essbase with HAL to a flat file

    Hello,
    I would like to extract data from Essbase with HAL.
    I use the essbase Adapter with the "Extract Data" Method.
    All is working when I use only the essbase Adaptater and configure it.
    But I want to have a variable on my Years dimension.
    I have to fill "Years member port" and "Years Criteria port" of my essbase Adapter with variable.
    I have a "v_year" and "v_year_criteria" variable. I fill "v_year" with "FY05" but I don't know how fill my "v_year_criteria" variable.
    Thanks a lor for answer.

    If you are in 9.3x, I would recommend using the DATAEXPORT calc script function. You just FIX on what you want to export (including substitution variables), and then fill in some parameters and it writes a file. Look in the DBAG.

  • Extract data from Query to a Flat File - scheduling in the background

    Hi All,
    We need to extract data from a query to a flat file periodically, but each time 10 separate executions based on 10 profit centers, to get the separate files.
    So, we have PC1, PC2, ... PC10 Profit centeres.
    We have Query1, with profit center variable.
    We have created 10 variants for Query1 so that we can execute for 10 profit centers.
    Now, we have used RSCRM_BAPI to execute the Query1 and write to a flat file. Now we are having a problem in getting this feature used to execute the query automatically for 10 different varaints.
    Thanks in advance,
    _ Shashi

    Shashi,
       You can try using Information Broadcasting or Reporting Agent. You can schedule this in Information Broadcasting.
    check this link for Information Broadcasting... <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/a5/359840dfa5a160e10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/a5/359840dfa5a160e10000000a1550b0/content.htm</a>
    Nagesh Ganisetti.

  • Extracting data from Excel To Illustrator javascript or vbscript

    Hi all-
    I was wondering if there was a way to extract data from Excel to be used in Illustrator. I know there is an option of variables and xml, and I don't want that. I've seen and tried out how to read illustrator and write to excel, and I get that.  What I would like to do is pretty much the opposite:
    1.Pre-fill in an Excel file(.xls,.csv, doesn't matter) with data such as a filename in column 1 and (Replacement Text) in column 2 and close manually.
    2. Run script(VBSCRIPT,Javascript, doesn't matter)
    3.For each column in Excel file where cell in first column is not empty, open Illustrator Template with placeholder of "DWG" textframe and replace the frame titled "DWG" with Replacement text from Excel in Column2.
    4, Save each to a PDF file and name file with text from Excel Column1(Filename)
    In a nutshell, there will be a single illustrator template with a premade textFrame with a name of "DWG". Excel will contain two columns, one for the filename to be named and one for the relative text to replace with the placeholder in AI. I hoped I explained this well enough without causing too much confusion. Thanks in advance.
    Filename
    Replacement Text
    test1.pdf
    DWG01
    test2.pdf
    DWG02
    test3.pdf
    DWG03
    test4.pdf
    DWG04

    As text… \n is new line character and \r is return character. I can't remember which excel uses but they both equate to a line/paragraph… I very quickly threw together an example for you…
    #target Illustrator
    textToPDF();
    function textToPDF() {
              if ( app.documents.length == 0 ) { return; }
              var doc, csvFile, i, fileArray, opts;
              csvFile = File( '~/Desktop/ScriptTest/Test.csv' );
              if ( !csvFile.exists ) { return; }
              fileArray = readInCSV( csvFile );
              doc = app.activeDocument;
              opts = new PDFSaveOptions();
              opts.pDFPreset = '[Press Quality]';
              // Here we loop the main array
              for ( i = 0; i < fileArray.length; i++ ) {
                        // Here we get the second item of sub array i
                        doc.textFrames.getByName( 'DWG' ).contents = fileArray[i].[1];
                        // Here we get the first item of sub array i
                        doc.saveAs( File( fileArray[i].[0] ), opts );
    function readInCSV( fileObj ) {
              var fileArray, thisLine, csvArray;
              fileArray =[];
              fileObj.open( 'r' );
              while( !fileObj.eof ) {
                        thisLine = fileObj.readln();
                        csvArray = thisLine.split( ',' );
                        fileArray.push( csvArray );
              fileObj.close();
              return fileArray;
    I haven't tested it but it should be close…?

  • Is it possible to save / extract data from a MS SQL database 2008 using lookout 6.2?

    Is it possible to save / extract data from a MS SQL database 2008 using lookout 6.2?
      Now a days we are saving / extracting data in a excel spreadsheet, but we would like to do that using a database because it is better.

    You can use ODBC connection to work with SQL Server database.
    Use SQLExec object to execute the SQL statement. Here is a KB about the SQL statement.
    http://digital.ni.com/public.nsf/allkb/4ADEEA04CD24AE0B862565E20002A16F?OpenDocument
    To write data to spreadsheet is more straightforward because Lookout has built-in spreadsheet object. But you need to write SQL statement by yourself to interact with other database.
    To read the data back is the same way. Just use "select" SQL statement to query. You can use Datatable object to query.
    The "Data Source" can be "DSN = data source name;". The data source name is configured in Control Panel->Administrative Tools->Data Sources(ODBC).
    Ryan Shi
    National Instruments

Maybe you are looking for