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+ If :ResultName = 'AgtMaster'
C+ Fetch Next From MainCursor Into :AgtMasterResults
C+ ElseIf :ResultName = 'TranHistory'
C+ Fetch Next From MainCursor Into :TranHistoryResults
C+ End If
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?