Re: IF <var> THEN
Posted in 1996
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
Manel Falc' wrote: > > Is this expression correct ?: > > if SQLCA.SQLCODE then > ... > > or it must be: > > if SQLCA.SQLCODE <> 0 then > ... > > Which numeric types can we use with the first expression ?. > It seems it is correct for smallint and integer types and > I prefer it but I don't know if it is correct for all rapid/executable > versions. I take it you are referring to Informix-4GL and Informix-4GL RDS. Both examples are correct. The first, IMO, is often more readable, especially if the variable is named carefully. For example: IF update_complete THEN ....continue ELSE ....we had an error END IF This form of the syntax requires the use of a BOOLEAN type. Now as discussed on this group earlier, there IS NO BOOLEAN data type in Informix. So you can use either SMALLINT or INTEGER. But why use INT and waste 2bytes, when SMALLINT will do. The boolean values then recognised by Informix in this context are: 0 (zero) = FALSE None-Zero = TRUE (this includes -ve numbers) When initialising such variables you can use two system global variables called TRUE and FALSE, which assign the values 1 (one) and 0 (zero) respectivly. The fact that -ve numbers are TRUE means that both your examples will work, and both will work in all versions of Informix-4GL, whether RDS or fully- compiled. Hope that covers it for you, -- Mark. +-------------------------------------------------------------------------+ |Mark D. Stock - The West Solutions Group http://www.west.co.za | | | |mailto:marks@west.co.za +------------------------------------------------+ |Tel: +27 11 803 2151 |If it doesn't work... force it! | |Fax: +27 11 803 2189 |If it breaks... it needed replacing anyway! | |Cell: +27 83 250 2325 |Well, that's how I code anyway! | +------------------------+------------------------------------------------+