Open davis-junior opened 5 years ago
This issue still applies as of version 2.0.5.12-0.
The extended message text for SQLCODE -5024 is this:
Message ID . . . . . . . . . : SQL5024
Message file . . . . . . . . : QSQLMSG
Library . . . . . . . . . : QSYS
Message . . . . : Variable &1 not character, UCS-2 graphic, or UTF-16
graphic.
Cause . . . . . : Host variable or global variable &1 is not defined as
character, UCS-2 graphic, or UTF-16 graphic. Host variables in a precompiled
program or REXX procedure or global variables must be character, UCS-2
graphic, or UTF-16 graphic if used as:
-- The statement string in a PREPARE or EXECUTE IMMEDIATE statement.
-- The table name in a DESCRIBE TABLE statement.
-- The procedure name in a CALL statement.
-- The server name, authorization name, or password in a CONNECT, SET
CONNECTION, RELEASE, DISCONNECT, SET ENCRYPTION PASSWORD, or SET SESSION
AUTHORIZATION statement.
-- The special register value in a SET special register statement such as
SET PATH, SET SCHEMA, or SET CURRENT DECFLOAT ROUNDING MODE.
-- The SQLSTATE value or signal information value in a SIGNAL statement.
-- A descriptor name.
Recovery . . . : Specify a variable that is character, UCS-2 graphic, or
UTF-16 graphic. Try the request again.
For some reason, the database is not handling the string properly when passed as UTF-8. It does seem to work if I hack it to pass as SQL_C_WCHAR (UTF-16) as noted from the message help, but that would be difficult to handle for just SET
statements...
I did find that there is a connection attribute that does exactly what is wanted and works: SQL_ATTR_DBC_DEFAULT_LIB
. Mapping that to SQL_ATTR_CURRENT_SCHEMA allows the existing code to work properly, though explicitly calling SET SCHEMA
via cursor.execute()
still doesn't.
Let me know if the set_current_schema()
fix is enough and I can fix that up.
Using ibm-db 2.0.5.9 from IBM i repo.
Connection.set_current_schema() fails with exception:
Internally, it executes the prepared statement "set current schema = ?" with proper parameter, and that's where the exception is thrown. A workaround is to concatenate directly (improper).
Here's a few tests, just change "schema" to an existing one on the system. The first three fail with the above exception.