Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2012
    Posts
    25

    Question Unanswered: Is it static sql ??

    DB2 9.7 new Feature - Access plan reuse ensures consistent. It is usefull for static sql queries.
    What i don't understand what is static sql.
    Is the following query a static query?? The ? part is filled at runtime.

    - select name from Persons where vorname=?



    Another question:
    Is the new functionality also good for dynamic queries. The same dynamic query may ocur again.

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Briefly stated, a static query is one that is not parsed/interpreted/optimized at runtime.
    So indeed, static SQL can still contain parameter markers (like in your vorname=... example) for which the constant values will be passed at runtime.

    There must of course be a "compile" or "bind" or "prepare" phase --once-- after which the optimized query is stored inside DB2 (in a package), and to be called directly later on.

    This is true both on DB2 for z/OS and on DB2 for LUW.
    Last edited by Peter.Vanroose; 06-08-12 at 14:59.
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  3. #3
    Join Date
    Mar 2012
    Posts
    25

    ..

    It means
    " select name from Persons where vorname=? " is not static. Because ? is filled at runtime.
    " select name from Persons where vorname='TestPerson' "would be on the other hand static. Because there is no need to parse or compile it again.

    Right??

  4. #4
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    removed post

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by kotuboy View Post
    It means
    " select name from Persons where vorname=? " is not static. Because ? is filled at runtime.
    " select name from Persons where vorname='TestPerson' "would be on the other hand static. Because there is no need to parse or compile it again.

    Right??
    No.

    Static SQL is compiled once and then put into a package. It can have either form above. Dynamic (not static) can also have both forms from above. It is just executed in an Ad Hoc manner and not stored in the database as a package.

    Andy

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •