[comp.databases] Informix-4GL handling of same variable- and column name

harry@cssoff.syssup.tds.philips.nl (Harry Weseman) (09/26/90)

Hi Informix-4GL programmers,

It is possible that the questions I am about to ask has been asked
before; if so, I apologize, I started reading this newsgroup  not long
ago.

We are using Informix-4GL for some development of our own, and we have
encountered the following problem. Suppose you have defined a local
variable, as follows: 

	DEFINE total_qty SMALLINT

and somewhere further down the program, there is:

	DECLARE my_cursor CURSOR FOR
		SELECT col1, col2, total_qty, col3
		FROM tab1

	FOREACH my_cursor INTO some_array
		.....
	END FOREACH

Compilation is okay, but the execution halts with error -201 on the DECLARE 
line, saying: "A syntax error has occurred".

I can understand that Informix-4GL has a problem with the use of the same
name for a local variable and a table column, but why does it confuse the
poor programmer so much in finding out what is wrong!

Even worse is the following, roughly similar case.

Suppose, there is a table called tab, with the folowing columns:

	col1	CHAR[20]
	col2	CHAR[20]
	col3	SMALLINT

with the following contents:

	values1-1|values1-2|1|
	values2-1|values2-2|1|
	values3-1|values3-2|1|

And this is the 4GL program:

	DATABASE tst

	MAIN

	DEFINE col3 SMALLINT

		UPDATE tab
			SET col1 = col2
			WHERE col3 = 1
	END MAIN

Compilation: no errors; execution: no problems (no syntax error this time!)
results: the UPDATE has not been carried out!

In reality, the DEFINE and the UPDATE statement were hundreds of statements
apart, so it was not obvious what the problem was.

The problem is overcome by qualifying the column-name, or using an at-sign;
but why does Informix-4GL allow such things in the first place, and why is
it inconsistent about it?

My questions are: 1) what is the view of you experienced Informix-4GL people;
2) is this improved in Informix-4GL release 4?

Kind regards,

Harry Weseman


Harry Weseman - Philips Information Systems Nederland B.V. - The Netherlands
Tel  : +31 (0)55 - 43 2529            |  UUCP  :  ...!hp4nl!philapd!cssnl!harry
Fax  : +31 (0)55 - 43 3487            |  NET   :  harry@syssup.tds.philips.nl
.... isn't MIPS an abbreviation of Meaningless Instructions Per Second? .....