× 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.



Hi Jeff,

it's not possible to use hostvariables (leading :) in the Command-String.

You have the following options:
1. If the SQL statement never changes and only uses different dates, I'd
suggest to use static SQL:
C/EXEC SQL
C+ Declare MyCursor Cursor
C+     for Select * from dbmstf/ordtlhst
C+            where onrcu IN (SELECT   onrcu
C+                               from  dbmstf/orhdrhst
C+                               where shpdtiso between :BgnDate
C+                                                  and :EndDate)
C+            Order By NAMEK10, DATEKISO, TIMEKISO'
C/END-EXEC

C/Exec SQL  Open MyCursor
C/End-Exec

C/EXEC SQL  Fetch ...
C/End-Exec

C/EXEC SQL  Close MyCursor
C/End-Exec

2. If the SQL-Statement must be built dynamically, you have to use parameter
markers (?) instead of Host-Variables.
   The parameter markers get replaced in the open statement by specifying
USING :HostVariable

D FetchSQL        C    'SELECT * FROM dbmstf/ordtlhst +
D                      WHERE onrcu IN (SELECT onrcu FROM +
D                      dbmstf/orhdrhst WHERE +
D                      shpdtiso >= DATE(?) +
D                      AND +
D                      shpdtiso <= DATE(?)) +
D                      ORDER BY NAMEK10, DATEKISO, TIMEKISO'
 *------------------------------------------------------------------
 /Free
   MySQL = FetchSQL;
 /End-Free
C/exec sql
C+ prepare mainStatement
C+    from :MySQL
C/end-exec

C/exec sql
C+ declare MyCursor cursor
C+     for mainStatement
C/end-exec

C/EXEC SQL Open MyCursor Using :BgnDate, :EndDate
C/End-Exec

C/EXEC SQL Fetch ....
C/End-Exec

C/EXEC SQL Close MyCursor
C/End-Exec


Mit freundlichen Gruessen / Best regards

Birgitta

"Shoot for the moon, even if you miss, you'll land among the stars."
(Les Brown)


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.