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



Jitendra,

If you want to use embedded SQL (or SQLRPG) you have to choose for dynamic
SQL. This means you build your SQL statement at runtime and prepare that
SQL statement.

You start with something like

C                             eval             Statement = "SELECT * FROM "
+ Filename.

As each file returns a different result set which you do not know at
compile time (or at runtime for that matter) the best solution (IMHO) is to
use a SQL descriptor area (SQLDA).

The sequence I have used for this (and done this) is:
DECLARE CURSOR
PREPARE
DESCRIBE INTO SQLDA
OPEN USING SQLDA
FETCH NEXT USING SQLDA
CLOSE CURSOR

In the SQL Reference manuals you can find information on the SQLDA
(searching the web can link you to other good resources of info as well;
the use of SQLDA is well explained).

The SQLDA exist of an array with each element a definition of a column in
the result set. To link an array element with the programme variable it
uses a pointer. As the number of columns in the result set or the data type
of each column at runtime is not know use DESCRIBE to get that data. The
programme variables linked with the SQLDA are elements of a noncontagious
array, defined as

D  Results                  DS
D    Resultset                                   1024              DIM(32)
D        CharValue                                 32
OVERLAY(Resultset:1)
D        PackedValue                             30P 9
OVERLAY(Resultset:*NEXT)
D        ZonedValue                               30S 9
OVERLAY(Resultset:*NEXT)

The linking with the pointer is done like

C                              eval       SQLDTA = %addr(CharValue(SQLIx))
C                              eval       SQLDTA =
%addr(PackedValue(SQLIx))
C                              eval       SQLDTA = %addr(ZonedValue(SQLIx))

I would make the SQLRPG programme a *SRVPGM, so you can use it for other
reporting purposses as well.

Hopefully this answers your questions and did not raise others.

Success with your project.

Regards,
Carel Teijgeler

*********** REPLY SEPARATOR  ***********

On 12-12-2006 at 18:25 Jitendra Bokshe wrote:

But I just want to use Embeded SQL, and I tried for the same but the thing
is that in Embeded SQL we need to define host sturture array.

If I am passing a PF(table name) & Library name as a parameter to RPGLE
program (means Runtime). So how it is possible?

One more doubt is that can we pass the parameter to SELECT Statment??
(Don't slap me if u think that this question is silly)



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.