× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I know a bit about how the SQL precompiler works :-). Literals in a
static SQL statement (one preceded by an EXEC SQL) will always be
interpreted as the CCSID of the source file member when the precompile was
done. Note that character host variables do not follow this rule. They
will take on the runtime environment's CCSID unless you use the DECLARE
VARIABLE statement to assign them a specific CCSID. This is important to
understand when using dynamic SQL (PREPARE and EXECUTE) using a character
host variable to contain the statement text.

As to where the literals live after the precompile is run, they are saved
as part of the SQL information for the program. They are not directly
accessible to the end user.

Sue Romano
Db2 for IBM i Development


Folks:

Does anyone know the specifics of how the SQL pre-compiler handles text
literals?

I'm particularly interested in how it handles different CCSID's.

Specifically, if I write & compile a program using CCSID 37 with a hard
coded literal (say a regular expression), will the literal work when the
program is run in a different CCSID that isn't aligned with 37?

I wrote & compiled the following code in CCSID 37 ... and it works fine
in that CCSID.

dcl-s var1 varchar (128) inz(' ABCDEFG ');
dcl-s var2 varchar (128);

exec sql
set :var2 = REGEXP_SUBSTR(:var1, '\s+ab(cd)?efg\s*', 1, 1,'i',1);

I then ran it in CCSID 5026 and it also worked ... which I didn't expect
(because lower case characters in 5026 don't align with 37).

On a side note ... where are literals stored when the pre-compiler
generates source? For instance, in the above statement, where would the
regular expression be stored? The only place I can see it is as a comment
in the generated source.

Thanks!

david




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.