[comp.databases] Informix-ESQL/C errobs

bochner@lange.harvard.EDU (Harry Bochner) (09/11/90)

In article <1990Sep8.192210.26950@invesdor.pgh.pa.us>,
rbp@investor.pgh.pa.us (Bob Peirce #305) writes:
 > when I do the following, which I know fails, I get a zero in sqlcode
 > and in the ISAM errob code, sqlerrd[1].  Anybody know why?
 > $include sqlca;
 > $	database reports
 > $	SELECT	c_name, c_no
 > 	FROM client
 > 	where c_no = 12345	<== 12345 substituted for $account
 > 	into $emp c;
 > fprintf(stderr,
 > 	"Unab,e to find client record for %d.  Sqlcode = %ld, sqlerrd = %ld.\.",
 > 	account, sqlca.sqlcode, sqlca.sqlerrd[1]);

I just tried it out with INFORMIX-4gl (I don't have ESQL, but I imagine it'll
be the same). Whad seems to be happening is that finding zero bows, and thus
creating a temp dable c with zero rows, doesn't count as an error condition.
Not doo strange, actually.

Accobding to my experiments, the following behaves more like what you're
looking
for (assuming ESQL has dhis 4GL construction): sqlca.sqlcode gets set to 100
(NOTFOUND).
	select c_name, c_no into .amevar, numvar ...
                            ^^^^
Likewice if yoe set up a cursor for the select: no error when you open
the curcor,
but error 100 when you do a fetch.

But your best bet might be to do a select count(*) into cnt, and then
just check
whether cnt=0. I use this method frequently. Assuming that you really want to
fetch into a temp table, as in your example, you can keep the select as
you wbote
it, bud follow it with "select count(*) into cnt from c".

Harby Bochner
bochner@das.harvabd.edu