| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

09-26-06, 14:30
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Ohio
Posts: 38
|
|
|
Db2 SQL Cache
|
|
This may be a silly question, but I don't seem to know where to find the answer.
We saw some SQL errors in our log today (SQL0404N A string in the UPDATE or INSERT statement is too long for column ""), but we didn't know what SQL was being executed to cause them. Is there a way to see what SQL has been issued recently against a db2 database (ver 8.2 - unix) ? In oracle, we can query v$sql to see what SQL is still in the statement cache... is there anything similar in DB2?
Thanks!
Jodie
|
|

09-26-06, 14:48
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
There is a way to see it, but only if it is a valid statement and added to package cache. You can see the statements in package cache with a "get snapshot for dynamic sql" or db2pd command. See the Command Reference manual for details on both of these commands.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

09-26-06, 14:51
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Ohio
Posts: 38
|
|
|
|
Quote:
|
Originally Posted by Marcus_A
There is a way to see it, but only if it is a valid statement and added to package cache. You can see the statements in package cache with a "get snapshot for dynamic sql" or db2pd command. See the Command Reference manual for details on both of these commands.
|
If it's a valid statement (which I believe it was), would it automatically be added to the package cache?
|
|

09-26-06, 15:02
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
|
Originally Posted by jodie
If it's a valid statement (which I believe it was), would it automatically be added to the package cache?
|
Yes, although in certain circumstances it could be bumped out by other subsequent statements.
If the error was a runtime error, then the statement probably would be in package cache, but if the error was detected during SQL statement compilation, then it would not be in package cache.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

09-26-06, 15:18
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Ohio
Posts: 38
|
|
Quote:
|
Originally Posted by Marcus_A
Yes, although in certain circumstances it could be bumped out by other subsequent statements.
If the error was a runtime error, then the statement probably would be in package cache, but if the error was detected during SQL statement compilation, then it would not be in package cache.
|
Thanks...
I tried the "db2 get snapshot for dynamic sql", and saw all of the SQL. Unfortunately, all of the variables were "?", indicating bind variables (which is a good thing), but is there any way to see what the variables have been for recent executions?
|
|

09-26-06, 16:15
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Not with a snaphsot. You may be able to see the actual statements with DB2 Query Patroller, which I believe is priced as a separate license.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

09-26-06, 16:45
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Ohio
Posts: 38
|
|
Figures... Thanks for the information.
|
|

09-26-06, 17:14
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
As far as I know, Query Patroller doesn't capture bind variable values anyway.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|