Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Informix Topics / February 2005

Tip: Looking for answers? Try searching our database.

LOAD In 4GL Problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Navdeep Virk - 23 Feb 2005 02:35 GMT
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
Claus Samuelsen - 23 Feb 2005 10:28 GMT
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

> Art and all ,
>
[quoted text clipped - 35 lines]
> Navdeep
> sending to informix-list
Ferronato - 23 Feb 2005 13:17 GMT
> Art and all ,
>
[quoted text clipped - 35 lines]
> Navdeep
> sending to informix-list

Hi,

Try this:
LET g_stmt = 'LOAD FROM "',g_filename clipped, '" INSERT INTO t_sp '

It means using inverted commas (" ") and into it the file name.

BR

Ferronato
ART KAGEL, BLOOMBERG/ 731 LEXIN - 23 Feb 2005 20:39 GMT
How about this:

   LET mover = "ln -s ", g_filename, " tmpname"
   RUN mover

   LOAD FROM tmpname INSERT INTO t_sp

   LET cleanup = "rm tmpname"
   RUN cleanup

  ...

Art S. Kagel

----- Original Message -----
From: Navdeep Virk  <nvirk@msn.com>
At:  2/22 21:36

> Art and all ,
>
[quoted text clipped - 34 lines]
>
> Navdeep

sending to informix-list
Everett Mills - 23 Feb 2005 21:30 GMT
Art & Navdeep-
    Navdeep never said what the behavior of his application was; he
just said "it did not work."  I see no reason that his original syntax
without the prepare statement should not have worked, unless there was
another problem interfering with it.  Navdeep: did the app give you any
error messages?  Did you check the contents of g_filename to make sure
that the name of the load file actually was stored there?  Is the file
in the same directory as the program trying to load it?  Did you make
sure to execute this statement before the LOAD statement:

    LET g_filename = ARG_VAL(1)

If not, the reason it won't work is because there is nothing in
g_filename for the app to load from.  If the load file is not in the
same directory, you will need to supply a complete pathname and user a
bigger variable for g_filename.  Also, assuming that g_filename is a
global, it may be getting reset after the ARG_VAL() loads it.  It may
help to see a bigger section of your original (without the prepare)
code, i.e.: Where the g_filename is loaded, where the temp table is
created, etc.
   
            --EEM

> -----Original Message-----
> From: ART KAGEL, BLOOMBERG/ 731 LEXIN [mailto:KAGEL@bloomberg.net]
[quoted text clipped - 57 lines]
> > 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

sending to informix-list
Navdeep Virk - 23 Feb 2005 23:21 GMT
Everett  ,

You are right , the syntax worked as it is ,However for the life of me I
cannot figure out what kinda of error I was encountering . I kept on getting
a runtime error ,something like syntax error etc . Could be I changed the
code to test too often and kept making different mistakes like not giving
the correct file name as argument  etc.

Thanks to all ,

Navdeep

----- Original Message -----
From: "Everett Mills" <eemills@nationalbeef.com>
To: <informix-list@iiug.org>
Sent: Wednesday, February 23, 2005 4:30 PM
Subject: RE: LOAD In 4GL Problems

> Art & Navdeep-
> Navdeep never said what the behavior of his application was; he
[quoted text clipped - 89 lines]
>
> sending to informix-list

sending to informix-list
Jonathan Leffler - 25 Feb 2005 08:00 GMT
> I tried to load rows into a temp table in a 4GL program ,where I am passing
> the filename as an argument .
[quoted text clipped - 5 lines]
>
> This did not work ,

Why not - what was the error?

> So I tried
>
[quoted text clipped - 12 lines]
>
> This also did not work .

The server has no knowledge of either LOAD or UNLOAD; they are
inherently non-preparable and hence non-executable.

They are simulated in I4GL and ISQL and DB-Access (and SQLCMD and
Aubit4GL and ...).

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

Use:
LET ins = "INSERT INTO tb_sp"
LOAD FROM g_filename ins

(A tb_sp is a bit bigger than a t_sp - otherwise, there's no difference.)

> 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

See above.

Signature

Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.