How to iterate through lines - (Re: SqlDataLoader)
"Ralf Hauser" <[email protected]> Thu, 24 Feb 2005 07:26:19 +0100
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
Hi,
How can one easily iterate through lines of an input .txt file?
I faintly remember that this is very easy with the Perl while loop, but I'd
rather stay with fmpp and I didn't find anything in freemarker doc.
Plan:
=====
I have a txt file with each line representing a relational table record. I
want to prefix some string (SQL instruction), perhaps replace some "," with
"','" and terminate each line by replacing "@@@" with a closing string.
And this needs to be written to a different outputfile (e.g. ".sql")
If anyone can share an example how to do this, many thanks in advance!
Ralf
Ps:
Background:
===========
Basically, I need the opposite of what Carl has so nicely contributed
(Although I would call his oeuvre "SqlDataRetriever") and I would call what
I need SqlDataUploader.
**
He is retrieving data from sql into fmpp and I want to take data out of a
txt file into fmpp and ultimately into a relational DB.
So far, my input txt file was sufficient with MySQL and I used
LOAD DATA
INFILE './tbl_globals.txt'
INTO TABLE TBL_GLOBALS
FIELDS TERMINATED BY ','
LINES TERMINATED BY '@@@';
Now, the data also needs to go into Oracle and I am told, it is for the few
dozens of records easier to just do plain SQL insert statements with the
values than to try to create a "sqlldr" .ctl input file. This is what I want
to achieve above.
The advantage of going for plain SQL is furthermore that it will be more
portable if I next had to get it into DB2, Postgres, Daffodil, ...
--------------
Securely and spam-free via:
https://www.privasphere.com/[email protected]
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click