Professional Web Applications Themes

Reading file on disk, one line at a time, from DB2 stored procedure - IBM DB2

Hi, we are evaluating the possibility of migrating all of our Oracle databases to DB2 UDB, we need an easy way to migrate our procedures without rewriting all the codes. We are migrating Oracle to DB2UDB in Windows 2000. Our Oracle procedures reads a file one line at a time, treat the data, modify it and then insert it on a table or in another file. Then it reads the next line in the file, treats the data and so on... Oracle has a package named UTL_FILE that has several methods to tread files and permit us to read and ...

  1. #1

    Default Reading file on disk, one line at a time, from DB2 stored procedure

    Hi,
    we are evaluating the possibility of migrating all of our Oracle

    databases to DB2 UDB, we need an easy way to migrate our procedures

    without rewriting all the codes. We are migrating Oracle to DB2UDB in

    Windows 2000.
    Our Oracle procedures reads a file one line at a time, treat the data,

    modify it and then insert it on a table or in another file. Then it

    reads the next line in the file, treats the data and so on...
    Oracle has a package named UTL_FILE that has several methods to tread

    files and permit us to read and write lines,one line at a time.

    Trying to migrate these procedures we downloaded the function os_calls

    UDF. The os_calls has two entries that allows reading from a file, but

    both of them reads the entire file and loads the data at a table or a

    clob.

    Is there a similar way in IBM DB2 to access files the way Oracle does

    that can help us to migrate our Oracle procedures that read files(one

    line at a time) with the minimum efforts?

    Thank You for your help,

    Valeria.
    Valeria Guest

  2. #2

    Default Re: Reading file on disk, one line at a time, from DB2 stored procedure

    Valeria wrote: 

    I believe os_calls does have a table function that does read a piece of
    the file a time. Of course, you will have to modify it a bit. The nice
    thing about DB2 table udfs is that it can convert an entire file into a
    table like entity, treating each line as a row of data. You can do all
    kinds of query on it. The downside is it doesn't work very well on MPP
    system.

    What kind of file are you reading? Do you want just treat each line as a
    varchar string data? I can modify that function for you.

    No Guest

  3. #3

    Default Re: Reading file on disk, one line at a time, from DB2 stored procedure

    May I suggest you have a look at Object REXX?
    Object Rexx is a procedural language like Perl but much easier to learn.
    Reading/Writing lines and parsing the input is very easy with REXX.
    Database calls can be done by invoking the DB2 command line processor or
    via Rexx-DB2 API'S.



    Valeria wrote:
     

    --
    Anton Versteeg
    IBM Certified DB2 Specialist
    IBM Netherlands


    Anton Guest

  4. #4

    Default Re: Reading file on disk, one line at a time, from DB2 stored procedure

    In article <iibbmm.com>,
    iibbmm.com says... 

    I won't recommend the REXX-DB2 API's, their functionality is frozen
    since DB2 V5.

    Copied from the Information Center:

    Note the following points about software support:

    Fortran and REXX. DB2 will not enhance features for Fortran and REXX
    beyond the level of support for these languages in DB2 Universal
    Database Version 5.2.

    Gert Guest

  5. #5

    Default Re: Reading file on disk, one line at a time, from DB2 stored procedure

    No Body <com> wrote in message news:<168.2.101>... 
    >
    > I believe os_calls does have a table function that does read a piece of
    > the file a time. Of course, you will have to modify it a bit. The nice
    > thing about DB2 table udfs is that it can convert an entire file into a
    > table like entity, treating each line as a row of data. You can do all
    > kinds of query on it. The downside is it doesn't work very well on MPP
    > system.
    >
    > What kind of file are you reading? Do you want just treat each line as a
    > varchar string data? I can modify that function for you.[/ref]

    Hi, Thank you for helping. The file we are reading is a simple txt and
    our procedures read each line like a varchar string. The procedure
    reads the line, receives the string and treats the data, then the
    procedure reads another line in the txt and receives it like a string,
    treats the data. This go on till the end of the file.
    We are Oracle DBAs and work with PL/SQL. As I dont know C I would
    appreciate if You can help me.
    Valeria.
    Valeria Guest

  6. #6

    Default Re: Reading file on disk, one line at a time, from DB2 stored procedure

    Gert van der Kooij wrote: 
    >
    > I won't recommend the REXX-DB2 API's, their functionality is frozen
    > since DB2 V5.
    >
    > Copied from the Information Center:
    >
    > Note the following points about software support:
    >
    > Fortran and REXX. DB2 will not enhance features for Fortran and REXX
    > beyond the level of support for these languages in DB2 Universal
    > Database Version 5.2.[/ref]

    You could use rexx/sql (http://rexxsql.sourceforge.net/).

    Wolfgang
    Wolfgang Guest

  7. #7

    Default Re: Reading file on disk, one line at a time, from DB2 stored procedure

    > > 
    >
    > You could use rexx/sql (http://rexxsql.sourceforge.net/).
    >
    > Wolfgang
    >[/ref]


    I guess I can't call the administrative API's using rexxsql?
    Gert Guest

Similar Threads

  1. Reading Last Line in a Txt File
    By miniCooper@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 2
    Last Post: August 19th, 11:57 PM
  2. Reading tab delimited File & sort everything according item 5 of every line
    By Bjorn Van Blanckenberg in forum PERL Beginners
    Replies: 10
    Last Post: March 6th, 11:00 PM
  3. Reading a line at a time from a file
    By bjg in forum PHP Development
    Replies: 2
    Last Post: September 23rd, 04:05 PM
  4. how to list all the file names in a directory in Stored Procedure
    By David Portas in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: July 11th, 05:13 AM
  5. Replies: 1
    Last Post: July 10th, 01:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139