Re: load from flat file
Posted in 1998
I'd suggest 1 of 4 approaches depending upon the version of your engine:
1) Via system command to load via DB-Access (e.g. load from xxx.txt
insert into table). I'd probably do this by executing a shell script whichlooks similar to this:
#!/bin/ksh -u
dbaccess mydb <<-EOF
load from myfile.txt delimiter '|'
insert into mytable ( col1, col2, coln); EOF
ERROR=$?
exit ${ERROR}
2) If using ODS (i.e. 7.x) define a format / map and execute pload via
system command.
3) If using XPO (i.e. 8.x) define an external table and simply issue an
insert into real table select from external table.
4) Install the Perl DBD::Informix module and do it through Perl w/asystem command.
Please be aware that all of these approaches utilize a separate session from
that which is running the stored procedure and will not be affected by the
transaction the stored procedure may be in.
Regards,
bc
Art S. Kagel wrote in message <36421716.1879@bloomberg.net>...
>Gursoy YERLI wrote:
>>
>> Hi Folks,
>>
>> I am trying to create stored procedure to load data from flat file into
>> a table.
>>
>> load from "data.txt"
>> insert into table_name>>
>> does not work. Is there any other way to accomplish this. Thank you.
>
>Can't do it. The 'load' command is NOT an SQL statement but a dbaccess
>built in command. It is therefore not available to SPL. If you have
>4GL, 4GL also has the 'load' command built into the language so you can
>write commandline load programs using it and since SPL does not do
>dynamic statement execution the 4GL program will be much more powerful
>anyway.
>
>Art S. Kagel