Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

4GL/Unload problem ..

205 views
Skip to first unread message

SUNIL S. SINGH

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to

H! ....

In a 4gl program I write

UNLOAD TO abc.unl SELECT * FROM tab_chmast

It works fine, but my table name changes dynamically hence I rewrote

LET sql_s = "UNLOAD TO abc.unl SELECT * FROM ",
variable_containing_table_name
PREPARE sql_str FROM sql_s
EXECUTE sql_str

It gives run time error -201 (syntax error)

Any Ideas...

TIA
Sunil

-----------------------<sunil...@tatainfotech.com>-------------------------
. .
. .
. .
. .
. *
. TATA INFOTECH LTD.
. SEEPZ,
. Andheri (E),
SUNIL S. SINGH Mumbai - 400 096,
(Sr. Software Engineer) India.
------------------------------------------------------------------------------


Colin M McGrath

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to

On Thu, 24 Sep 1998, SUNIL S. SINGH wrote:
>
> H! ....
>
> In a 4gl program I write
>
> UNLOAD TO abc.unl SELECT * FROM tab_chmast
>
> It works fine, but my table name changes dynamically hence I rewrote
>
> LET sql_s = "UNLOAD TO abc.unl SELECT * FROM ",
> variable_containing_table_name
> PREPARE sql_str FROM sql_s
> EXECUTE sql_str
>
> It gives run time error -201 (syntax error)
>
> Any Ideas...
>
> TIA
> Sunil

You are not allowed to prepare an unload statement. (RTFM)
But you can do the following:

let tab = "some_table"
let unl_tab = tab clipped, ".unl"
let str = "select * from ", tab, " where cnt_nbr = 'XYZ'"
unload to unl_tab str


--
______________________________________________________________________
| Colin McGrath c...@trac3000.ueci.com |
| Raytheon Engineers & Constructors, Inc. (215) 422-4144 |
| Phila, PA, USA |
| Any opinions I state are my own and not necessarily of my employer |
|____________________________________________________________________|


Peter Lancashire

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to
SUNIL S. SINGH wrote:
>
> H! ....
>
> In a 4gl program I write
>
> UNLOAD TO abc.unl SELECT * FROM tab_chmast
>
> It works fine, but my table name changes dynamically hence I rewrote
>
> LET sql_s = "UNLOAD TO abc.unl SELECT * FROM ",
> variable_containing_table_name
> PREPARE sql_str FROM sql_s
> EXECUTE sql_str
>
> It gives run time error -201 (syntax error)
>
> Any Ideas...
>
> TIA
> Sunil
You cannot prepare an UNLOAD statement. It is something specific to
DB-Access (note the DB label against it in the SQL Syntax manual).

You can write in 4GL:

LET mystring = "SELECT * FROM tab_chmast"
UNLOAD TO "abc.unl" mystring
--
Peter Lancashire
Information Systems Specialist, Bayer plc
Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK
Tel: +44-1635-562258, Fax: +44-1635-562281
---
If all else fails, read the instructions AND the release notes.
All opinions are my own and not those of Bayer plc.
My Internet plumbing does not allow me to mail and post news together.
Sorry.
---
Join Infuse, the UK Informix User Group at http://www.infuse.org.uk/

Sadagopan, Sathish

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to

You cannot prepare an UNLOAD or LOAD statement.

HTH
Sathish

> ----------
> From: SUNIL S. SINGH[SMTP:sunil...@tatainfotech.com]
> Sent: Thursday, September 24, 1998 3:23 AM
> To: informix list
> Subject: 4GL/Unload problem ..


>
> H! ....
>
> In a 4gl program I write
>
> UNLOAD TO abc.unl SELECT * FROM tab_chmast
>
> It works fine, but my table name changes dynamically hence I rewrote
>
> LET sql_s = "UNLOAD TO abc.unl SELECT * FROM ",
> variable_containing_table_name
> PREPARE sql_str FROM sql_s
> EXECUTE sql_str
>
> It gives run time error -201 (syntax error)
>
> Any Ideas...
>
> TIA
> Sunil
>

> -----------------------<sunil...@tatainfotech.com>---------------------

Jonathan Knight

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to

Check the manual. You cannot use unload in a prepared statement. See the
Prepare entry in the 4GL reference manual.

Jon

Alex Dron

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to
SUNIL S. SINGH (sunil...@tatainfotech.com) wrote:
:
: H! ....

:
: In a 4gl program I write
:
: UNLOAD TO abc.unl SELECT * FROM tab_chmast
:
: It works fine, but my table name changes dynamically hence I rewrote
:
: LET sql_s = "UNLOAD TO abc.unl SELECT * FROM ",
: variable_containing_table_name
: PREPARE sql_str FROM sql_s
: EXECUTE sql_str

You cannot prepare unload statement in 4GL.

But you can instead use string variable for select clause:

LET vv = "select * from ",var_tab_name
UNLOAD TO abc.unl vv

: TIA
: Sunil
:

--
Dron Alexander, IDS

Wu

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to

Hi there,

You cannot prepare an "unload" statement, that's why you have a syntax error
(-201) ...

SUNIL S. SINGH wrote:

> H! ....
>
> In a 4gl program I write
>
> UNLOAD TO abc.unl SELECT * FROM tab_chmast
>
> It works fine, but my table name changes dynamically hence I rewrote
>
> LET sql_s = "UNLOAD TO abc.unl SELECT * FROM ",
> variable_containing_table_name
> PREPARE sql_str FROM sql_s
> EXECUTE sql_str
>

Art S. Kagel

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to
Wu wrote:
>
> Hi there,
>
> You cannot prepare an "unload" statement, that's why you have a syntax error
> (-201) ...

Just to be clear. The reason you cannot prepare an UNLOAD statement is
that it is not a SQL statement it is a 4GL builtin command which was
included to support the same syntax as the UNLOAD built into dbaccess.

0 new messages