[FMPP] How to iterate through lines - (Re: SqlDataLoader)
Brought to you by:
ddekany
|
From: Ralf H. <ral...@gm...> - 2005-02-24 06:26:57
|
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/e.do?ema...@ac...
|