dbTalk Databases Forums  

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

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Reading file on disk, one line at a time, from DB2 stored procedure in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Valeria
 
Posts: n/a

Default Reading file on disk, one line at a time, from DB2 stored procedure - 10-03-2003 , 01:08 PM






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.

Reply With Quote
  #2  
Old   
No Body
 
Posts: n/a

Default Re: Reading file on disk, one line at a time, from DB2 stored procedure - 10-03-2003 , 08:07 PM






Valeria wrote:
Quote:
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.
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.



Reply With Quote
  #3  
Old   
Anton Versteeg
 
Posts: n/a

Default Re: Reading file on disk, one line at a time, from DB2 stored procedure - 10-06-2003 , 06:31 AM



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:

Quote:
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.


--
Anton Versteeg
IBM Certified DB2 Specialist
IBM Netherlands




Reply With Quote
  #4  
Old   
Gert van der Kooij
 
Posts: n/a

Default Re: Reading file on disk, one line at a time, from DB2 stored procedure - 10-06-2003 , 04:05 PM



In article <3F81529B.7030804 (AT) nnll (DOT) iibbmm.com>,
anton_versteeg (AT) nnll (DOT) iibbmm.com says...
Quote:
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.


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.



Reply With Quote
  #5  
Old   
Valeria
 
Posts: n/a

Default Re: Reading file on disk, one line at a time, from DB2 stored procedure - 10-07-2003 , 02:37 PM



No Body <nobody (AT) nowhere (DOT) com> wrote

Quote:
Valeria wrote:
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.

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.
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.


Reply With Quote
  #6  
Old   
Wolfgang Riedel
 
Posts: n/a

Default Re: Reading file on disk, one line at a time, from DB2 stored procedure - 10-08-2003 , 11:05 AM



Gert van der Kooij wrote:
Quote:
In article <3F81529B.7030804 (AT) nnll (DOT) iibbmm.com>,
anton_versteeg (AT) nnll (DOT) iibbmm.com says...
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.



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.
You could use rexx/sql (http://rexxsql.sourceforge.net/).

Wolfgang


Reply With Quote
  #7  
Old   
Gert van der Kooij
 
Posts: n/a

Default Re: Reading file on disk, one line at a time, from DB2 stored procedure - 10-09-2003 , 01:30 PM



Quote:
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.

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

Wolfgang


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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.