Dynamic SQL using parameter markers vs. embedded SQL using host variables
Dan Bale <dan.bale-EkiVQpMPPJH8R359/[email protected]>
| Newsgroups | gmane.comp.lang.as400.rpg |
|---|---|
| Message-ID | <CO1PR15MB490603729AFD6E14733FAF3F9E09A@CO1PR15MB4906.namprd15.prod.outlook.com> |
We have a lot of embedded SQL that uses host variables, e.g.: Select a, b, c from custmast where c = :hostc; It has been suggested to me that this can cause performance issues because the plan cache may need to be "rebuilt"(?), so we should consider replacing these type of queries with dynamic SQL using parameter markers, e.g. SQLStatement = 'Select a, b, c from custmast where c = ?'; Exec SQL Prepare P1 from :SQLStatement; Exec SQL Declare C1 cursor for P1; Exec SQL Open C1 USING :hostc; Is anyone aware of a resource that describes this in detail? Maybe also provide test cases that prove performance gains? (Or not?) - Dan Bale *** CONFIDENTIALITY NOTICE: The information contained in this communication may be confidential, and is intended only for the use of the recipients named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately and delete the original message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender. *** -- This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options, visit: https://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l. Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.