IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What is the Difference of Static SQL and Dynamic SQL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
penchalaiaht

New User


Joined: 22 Mar 2006
Posts: 2
Location: Bangalore

PostPosted: Sun Jan 21, 2007 3:11 am
Reply with quote

Hi

could you give me the brief explanation for Static SQL and Dynamic SQL
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Jan 21, 2007 3:55 am
Reply with quote

penchalaiaht,

FWIW (For What It's Worth):
Static has already been evaluated by the SQL optimizer and (hopefully) optimized for the best access to the data.
Dynamic has not (yet) been optimized and, with a throw of the dice, will get be optimized well (real time cpu goes here).
Static is, for instance, a select with all the conditions already decided, the actual values of the selection need to be decided but the structure of the select is already "poured in concrete", so to speak.
Dynamic is pretty much "freeflow", The actual conditions for the select have been determined at execution time.
Static can be "honed" to the most efficient select while, expending cpu real time, dynamic may or may not pick the best access path.

Is that enough?

Bill
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Jan 22, 2007 5:42 am
Reply with quote

Penchalaiaht,

Static SQL is coded in your program and analyzed or prepared at compile time. You cannot change the SQL.

Dynamic SQL is constructed at execution time in working storage as a character field. (This would be done, perhaps, when a column exists in multiple tables or the column name you want to select is unknown until execution time) then prepared and executed. This method is not as efficient as static SQLs and may result in less than the best access to the data.

Please also take a look the links in this previous post Previous Post
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Timestamp difference and its average ... DB2 11
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
No new posts Difference when accessing dataset in ... JCL & VSAM 7
Search our Forums:

Back to Top