Re: Question about "prepare statements"
Posted in 1993
>Date: Wed, 22 Dec 93 09:54:39 GMT
>From: andy_d@rapier.demon.co.uk (A. J. Dibbins)
>Subject: Question about "prepare statements"
>X-Informix-List-Id: <list.3251>
>
>Hi,
>
>My question is this, I am assured that both of these examples work on most
>machines, but my Sun running Sunos 4.1.1 and I4GL v4.0 complains about the
>first example.
>
>Eg1
>
> prepare s1 from "insert into fred values (?,?,?,?)
> execute s1 using "andy_d","CUSTOMER","JUNK","JUNK")
>
>Eg2
>
> define str char(80)
>
> let str = "insert into fred values (?,?,?,?)"
> prepare s1 from str
> execute s1 using "andy_d","CUSTOMER","JUNK","JUNK"
>
>The manual uses example 2 style code, but I am assured by the programmer
>that Eg1 has worked on other machines/setups.
How seriously are we to take your punctuation? Example 1 should be failing
to compile with an unmatched quote error on the prepare line and an
unwanted parenthesis on the second. When these errors are corrected, and
using 4.11.UC1 I4GL against a 5.01.UC2 OnLine engine, both versions work
correctly. What are you doing still running antiques?
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
Test code:
main
define str char(80), c1, c2, c3, c4 char(10)
create database ex01
create table fred
(
col01 char(10),
col02 char(10),
col03 char(10),
col04 char(10)
)
prepare s1 from "insert into fred values (?,?,?,?)"
execute s1 using "andy_d","CUSTOMER","JUNK","JUNK"
let str = "insert into fred values (?,?,?,?)"
prepare s2 from str
execute s2 using "andy_d","CUSTOMER","JUNK","JUNK"
declare c cursor for select * from fred
foreach c into c1, c2, c3, c4
display c1, c2, c3, c4
end foreach
close database
drop database ex01
end main