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



Alan,


-----Original Message-----
From: Alan Campin <Alan.Campin@xxxxxxxxxxxxxxxx>

<<< Off the question but why the prepare statement? >>>

I am able to use one PREPARE for many situations. Depending upon conditions, I can structure my PREPARE statement and execute it with common code. You should have seen what I had to do before I learned how to write a prepare... full SQL structures based on a number of user-selectable conditions. Now all I need to do is populate each segment and string them together:

// Assemble Select Statement For The Workfile
QQS = 'Select * From FILEA '; // Select All Fields From This File

// Set Where For Records Having Days Past Due In Range For The Selected Agency
QQW = 'Where GRGDPD Between ? And ? ' + // Days Past Due In Range
' And GRGAID = ? '; // For This Agency

// Set Order By Sort Method
QQO = 'Order By GRBAA '; // Order By Account Number

// Move SQL Statements To A Single Field
QQSQL = %Trim(QQS) + ' ' + %Trim(QQW) + ' ' + %Trim(QQO) + For_Read; // Move Statements

// Declare, Then Open Cursor
Exec SQL Prepare SQL_Stmt From :QQSQL; // Prepare Executable Statement
Exec SQL Declare @C1 Cursor For SQL_Stmt; // Declare Cursor
Exec SQL Open @C1 // Open Cursor...
Using :Days_From, :Days_To, :Proc_Agency; // Using These Values


I can fill QQS (Select), QQW (Where) and QQO (Order) with any number of variable conditions and still use my one cursor statement set.



Robert Munday
Munday Software Consultants
Montgomery, AL
on assignment in Columbia, SC



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.