Re: NULL generating "Sintax Error"
Posted in 2003
Topics: SQL Development & Query Writing, Data Types & Schema Design
Gregg. Do you know wich engines do support casting? Vergara "Gregg Walker" <gregg@rrmca.com> wrote in message news:<_6KIa.1055807$Zo.258000@sccrnsc03>... > If you want to return an null value constant in a select statement then your > engine must support casting. > > Assuming your engine allows casting you can use the following if you want a > null of type integer. > > SELECT null::integer FROM table; > > The database can't return a null without knowing what data type to use for > the null value. > > If your engine does not support casting then you could simulate by creating > a table with different columns for the different data types you would need > null values for. You could insert one row with null values and join to this > table in your queries where you need a null value returned. > > Gregg Walker > > "Jorge Vergara" <jlvergara@sispro.com.br> wrote in message > news:2f175445.0306200556.4ebda7f8@posting.google.com... > > Hello All. > > > > The query bellow generates a sintax error: > > SELECT 'ADP' > > , '!' > > , null > > , '6.1.1.06' > > #^ > > # 201: A syntax error has occurred. > > # > > , '!' > > , '!' > > , '!' > > , '!' > > , GF_CTOP_CTB.CD_CTOP_CTB > > > > FROM GF_CTOP_CTB > > > > If I replace the word "null" with "''" the statement runs without > > error. > > Is there any configuration parameter I could manipulate that would > > allow me to use "null" as a constant in my queries? > > > > Thanks in advance. > > > > Jorge Vergara
Jorge Vergara wrote: > Do you know which engines do support casting? IDS 9.x. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
I believe was first available in IDS.2000 with Universal Option which is now included in all version 9.x engines. Someone please correct me if it's available in 7.x versions. Is there a problem using the stored procedure Null() as someone suggested? It seems an elegant solution as you don't have to worry about defining a type for null. It simply returns a null of type char which will then be converted to a null of any other type when fetched into a host variable. Basically it's doing the same as selecting null::char but without the requirement of your engine supporting casting. Gregg Walker "Jorge Vergara" <jlvergara@sispro.com.br> wrote in message news:2f175445.0306261047.676bafe8@posting.google.com... > Gregg. > > Do you know wich engines do support casting? > > Vergara > > "Gregg Walker" <gregg@rrmca.com> wrote in message news:<_6KIa.1055807$Zo.258000@sccrnsc03>... > > If you want to return an null value constant in a select statement then your > > engine must support casting. > > > > Assuming your engine allows casting you can use the following if you want a > > null of type integer. > > > > SELECT null::integer FROM table; > > > > The database can't return a null without knowing what data type to use for > > the null value. > > > > If your engine does not support casting then you could simulate by creating > > a table with different columns for the different data types you would need > > null values for. You could insert one row with null values and join to this > > table in your queries where you need a null value returned. > > > > Gregg Walker > > > > "Jorge Vergara" <jlvergara@sispro.com.br> wrote in message > > news:2f175445.0306200556.4ebda7f8@posting.google.com... > > > Hello All. > > > > > > The query bellow generates a sintax error: > > > SELECT 'ADP' > > > , '!' > > > , null > > > , '6.1.1.06' > > > #^ > > > # 201: A syntax error has occurred. > > > # > > > , '!' > > > , '!' > > > , '!' > > > , '!' > > > , GF_CTOP_CTB.CD_CTOP_CTB > > > > > > FROM GF_CTOP_CTB > > > > > > If I replace the word "null" with "''" the statement runs without > > > error. > > > Is there any configuration parameter I could manipulate that would > > > allow me to use "null" as a constant in my queries? > > > > > > Thanks in advance. > > > > > > Jorge Vergara