Re: LOAD In 4GL Problems
Posted in 2005
This works fine with 4GL 7.32
$ echo "create table t1 (c1 serial, c2 varchar(20))" | dbaccess dk
$ echo -e "0|some text|\\n0|more text|" > input.unl
test.4gl:
main
define inpfile, outfile varchar(20)
database dk
let inpfile = "input.unl"
let outfile = "output.unl"
load from inpfile insert into t1
unload to outfile select * from t1
end main
fglpc test.4gl
fglgo test.4go
$ cat output.unl
1|some text|
2|more text|
The fine Art of 4GL programming
Navdeep Virk wrote:
> Art and all ,
>
> I tried to load rows into a temp table in a 4GL program ,where I am passing
> the filename as an argument .
> So I used the following syntax.
> DEFINE g_filename CHAR(10)
> .....
> LOAD FROM g_filename INSERT INTO t_sp ,where g_filename is a char variable
> and t_sp is a Temp table.>
> This did not work ,
>
> So I tried
>
> LET g_stmt = "LOAD FROM ",g_filename, " INSERT INTO t_sp "
>
> PREPARE p_curs FROM g_stmt
> EXECUTE p_curs
>
> did not work ,
>
> the third approach was
>
> LET g_stmt = "LOAD FROM ? INSERT INTO t_sp "
> PREPARE p_curs FROM g_stmt
> EXECUTE p_curs USING g_filename
>
> This also did not work .
>
> I can of course hard code the name of the load file ,also I can try fglgets
> to read in the rows one by one to solve the problem.
>
> But my question is that is there no way the "load into a temp table"
> achieved by passing a file as an argument and using prepare or otherwise
>
>
> TIA.
>
> Navdeep
> sending to informix-list