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.

 
Go Back  dBforums > Database Server Software > DB2 > Db2 SQL Cache

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-26-06, 14:30
jodie jodie is offline
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
Reply With Quote
  #2 (permalink)  
Old 09-26-06, 14:48
Marcus_A Marcus_A is offline
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
Reply With Quote
  #3 (permalink)  
Old 09-26-06, 14:51
jodie jodie is offline
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?
Reply With Quote
  #4 (permalink)  
Old 09-26-06, 15:02
Marcus_A Marcus_A is offline
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
Reply With Quote
  #5 (permalink)  
Old 09-26-06, 15:18
jodie jodie is offline
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?
Reply With Quote
  #6 (permalink)  
Old 09-26-06, 16:15
Marcus_A Marcus_A is offline
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
Reply With Quote
  #7 (permalink)  
Old 09-26-06, 16:45
jodie jodie is offline
Registered User
 
Join Date: Aug 2003
Location: Ohio
Posts: 38
Figures... Thanks for the information.
Reply With Quote
  #8 (permalink)  
Old 09-26-06, 17:14
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
As far as I know, Query Patroller doesn't capture bind variable values anyway.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On