Quantcast
Viewing latest article 3
Browse Latest Browse All 10

Conditional processing in embedded 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?

The post Conditional processing in embedded SQL appeared first on IT Answers.


Viewing latest article 3
Browse Latest Browse All 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>