× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Based on statement number 2, I assume you are writing an SQL Stored Procedure on the iSeries...

So, the short answer is no... if you must use dynamic, the parameter markers are set positionally. Even if you were to use the SQLDA, you would still have to specify the values by position.

As for the academic question... yes, when you don't parameterize the query (use markers) then you must prepare the statement each time it is executed. If you use markers, you can isolate the prepare from repeated execute calls.

As for performance differences between the two, it's minimal when you prepare, execute, return. It adds up when you prepare, repeatedly execute and return.


Ryan Hunt wrote:
Microsoft guy here...bear with me.

I am writing a DB2 proc that will utlize dynamic SQL to build the SQL String
based on parameters recieved at call time.  So far I've found 2 ways to
include a portion of my params within the query:

1)  SET SQL_STMT='SELECT * FROM books WHERE bookid=?'
or
2)  SET SQL_STMT='SELECT * FROM books WHERE bookid=' || CAST(parm1 as
varchar(x))

My issues are that with option 1 the lining up of paramter markers (?) seem
to be based on the order they are defined in the procedure.  (i.e. the first
? get the first defined parameter, the second get the second and so on).
This will not work for me in this particular proc.

My other issue is simply an academic one.  On the DBMS I am accustomed to,
not actually paramterizing your queries is a last resort type of thing.  So,
I have been trying to avoid it on the AS400 as well (maybe without reason
though...).

Anyway, is there a way to pass named variables/parameters to my D-SQL?

Thanks in advance.

Ryan





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.