bug: sqlca.sqlerrm is not CLIPPEDable in 4gl
Posted in 2000
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
I want get token from sqlca.sqlerrm and concatenate it with another
text:
assume sqlca.sqlerrm contains "column_name"
LET var = "before ", sqlca.sqlerrm CLIPPED, " after"
but in var is only:
"before column_name"
This is sample code:
---------------------------------------
DATABASE sysmaster
MAIN
DEFINE
lc_errmsg CHAR(80)
WHENEVER ANY ERROR CONTINUE
SELECT non_exist_column
FROM systables
LET lc_errmsg = 'Column "', SQLCA.SQLERRM CLIPPED, '" does not exist.'
DISPLAY lc_errmsg
END MAIN
---------------------------------------
expected result:
Column "non_exist_column" does not exist.
informix result:
Column "non_exist_column"
enviroment:
Informix Dynamic Server Version 7.30.UC8
INFORMIX-4GL Version 6.05.UD2
or
INFORMIX-4GL Version 7.20.UE1
--
Jiří Lisický ČD DATIS Olomouc
e-mail: lisicky@datis.cdrail.cz Nerudova 1
phone: +420-068-472-5496 Olomouc, Czech Republic
>>> čeština ISO-8859-2 Compatible <<<
Jiri Lisicky wrote:
>
> I want get token from sqlca.sqlerrm and concatenate it with another
> text:
>
> assume sqlca.sqlerrm contains "column_name"
> LET var = "before ", sqlca.sqlerrm CLIPPED, " after"
> but in var is only:
> "before column_name"
>
> This is sample code:
> ---------------------------------------
> DATABASE sysmaster
>
> MAIN
> DEFINE
> lc_errmsg CHAR(80)
>
> WHENEVER ANY ERROR CONTINUE
>
> SELECT non_exist_column
> FROM systables>
> LET lc_errmsg = 'Column "', SQLCA.SQLERRM CLIPPED, '" does not exist.'
> DISPLAY lc_errmsg
> END MAIN
> ---------------------------------------
> expected result:
> Column "non_exist_column" does not exist.
> informix result:
> Column "non_exist_column"
>
> enviroment:
> Informix Dynamic Server Version 7.30.UC8
> INFORMIX-4GL Version 6.05.UD2
> or
> INFORMIX-4GL Version 7.20.UE1
Probably a bug; probably a bug that has been fixed in other
manifestations.
The usual trouble is that there is an ASCII NUL '\\0' somewhere in the
string
which I4GL doesn't expect, and it throws things off. In this case, I'm
pretty
confident that sqlca.sqlerrm contains an ASCII NUL just after the end of
the
column name. I4GL determines the length of the string by starting at
the last
character (SQLCA.SQLERRM[72]) and counting backwards till it gets to a
non-blank.
It then copies the string forwards into the output, and appends the
"does not
exist" part after that. Unfortunately, since there is a NUL in
sqlca.sqlerrm,
as it prints the resulting string using a NUL to terminate the string,
the NUL
in sqlca.sqlerrm causes the tail of the message to be omitted. Such are
the
wonders of 'always blank padded' strings which are not always blank
padded.
Oh, you want a workaround? Hmmm...without dropping into C, that's going
to be
tricky. The I4GL ASCII(0) returns blank unless you're in a report,
which adds
to the complexity of a solution. I'd pass sqlca.sqlerrm into a function
and
then return it, maybe using:
FUNCTION munge_sqlca_sqlerrm(s)
DEFINE s VARCHAR(72)
RETURN s
END FUNCTION
With just a small modicum of luck, that will deal with the problem; the
code
which pushes the VARCHAR onto the return value stack should do strlen()
on the
string, and will encounter the NUL after the column name, and proceed as
we want.
*** UNTESTED ***
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v0.95 -- http://www.perl.com/CPAN
"Windows is NOT a virus: a virus is small and efficient."
Related threads
- Conversion to differeent characters sets
- Problem in changing locale via dbexport/dbimport
- RE: openlink error "Unable to load locale categories"