Hello all,
I'm trying to call the snapshot table function SNAP_GET_TBSP via a jdbc
connection using the following query:
SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1), -1)) AS T
In CLP this works properly, but when I execute it from java, I get the
following SQL exception:
DB2 SQL error: SQLCODE: -873, SQLSTATE: 53090, SQLERRMC: Different
encoding schemes in one statement
If I call a table function that doesn't take a varchar param (like
SNAPSHOT_DBM), the exception doesn't occur. It seems to me that the
varchar parameter of the snapshot function is responsible for the
problem. I already tried to use a prepared statement and provide the
parameter with different encodings, but then I get an exception that a
prepared statement can't be used with this kind of query...
The database version is 8.2; I'm using the IBM db2 universal driver.
Any help or hint is welcome
Hans 8 4533
SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)-!--)--!--,
-1)) AS T
veffen 写道:
Hello all,
I'm trying to call the snapshot table function SNAP_GET_TBSP via a jdbc
connection using the following query:
SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1), -1)) AS T
In CLP this works properly, but when I execute it from java, I get the
following SQL exception:
DB2 SQL error: SQLCODE: -873, SQLSTATE: 53090, SQLERRMC: Different
encoding schemes in one statement
If I call a table function that doesn't take a varchar param (like
SNAPSHOT_DBM), the exception doesn't occur. It seems to me that the
varchar parameter of the snapshot function is responsible for the
problem. I already tried to use a prepared statement and provide the
parameter with different encodings, but then I get an exception that a
prepared statement can't be used with this kind of query...
The database version is 8.2; I'm using the IBM db2 universal driver.
Any help or hint is welcome
Hans
Hello,
ok, thanks for the reply, and sorry, somehow I forgot that closing
brace here, but it was in the original statement. (Otherwise I'd get a
syntax error...)
Here's the statement COPIED from my source code
SELECT T.TBSP_ID FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)),-1))
AS T
No missing braces this time, but the exception is thrown anyway...
And here's the exception, also copied...
DB2 SQL error: SQLCODE: -873, SQLSTATE: 53090, SQLERRMC: Different
encoding schemes in one statement
Any help is appreciated
Hans
Hardy schrieb:
SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)-!--)--!--,
-1)) AS T
veffen 写道:
Hello all,
I'm trying to call the snapshot table function SNAP_GET_TBSP via a jdbc
connection using the following query:
SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1), -1)) AS T
In CLP this works properly, but when I execute it from java, I get the
following SQL exception:
DB2 SQL error: SQLCODE: -873, SQLSTATE: 53090, SQLERRMC: Different
encoding schemes in one statement
If I call a table function that doesn't take a varchar param (like
SNAPSHOT_DBM), the exception doesn't occur. It seems to me that the
varchar parameter of the snapshot function is responsible for the
problem. I already tried to use a prepared statement and provide the
parameter with different encodings, but then I get an exception that a
prepared statement can't be used with this kind of query...
The database version is 8.2; I'm using the IBM db2 universal driver.
Any help or hint is welcome
Hans
veffen wrote:
Hello,
ok, thanks for the reply, and sorry, somehow I forgot that closing
brace here, but it was in the original statement. (Otherwise I'd get a
syntax error...)
Here's the statement COPIED from my source code
SELECT T.TBSP_ID FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)),-1))
AS T
No missing braces this time, but the exception is thrown anyway...
And here's the exception, also copied...
DB2 SQL error: SQLCODE: -873, SQLSTATE: 53090, SQLERRMC: Different
encoding schemes in one statement
Any help is appreciated
Hans
Hardy schrieb:
>SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)-!--)--!--, -1)) AS T
veffen 写道:
Hello all,
I'm trying to call the snapshot table function SNAP_GET_TBSP via a jdbc
connection using the following query:
SELECT * FROM TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1), -1)) AS T
In CLP this works properly, but when I execute it from java, I get the
following SQL exception:
DB2 SQL error: SQLCODE: -873, SQLSTATE: 53090, SQLERRMC: Different
encoding schemes in one statement
If I call a table function that doesn't take a varchar param (like
SNAPSHOT_DBM), the exception doesn't occur. It seems to me that the
varchar parameter of the snapshot function is responsible for the
problem. I already tried to use a prepared statement and provide the
parameter with different encodings, but then I get an exception that a
prepared statement can't be used with this kind of query...
The database version is 8.2; I'm using the IBM db2 universal driver.
Any help or hint is welcome
Hans
Can you post some more code, because it works for me.
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Thanks for your answers.
I did the following to examine your point:
Class.forName("com.ibm.db2.jcc.DB2Driver");
Properties props = new Properties();
props.put("user","****");
props.put("password","****");
// props.put("charSet", "ISO-8859-1");
Connection conn =
DriverManager.getConnection("jdbc:db2://****:****/****",props);
conn.setAutoCommit(false);
Statement st = conn.createStatement();
printResultSet(st.executeQuery("SELECT
DBPARTITIONNUM,REG_VAR_NAME,REG_VAR_VALUE FROM
TABLE(REG_LIST_VARIABLES()) AS T WHERE REG_VAR_NAME = 'DB2CODEPAGE'"));
printResultSet(st.executeQuery("SELECT TYPESCHEMA,TYPENAME,CODEPAGE
FROM SYSCAT.DATATYPES"));
printResultSet(st.executeQuery("SELECT
TABSCHEMA,TABNAME,COLNAME,TYPESCHEMA,TYPENAME,CODE PAGE FROM
SYSCAT.COLUMNS WHERE (CODEPAGE <0) AND (CODEPAGE <819)"));
printResultSet(st.executeQuery("SELECT * FROM
TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)),-1)) AS T"));
The first two statements gave me the following results:
DBPARTITIONNUM REG_VAR_NAME REG_VAR_VALUE
0 DB2CODEPAGE 819
TYPESCHEMA TYPENAME CODEPAGE
SYSIBM BIGINT 0
SYSIBM BLOB 0
SYSIBM BOOLEAN 0
SYSIBM CHARACTER 819
SYSIBM CLOB 819
SYSIBM DATALINK 819
SYSIBM DATE 0
SYSIBM DECIMAL 0
SYSIBM DOUBLE 0
SYSIBM INTEGER 0
SYSIBM LONG VARCHAR 819
SYSIBM REAL 0
SYSIBM REFERENCE 0
SYSIBM SMALLINT 0
SYSIBM TIME 0
SYSIBM TIMESTAMP 0
SYSIBM VARCHAR 819
The third statement issued a list of varchar columns with CCSID 1208
(besides a never-ending list of columns with 819, which I had to
suppress). Do you think (or know) that those columns are responsible
for the exception, because the snap_tbsp function sweeps all columns
and can't cope with those two encoding types in the same statement? But
why does the very same statement work in the CLP, then?
It's a SAP database (hence I don't "play around"...), and everything
works fine, except for my little query in java :-(
Regards,
Hans
Serge Rielau schrieb:
Are you playing with unicode tables in a non unicode database?
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference http://www.ibm.com/software/data/ond...ness/conf2006/
veffen wrote:
Thanks for your answers.
I did the following to examine your point:
Class.forName("com.ibm.db2.jcc.DB2Driver");
Properties props = new Properties();
props.put("user","****");
props.put("password","****");
// props.put("charSet", "ISO-8859-1");
Connection conn =
DriverManager.getConnection("jdbc:db2://****:****/****",props);
conn.setAutoCommit(false);
Statement st = conn.createStatement();
printResultSet(st.executeQuery("SELECT
DBPARTITIONNUM,REG_VAR_NAME,REG_VAR_VALUE FROM
TABLE(REG_LIST_VARIABLES()) AS T WHERE REG_VAR_NAME = 'DB2CODEPAGE'"));
printResultSet(st.executeQuery("SELECT TYPESCHEMA,TYPENAME,CODEPAGE
FROM SYSCAT.DATATYPES"));
printResultSet(st.executeQuery("SELECT
TABSCHEMA,TABNAME,COLNAME,TYPESCHEMA,TYPENAME,CODE PAGE FROM
SYSCAT.COLUMNS WHERE (CODEPAGE <0) AND (CODEPAGE <819)"));
printResultSet(st.executeQuery("SELECT * FROM
TABLE(SNAP_GET_TBSP(CAST(NULL AS VARCHAR(1)),-1)) AS T"));
The first two statements gave me the following results:
DBPARTITIONNUM REG_VAR_NAME REG_VAR_VALUE
0 DB2CODEPAGE 819
TYPESCHEMA TYPENAME CODEPAGE
SYSIBM BIGINT 0
SYSIBM BLOB 0
SYSIBM BOOLEAN 0
SYSIBM CHARACTER 819
SYSIBM CLOB 819
SYSIBM DATALINK 819
SYSIBM DATE 0
SYSIBM DECIMAL 0
SYSIBM DOUBLE 0
SYSIBM INTEGER 0
SYSIBM LONG VARCHAR 819
SYSIBM REAL 0
SYSIBM REFERENCE 0
SYSIBM SMALLINT 0
SYSIBM TIME 0
SYSIBM TIMESTAMP 0
SYSIBM VARCHAR 819
The third statement issued a list of varchar columns with CCSID 1208
(besides a never-ending list of columns with 819, which I had to
suppress). Do you think (or know) that those columns are responsible
for the exception, because the snap_tbsp function sweeps all columns
and can't cope with those two encoding types in the same statement? But
why does the very same statement work in the CLP, then?
It's a SAP database (hence I don't "play around"...), and everything
works fine, except for my little query in java :-(
Yep.. One of these special SAP thingies.
try:
SELECT T.* FROM SYSIBM.SYSDUMMY1, TABLE(SNAP_GET_TBSP(CAST(NULL AS
VARCHAR(1)),-1)) AS T
or
SELECT T.* FROM SYSIBM.SYSDUMMY1, TABLE(SNAP_GET_TBSP(CAST(NULL AS
VARCHAR(1) FOR SBCS DATA ),-1)) AS T
What's happening here is that DB2 needs to decide whether a statement
should be Unicode or DB codepage. The first thing the parser runs into
is likely the CAST. It decides (for SAP) to go with Unicode and then you
get swear words when it discovers that SNAP_GET_TBSP isn't Unicode.
The first fix pre-empts the CAST with SYSIBM.SYSDUMMY1 (a view in DB
code page), so DB2 commits to db-codepage.
The second fix (tries) the same trick by influencing the CAST itself.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference http://www.ibm.com/software/data/ond...ness/conf2006/
PS: The reason why it works from CLP is that CLP is not a unicode
client. All this fancyness kicks in for Unicode clients to allow Unicode
literals and such to talk to unicode tables unpestered.
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference http://www.ibm.com/software/data/ond...ness/conf2006/
It works! Thanks so much! And thanks for the explanations.
Best regards,
Hans
Serge Rielau schrieb:
PS: The reason why it works from CLP is that CLP is not a unicode
client. All this fancyness kicks in for Unicode clients to allow Unicode
literals and such to talk to unicode tables unpestered.
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference http://www.ibm.com/software/data/ond...ness/conf2006/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nils Valentin |
last post by:
Hi MySQL Fans ;-),
Is it possible that the 3.08 series allows to connect to 4.0.14 versions but
not to the 4.1 alpha-versions ?
I get belows error when tryig to connect from DbVisualizer which...
|
by: John Gibson |
last post by:
Hi, all.
I have a table which is continually updated with the latest totals. I
would like to take snapshots of some of the data in that table and store
it in a second table to run statistics on...
|
by: Jean-Marc Blaise |
last post by:
Dear all,
It seems there is a problem with some snapshot table functions, if you try
to divide by some element that is unset or equal to 0. This generates a trap
file with the db2fmp.exe...
|
by: Prince Kumar |
last post by:
Is there anyway to display the partition number while taking snapshot
on all the partitions (-2) using the snapshot function?
ex,
select TABLESPACE_NAME, TOTAL_PAGES from...
|
by: Civilian_Target |
last post by:
Is there any way in DB2 to automate the taking of a snapshot, for
example, a function that will cause a db2 snapshot to be taken every 5
minutes and written to a uniquely named file?
Am I better...
|
by: Ina Schmitz |
last post by:
Hello,
I would like to get the logical and physical reads for every sql statement
executed.
Thatfore, I used the command "db2 get snapshot for dynamic sql on
<mydatabase>". There, I could see...
|
by: BuddhaBuddy |
last post by:
Platform is DB2/NT 7.2.9
The table was created like this:
CREATE TABLE MYTEST (
MYTESTOID bigint not null primary key,
FK_OTHEROID bigint not null references other,
FK_ANOTHEROID bigint not...
|
by: PaulR |
last post by:
Hi all,
(DB2 LUW 8.2)
I'm just trying to write a little widget to capture lock wait details
(when they occur).
i.e when a lock-wait occurs, simply record the 2 statements involved
in the...
|
by: MPD |
last post by:
Hi
How can I create a job in sql agent to create a new snapshot every hour?
I have, for eg a T-SQL that does it manually.
create database Snapshotter_snap_20070418_1821 on
( name =...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |