Re: ESQL/C insert statement problem
Posted in 1991
Path: emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!pyramid!infmx!johnl
From: johnl@informix.com (Jonathan Leffler)
Newsgroups: comp.databases.informix
Summary: There is a bug in the manual
Message-ID: <1991Dec6.174109.10282@informix.com>
Date: 6 Dec 91 17:41:09 GMT
References: <1991Dec05.192501.13636@dircon.co.uk>
Sender: JOnathan Leffler (johnl@asterix)
Organization: Informix Software, Inc.
In article <1991Dec05.192501.13636@dircon.co.uk> uaa1006@dircon.co.uk (Peter Miles) writes:
>
>The manual for Informix-Esql/C (Version 4.0) says that if you
>have a structure defined as follows...
>
>$struct foo
>{
> char name[20];
> char address[20];
> char phone[20];
>} bar;
>
>...you can use the following statement to add a record to a
>table...
>
> $insert $foo into customer;
>
>(where customer is the table name).
>
>However, when I try this, I get the following compile time error:
>
> Syntax error on keyword or symbol '$'. (sqlhost.y)
>
>I assume the '$' being complained about is the one on the $foo
>part of the statement. However, removing the $ gets ...
>
> Syntax error on identifier 'foo'.
>
>Is this a bug, or am I doing something wrong?
>
> -- Pete
>--
>Pete Miles uaa1006@dircon.co.uk
> ...uknet!dircon!uaa1006
There is a bug in the manual.
You should use the syntax:
$ insert into customer values ($foo.name, $foo.address, $foo.phone);
This is guaranteed.
Try:
$ insert into customer values ($foo.*);
It might work, but don't complain if it doesn't.
Incidentally, if your database table is:
create table foo (name char(20), address char(20), phone char(20));
your structure declaration should be:
$struct foo
{
char name[21];
char address[21];
char phone[21];
} bar;
--
-------------------------------------------------------------------
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>