Conditional processing in embedded SQL

4,290 pts.
Tags:
Conditional expressions
Embedded SQL
SELECT statement
SQL
I'd like to conditionally control the host variable into which the data from an SQL select statement is retrieved. This is for flexibility, so that I can use the same code in my program more than once. Here is a code sample: C/EXEC SQL C+ If :ResultName = 'AgtMaster' C+ Then C+ Fetch Next From MainCursor Into :AgtMasterResults C+ ElseIf :ResultName = 'TranHistory' C+ Then C+ Fetch Next From MainCursor Into :TranHistoryResults C+ End If C/END-EXEC I'm getting an SQL precompiler error though: SQL0199 Position 10 Keyword IF not expected. Valid tokens: DECLARE This is referring to the first statement. I don't understand if this is because I'm missing something, or if it's because conditions can't be used in an embedded SQL block. Has anyone done something similar?
ASKED: December 4, 2008  6:25 PM
UPDATED: December 4, 2008  6:50 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following