syntax of insert like mysql
Posted in 2008
Topics: General Discussion
is there an option to allow :
insert into customer (fname) values ('a'),('b');
thanks.
jack
vomaringo@yahoo.com wrote:
> is there an option to allow :
> insert into customer (fname) values ('a'),('b');>
No, using pure SQL you'll need two inserts to do that. If you are using
a host language you can use an INSERT cursor to insert as many rows as
you like with a single INSERT statement and it's very efficient. An
example in ESQL/C (but you can do similarly with ODBC, JDBC, etc.):
$char a_value[2];
...
$BEGIN WORK;
$PREPARE ins_s FROM "INSERT INTO customer (fname) VALUES ( ? )";
$DECLARE ins_c CURSOR FOR ins_s;
for (rec=0; rec=num_in_array; rec++) {
strcpy( a_value, value_array[rec] );
$PUT ins_c USING :a_value;
}
$FLUSH ins_c;
$COMMIT WORK;
Art S. Kagel
Oninit
> thanks.
> jack
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
>
Art S. Kagel (Oninit LLC) wrote:
> vomaringo@yahoo.com wrote:
>> is there an option to allow :
>> insert into customer (fname) values ('a'),('b');>>
>
> No, using pure SQL you'll need two inserts to do that.
I have seen some creative uses of UNION ALL to get this done in some
products. Don't know whether it works in IDS...
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab