How to read a specific value or a portion of text using utl_file.

hi,
I have a small requirement which goes as follows. I have a text file which is a resultof the sql query and it contains 16 columns as PIPE delimited text . I am using the UTL_FILE package concept to read the data. In general when we use the UTL_FILE.GET_LINE we read the entire line of text. But i need to read the 10th column of the query or the PIPE delimited text .
Please advice.
My query goes something like this:
declare
f utl_file.file_type;
s long;
c number := 0;
begin
f := utl_file.fopen('ABC_EXTRACTS','sample1.txt','R');
loop
utl_file.get_line(f,s);
insert into s values (s);
c := c + 1;
end loop;
exception
when NO_DATA_FOUND then
utl_file.fclose(f);
dbms_output.put_line('No. of rows inserted : ' || c);
end;

Why don't you use varchar2 instead of long data type. I doubt you can read a portion from a file using utl_file but after doing the fetch you can do substring over the varchar2 variable and retrieve just the 10th column.
sample sql:
If your DB is 10g or higher, you can use the below regular expression to retrieve value based on your need.
PRAZY@11gR1> select regexp_substr('111|222|333|444|555|666|777|888|999|000|aaa|bbb|','[^|]+',1,10) from dual;
REG
000
Elapsed: 00:00:00.00Btwn, if the text file has fixed number of columns at all time, why don't you use a external table instead?
Regards,
Prazy
Edited by: Prazy on Mar 22, 2010 4:11 PM

