Re: ESQL/C: why 2 short ints for indicator variables?
Posted in 1994
>Date: Mon, 21 Feb 1994 17:31:56 +0100 (GMT+0100) >From: "Centr. Instytut Ochrony Pracy" <cinsop@frodo.nask.org.pl> >Subject: ESQL/C: why 2 short ints for indicator variables? >X-Informix-List-Id: <list.3553> > >Jonathan Leffler writes: >> First of all, you are responsible for allocating pointers to the sqlind >> stuff; ESQL/C doesn't assign anything there. Therefore, you are >> responsible for freeing it, if you used allocated memory. You might not >> have done for indicator variables. I tend to use pointers to 2 short >> integers, one containing 0, t'other -1. > >Why exactly are you using pointers to 2 short integers? >Having read the documentation I understand the sole purpose >of indicator variable is to indicate whether the value >of the given field is null. Why, then do you need 2 short ints >isn't one enough? > >Pawel Pietrusinski >Centralny Instytut Ochrony Pracy >Warsaw, Poland One indicator is enough for any single field. I use 2 for ALL the fields in all the descriptors. One indicates the field is null; the other indicates the field is not null. It just requires a rethink of what you are using it for. *** WARNING *** Actually, now I think about it more carefully, I have used this technique in connection with INSERT and UPDATE operations, where I am telling the database what's what, rather than for SELECT operations, where the database is telling me what's null and what isn't. For SELECT operations, my 2-variable solution is not merely unhelpful, it is downright lethal -- you have (somewhat belatedly) been warned. Thank you, Pawel, for re-raising the issue. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>