4GL CONSTRUCT...
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
INFORMIX 4GL Version 4.11.UC4 et 6.04.UC2 I want to generate a "NOT MATCHES" for a column of type char... I thing there is a bug, CONSTRUCT can generate a "MATCHES" but not a "NOT MATCHES"... example: SELECT ...... WHERE name NOT MATCHES "Martin*" CONSTRUCT generate SELECT.... WHERE name <> "Martin*" Any help appreciated! Marc
Marc Lincé wrote: > INFORMIX 4GL Version 4.11.UC4 et 6.04.UC2 > > I want to generate a "NOT MATCHES" for a column of type char... > I thing there is a bug, CONSTRUCT can generate a "MATCHES" but not a > "NOT MATCHES"... > > example: SELECT ...... WHERE name NOT MATCHES "Martin*" > CONSTRUCT generate SELECT.... WHERE name <> "Martin*" > > Any help appreciated! One person's bug is another person's feature :-( That's the way it is designed, so the problem is with the design rather than the implementation. If it ever gets fixed, we'd also want to be able to type: *510*|*415* and get (phone matches "*510*" or phone matches "*415*") There are some other changes that could usefully be made to CONSTRUCT too. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>
Marc Lincé wrote: > INFORMIX 4GL Version 4.11.UC4 et 6.04.UC2 > > I want to generate a "NOT MATCHES" for a column of type char... > I thing there is a bug, CONSTRUCT can generate a "MATCHES" but not a > "NOT MATCHES"... > > example: SELECT ...... WHERE name NOT MATCHES "Martin*" > CONSTRUCT generate SELECT.... WHERE name <> "Martin*" > > Any help appreciated! One person's bug is another person's feature :-( That's the way it is designed, so the problem is with the design rather than the implementation. If it ever gets fixed, we'd also want to be able to type: *510*|*415* and get (phone matches "*510*" or phone matches "*415*") There are some other changes that could usefully be made to CONSTRUCT too. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>
Although the 4GL construct statement is one of the best parts of 4GL and a greate idea that few others (if any) have emulated there are several limitations to it's capabilities. You have come across one of them. There is a possible solution however, although it does involve a little programming. I assume this is what the user typed into the field: <>Martin* and this is what the construct statement itself created: name <> "Martin*" Of course this is "wrong". However it is easy enough to scan through the char variable looking for <> followed by a set of quotes. Then look inside the quotes and see if you find a ? or * (and possibly [ ] if you want to support those). If you do replace the <> with matches and you are done. There may be cases where this doesn't work, but I doubt it. Just test a little and see. You can do all this scaning and replacing of characters with a 4GL function only. Some may say you should use a C function because 4GL is so slow for this kind of code. 4GL is plenty fast enough though, so just do it. On Wed, 31 Mar 1999 11:53:57 +0200, "Marc Lincé" <mjl@ciger.be> wrote: >INFORMIX 4GL Version 4.11.UC4 et 6.04.UC2 > >I want to generate a "NOT MATCHES" for a column of type char... >I thing there is a bug, CONSTRUCT can generate a "MATCHES" but not a >"NOT MATCHES"... > >example: SELECT ...... WHERE name NOT MATCHES "Martin*" > CONSTRUCT generate SELECT.... WHERE name <> "Martin*" > >Any help appreciated! > >Marc > > Nils Myklebust NM Data AS Norway E-mail: Nils.Myklebust@nmdata.com FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html (Now with ODBC info under "Third party products".)
Although the 4GL construct statement is one of the best parts of 4GL and a greate idea that few others (if any) have emulated there are several limitations to it's capabilities. You have come across one of them. There is a possible solution however, although it does involve a little programming. I assume this is what the user typed into the field: <>Martin* and this is what the construct statement itself created: name <> "Martin*" Of course this is "wrong". However it is easy enough to scan through the char variable looking for <> followed by a set of quotes. Then look inside the quotes and see if you find a ? or * (and possibly [ ] if you want to support those). If you do replace the <> with matches and you are done. There may be cases where this doesn't work, but I doubt it. Just test a little and see. You can do all this scaning and replacing of characters with a 4GL function only. Some may say you should use a C function because 4GL is so slow for this kind of code. 4GL is plenty fast enough though, so just do it. On Wed, 31 Mar 1999 11:53:57 +0200, "Marc Lincé" <mjl@ciger.be> wrote: >INFORMIX 4GL Version 4.11.UC4 et 6.04.UC2 > >I want to generate a "NOT MATCHES" for a column of type char... >I thing there is a bug, CONSTRUCT can generate a "MATCHES" but not a >"NOT MATCHES"... > >example: SELECT ...... WHERE name NOT MATCHES "Martin*" > CONSTRUCT generate SELECT.... WHERE name <> "Martin*" > >Any help appreciated! > >Marc > > Nils Myklebust NM Data AS Norway E-mail: Nils.Myklebust@nmdata.com FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html (Now with ODBC info under "Third party products".)