Similar Messages

  • How to read Share Memeory values in Solaris 10 Kernel?

    How to read Share Memeory values in Solaris 10 Kernel?

    # ipcs
    IPC status from <running system> as of Tue Apr 8 15:39:50 BST 2008
    T ID KEY MODE OWNER GROUP
    Message Queues:
    Shared Memory:
    Semaphores:
    or review the output of
    # sysdef

  • WAD template with BSP Application - how to read selection screen values

    Hello,
    I've created Web template with Web Application Designer (WAD).
    I would like to extend  that page with BSP Application...
    Purpuse of this application is to read some information from tables
    on BW transaction server and display them within Web page.
    Question: How to read selection screen values from a Web template ?
    Thanks for any help,
    Pawel Borowiec

    Hi,
    The selection screen parameters will be on an inputField, so try and get the is of the inputfield generated by doing View source...
    And once you get the inputfield Id, you can read the value in the InputField(InF) by
    using the following code...!
    data : if_value type ref to cl_htmlb_inputfield.
    data : variable type string.
    if_value ?= cl_htmlb_manager=>get_data( request = request
                                                name    = 'inputField'
                                                id      = 'InF_ID_here'
           if if_value->value is not initial.
             variable  = if_value->value.
           endif.
    Hope this helps.
    <b><i>Do reward each useful answer..!</i></b>
    Thanks,
    Tatvagna.

  • How can i get the value stored in the session object using its sessionid

    how can i get the value stored in the session object using its sessionid by running stand alone java application

    myforum wrote:
    how can i get the value stored in the session object using its sessionid by running stand alone java applicationThis does not seem to make sense! You need at least to give a lot more detail of what you are doing.

  • How to get the kerning value and set it to back use script?

    hi,guys
    I come back again.
    I encountered a kerning problem.
    how to get the kerning value and set it to back use script?
    Thanks very much!

    For both cases, the filename can be found on the FILE.ReceivedFileName Context Property.  You can access this Property in a Pipeline Component or Orchestration and take any action you want, such as apply to a database.
    The value is accessed by: MyReceivedMessage(FILE.ReceivedFileName)
    In the case of a duplicate EDI Interchange, you would use the Failed Message Routing feature to capture the error message with either an Orchestration or Send Port.

  • How can I set a value of column in SSIS by using Replace

    How can I set a value of a column in SSIS using a Replace in Derive columns. I have here NameCode and I need to Set = 1 Where NameCode like LIKE '____99____'
    eg. 1006993010... if 5th and 6th characters are 99
    Else 0
    Hope to hear from someone soon and I appreciate great help here.

    If NameCode column is integer then you have to cast it correctly to String.
    I am adding that to the expression provided by Rajen.
    SUBSTRING((DT_WSTR,20)ProductCode,5,2) == "99" ? 1 : 0
    -Vaibhav Chaudhari

  • How can we repeat specific page number of pdf file by using FDF Toolkit for Windows?

    how can we repeat specific page number of pdf file by using FDF Toolkit for Windows?

    let's say a registration form, there is only 1 full address provided in my registration pdf, but applicant could have more than 1 address, so i have to make it more flexible to extend the address page no matter how many addresses that applicant provided, i have use adobe acrobat pro to edit the form properties. but dont know how to extend/duplicate a page in felxible times.
    Please advise~ tks so much!!! George

  • How to read a specific line of a .dat file?

    can we read a specific line of a .dat file, if so, how?
    i have this .dat files for each customer, which contain their name on the first line, their id on the second line
    and a list of items and an item id between each item.
    John Doe
    455689
    milk
    1
    orange
    9
    Here is what I am trying to do, please correct me
    //list out .dat file in dir
    File customer_dir = new File ("Customer")
    if (customer_dir.isDirectory())
    String[] listofdat=dir.list();
    for (int i=0;i<listofdat.length();i++)
    Scanner dat_read = new Scanner (new File listfodat);
    dat_read.nextLine();
    if (dat_read.nextLine().equals("455689")) <--is this okay?

    bibiancheng wrote:
    would you please explain to me what
    String[] tokens = line.trim().split("\\s*,\\s*")"\\s*,\\s*" is a regex where \\s means whitespace and the * means "any number of".
    so \\s* means that it will grab all the whitespace if there is any.
    trim() removes white space from the beginning and end of the string.
    dont put a comma in the name.
    spaces allowed: "jane doe, 12-14-09, 428438, 6, 388473, 7, 187374, 3"
    it was just a recommendation. breaking it into separate lines would be fine.

  • How to read the selected value of a dropdown list box

    Hello,
    I have 2 custom fields which are of type dropdown list on Accounts(CRMM_ACCOUNT) PCUI application details tab.I need to read the selected value of first dropdown list item,based on that second dropdown list will be populated.
    I know where to populate the dropdown list box,it is in FILL_DROPDOWN_LISTBOX.
    I dont know how to trap the selection made on dropdown list.
    PLease guide me on how to trap the dropdown list field selection value.
    Thanks in advance.
    Thirumala.

    Hello,
    Check what is done in standard for the fielf REGION which is inked to the country.
    Otherwise, you can do the following :
    - in field group customizing, for field 1, flag the 'send request' flag. So, when you change the value in this field via the dropdown, the MAC methods are immediately called.
    - Put the new value in a global variable (GV).
    - in the fill_dropdown_listbox method, get the value from this GV and based on it, filter the values for the dropdown of field 2.
    Hope this will help you,
    Regards,
    Frederic

  • How to read the tag values sent by PCo to MII transaction

    Hi everybody,
    I have an Agent created inside PCo and its listening to a data server. I have also created a notification object which triggers my MII Transaction (after certain condition is getting fulfilled).
    Now, I want to pass certain values from PCo to MII using the notification object. For this I have tried 2 options:
    1. I defined one input parameter in transaction of type 'XML'. But this did not work. When I used 'Tracer' to check the received values, it showed empty.
    2. Since XML variable did not work, I tried with 'String' variable. It worked but the entire input data was in 'String' format.
    Actually I used XML_Saver to save the string and given filename as '.xml'. When I opened that xml file, it was looking like this:
    <<unable to write XML here>>
    Considering the above 2nd option, how can I extract the particular 'Tag' values from XML string. Since the string is not in the format of 'Rowset/Row/Row', I cannot specifically assign/map those tag values to any other variable inside MII transaction.
    ===========

    Hi, I was trying to post the xml string. It was not possible yesterday (because, SDN editor has converted xml part into some irregular string).
    Now, I am trying to post the string by removing the special characters. Please try to understand it.
    Now, my question is how to retrieve the CDATA value 5599999999 using xpath. Please help.
    NotificationMessage
    Body
    Values
    Expression1 type xsd string
    CDATA 5599999999
      /Expression1
      /Values
      /Body
      Faults /
      /NotificationMessage

  • How to read empty tag value.

    Suppose there is a tag name with values ,
    <Name>Raj</Name>
    I am able to read the tag value 'Raj' ..
    But if the tag is like
    <Name /> I am getting null pointer exception while reading the tags value..
    I have put the reading part in a try catch block .Is there any other efficient way to do it.

    try {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder = factory.newDocumentBuilder();
             Document doc = builder.parse(inputSource);
             NodeList list = doc.getElementsByTagName("*");
             for (int i=0; i<list.getLength(); i++) {
               Element element = (Element)list.item(i);
               NodeList fstNm = element.getChildNodes();
    *//  Here is where i get null point exception because of tag being*
        *like <test/> ,whereas other tags have vakue like <test>value </test>*
               String check_null;
               try {
                check_null = (((Node) fstNm.item(0)).getNodeValue());
               catch(Exception ex) {
                   check_null="";
               //System.out.println(element.getNodeName() + ":"  + ((Node) fstNm.item(0)).getNodeValue());
               //if((((Node) fstNm.item(0)).getNodeValue()) != null)
               hm.put(element.getNodeName(),check_null);
               //System.out.println(element.getNodeName() + ":"+ (((Node) fstNm.item(0)).getNodeValue()));
           catch (Exception ex) {
               System.out.println("Exception in PostPaidInfo Parsing") ;;
               System.err.println(ex.toString());
               return 1;
         }I have just caught the exception ,I want to know is there any other way . The null pointer exception arises not because of string being null , But because of the internal parsing.
    Edited by: CulbOy on Apr 29, 2010 12:13 PM

  • How to read repeated tag values using sql query

    Database version
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE 11.2.0.2.0 Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Question
    How to get repeated tag values?
    <TXLife>
    <TXLifeRequest>
    <TransRefGUID>10bc80e7d60e59b0:a134d0:10d7c4674ad:-7ffd</TransRefGUID>
    <TransType tc="1203">OLI_TRANS_TRNHLD</TransType>
    <TransExeDate>2011-02-27</TransExeDate>
    <TransExeTime>15:06:35</TransExeTime>
    <InquiryLevel tc="3">OLI_INQUIRY_OBJRELOBJ</InquiryLevel>
    <InquiryView>
    <InquiryViewCode>PLANUPDATE_CHBM_1203A</InquiryViewCode>
    </InquiryView>
    <OLifE>
    <SourceInfo>
    <SourceInfoName>CHBM Admin Tool</SourceInfoName>
    </SourceInfo>
    <Activity id="Activity1" HoldingID="Holding1">
    <UserCode>User123</UserCode>
    <LastUpdate>2011-02-27</LastUpdate>
    <ActivityCode>CHBM10001</ActivityCode>
    <OLifEExtension VendorCode="0098" ExtensionCode="Activity">
    <ActivityExtension>
    <SubActivityCode>CHBM20002</SubActivityCode>
    <LastUpdateTime>15:06:35</LastUpdateTime>
    </ActivityExtension>
    </OLifEExtension>
    </Activity>
    <Holding id="Holding1">
    <HoldingTypeCode tc="6">Group Master Contract</HoldingTypeCode>
    <Purpose tc="36">Business Protection and Preservation</Purpose>
    <Policy>
    <CarrierAdminSystem>CHBM</CarrierAdminSystem>
    <PolNumber>CHB0001234</PolNumber>
    <OLifEExtension VendorCode="0098" ExtensionCode="Policy">
    <PolicyExtension>
    <BillingDetail>
    <PaymentMode tc="3">Quarterly</PaymentMode>
    <BillingOrder tc="1009800002">Employee ID</BillingOrder>
    </BillingDetail>
    <SalaryAllotment>12354333</SalaryAllotment>
    </PolicyExtension>
    </OLifEExtension>
    </Policy>
    <Attachment id="Attach1">
    <DateCreated>2011-02-27</DateCreated>
    <UserCode>System</UserCode>
    <AttachmentBasicType tc="1">Text</AttachmentBasicType>
    <Description>Event 4</Description>
    <AttachmentData>Event Log</AttachmentData>
    <AttachmentType tc="1009800001">Transaction Log</AttachmentType>
    <AttachmentLocation tc="1">Inline</AttachmentLocation>
    <OLifEExtension VendorCode="0098" ExtensionCode="Attachment">
    <AttachmentExtension>
    <Sequence>2</Sequence>
    <CreationTime>16:05:45</CreationTime>
    </AttachmentExtension>
    </OLifEExtension>
    </Attachment>
    <Attachment id="Attach2">
    <DateCreated>2011-02-27</DateCreated>
    <UserCode>System</UserCode>
    <AttachmentBasicType tc="1">Text</AttachmentBasicType>
    <Description>Event 3</Description>
    <AttachmentData>Event Log</AttachmentData>
    <AttachmentType tc="1009800001">Transaction Log</AttachmentType>
    <AttachmentLocation tc="1">Inline</AttachmentLocation>
    <OLifEExtension VendorCode="0098" ExtensionCode="Attachment">
    <AttachmentExtension>
    <Sequence>1</Sequence>
    <CreationTime>16:01:54</CreationTime>
    </AttachmentExtension>
    </OLifEExtension>
    </Attachment>
    <Attachment id="Attach3">
    <DateCreated>2011-02-27</DateCreated>
    <UserCode>P62350</UserCode>
    <AttachmentBasicType tc="1">Text</AttachmentBasicType>
    <Description>Note 2</Description>
    <AttachmentData>Enter notes on changes or edits to plan</AttachmentData>
    <AttachmentType tc="14">Note</AttachmentType>
    <AttachmentLocation tc="1">Inline</AttachmentLocation>
    <OLifEExtension VendorCode="0098" ExtensionCode="Attachment">
    <AttachmentExtension>
    <Sequence>2</Sequence>
    <CreationTime>16:02:23</CreationTime>
    </AttachmentExtension>
    </OLifEExtension>
    </Attachment>
    </Holding>
    </OLifE>
    </TXLifeRequest>
    </TXLife>
    Expected output shoulb be like this
    Description AttachmentType AttachmentData
    Event 4 Transaction Log Event Log
    Event 3 Transaction Log Event Log
    Note 2 Note Enter notes on changes or edits to plan
    Please help me any one on this
    Edited by: LRAJESH on Apr 20, 2011 8:27 AM

    SELECT
    t2. Description des,
    t2.AttachmentType attty,
    t2.DateCreated DateCreated,
    t2.UserCode UserCode,
    t1.Planid Planid,
    t2.createdtime,
    t1.Ausercode Ausercode
    FROM (
    SELECT xData doc
    FROM dual
    ) temp_table,
    XMLTable ( '/TXLife/TXLifeRequest/OLifE' passing doc
    COLUMNS
    Planid varchar2(20) path 'Holding/Policy/PolNumber',
    AttachmentType xmltype path 'Holding//Attachment' ,
    Ausercode varchar2(20) path 'Activity/UserCode'
    ) t1,
    XMLTable
    '/Attachment'
    passing t1.AttachmentType
    columns
    Description varchar2(1000) path 'Description',
    AttachmentType varchar2(1000) path 'AttachmentType/@tc',
    DateCreated varchar2(20) path 'DateCreated',
    createdtime varchar2(20) path 'OLifEExtension/AttachmentExtension/CreationTime',
    UserCode varchar2(200) path 'UserCode'
    ) t2

  • How to read multiline element values to a table

    Hello every one,
    I am facing a problem while reading multiline element values for workflow container.
    Through portal i am populating multipul records to the structure in wrokflow and they are storing fine, but when i am trying to read
    them through SAP_WAPI_READ_CONTAINER and reding with SWC_GET_TABLE OR SWC_GET_ELEMENT to a table with similar structure, i am not geitting the values.
    DATA: lt_url TYPE STANDARD TABLE OF ZHRESS_URL WITH HEADER LINE.
    CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
            EXPORTING
              workitem_id                    = '476329'                            "for instance i have hard coded the value
             LANGUAGE                       = SY-LANGU
             USER                           = SY-UNAME
          IMPORTING
            RETURN_CODE                    =
            IFS_XML_CONTAINER              =
            IFS_XML_CONTAINER_SCHEMA       =
           TABLES
             SIMPLE_CONTAINER               = lt_container
            MESSAGE_LINES                  =
            MESSAGE_STRUCT                 =
            SUBCONTAINER_BOR_OBJECTS       =
            SUBCONTAINER_ALL_OBJECTS       =
      swc_get_table wf_container 'URL' lt_url.
    the above element URL is multiline structure(ZHRESS_URL).
    Request your guidence.
    Thanks,
    Krish.

    Hello,
    Just look in SIMPLE_CONTAINER, you'll see mutiple entries if there's a table, eg:
    ADDRESSSTRINGS                   USSMITHJ
    ADDRESSSTRINGS                   USJONESB
    You can just read them using normal ABAP.
    regards
    Rick Bakker
    hanabi technology

  • How to read Choice Field values in a Formula of ohter shrepoint field

    Hi,
    i want to read choice field values(total values) in formula of other sharepoint calculated column field.
    Can anyone please help me.
    Thanks & Regards,
    Sandeep 

    Hi,
    According to your description, you might need to set the value of a column with the option from a Choice Field based on the value of another column(Site Column 1).
    The OOTB Calculated Formulas doesn’t provide such functionality to read the options of a Choice Field, we can do it via SharePoint JavaScript Client Object Model instead.
    Here is a documentation about SharePoint JavaScript Client Object Model :
    http://msdn.microsoft.com/en-us/library/office/hh185006(v=office.14).aspx
    An articel about using SharePoint JavaScript Client Object Model with steps in detail for your reference:
    http://social.technet.microsoft.com/Forums/en-US/2f679d4d-9aac-41ce-94a9-872ab258e30a/forum-faq-step-by-step-jsom-in-sharepoint-code-samples?forum=sharepointdevelopment
    Feel free to reply if there are still any questions.
    Best regards
    Patrick Liang
    TechNet Community Support

  • In NodeList how to read the ERRTAB values

    How to Read the NodeList ? I have an error table it has Type and message fields....
    NodeList list = document.getElementsByTagName("ERRTAB");

    I assume you are using XML DOM inside Java mapping. Once you got the Nodelist object initialised, get the length of the node list and run in a for loop for each Node that it has.
    VJ

Maybe you are looking for

  • User-defined fields in cost calculation

    Hi, I'm working with process order in customer service process. I would like to make a cost precalculation based on a user-defined field. To let you know. I created a new user-defined field. I affected to it a new parameter ID so that this user-defin

  • Document type in REM

    Hi All After posting from RERAPP system has posted doc with account type AB. Please let me know from where it has picked AB doc type. Regards shantanu

  • How can i get my mobile unlocked

    i was in us , and i bought iphone 4s and it's locked in sprint company . now i can't use him , so how to get him unlocked and how to make him international sim card

  • Query for finding out which components are in use

    Hi, I had a query once to check, if specific components are in use. Theres some internal view but i just can't remember. Can someone help me with this? EDIT: Damn it wrong board... Edited by: torgum on Nov 2, 2009 10:51 AM

  • Bex Query how to add two results fields to give a new total

    Hello gurus, I am using the Bex query designer to develop a report for invoice payments for different document types. One of the requirements of the report is to add a total column to give a total of the results for the document types added together.