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



All,

Perhaps someone will be kind enough to show what I'm doing to prevent a CLLE
program from receiving an integer from a procedure? I'm at the end of my rope!

I wrote a ReturnCount() procedure for our RPGLE "Toolbox" service program. Pass
it an SQL 'from-where' string and it uses SQLCLI to return the count(*) as an
integer. It works great when called from RPGLE but CLLE refuses to recognize the
integer returned from the CALLPRC with RTNVAR. Debug shows ReturnCount() is
completing correctly and the value in RtnValue is correct down to the last line
of the procedure, but the RTNVAR returned to the CL contains random garbage. Out
of frustration I wrote a ReturnString() procedure that executes a 'select
SOMECOLUMN from SOMETABLE where SOMEFIELD = ''FOO'' ' which is identical to
ReturnCount() except that RtnValue is defined as a string. This procedure behaves
correctly from either RPGLE or CLLE, so the issue seems to be specifically
related to returning integers to CLLE with CALLPRC-RTNVAR. It behaves the same
way whether or not the 'extproc(*CL:)' keyword is present.

I know that CLLE doesn't exactly understand integers, but I was under the
impression that RTNVAR could be retrieved in a *CHAR variable and treated with
the %bin() function.
Any suggestions will be most welcome. JK

This works fine in /free RPG:
mySQLStm = 'select count(*) from SOMETABLE where SOMEFIELD = ''FOO'' ';
myInt = ReturnCount( mySQLStm: myPgmRC: myPgmMisc );

The RTNVAR contains random garbage when called from CLLE:
DCL &SQLStmt *CHAR 1024
DCL &hexinteger *CHAR 4
ChgVar &SQLStmt ('select count(*) from SOMETABLE where SOMEFIELD = ''FOO'' ')
CALLPRC PRC('RETURNCOUNT') PARM((&SQLSTMT) (&PGMRC) (&PGMMISC))
RTNVAL(&HEXINTEGER)

D ReturnCount...
D PR 10I 0
D extproc(*CL: 'RETURNCOUNT')
D i_SQLStmt 1024A const
D o_PgmRC 1 options(*nopass : *omit)
D o_PgmMisc 100 options(*nopass : *omit)

P ReturnCount...
P B export
D ReturnCount...
D PI 10I 0
D i_SQLStmt 1024A const
D o_PgmRC 1 options( *nopass: *omit )
D o_PgmMisc 100 options( *nopass: *omit )
* Local definitions here
D env s like(SQLHENV)
D conn s like(SQLHDBC)
D stmt s like(SQLHSTMT)
D rc s like(SQLRETURN)
D RtnValue s like( StdInt )
D WillThisWork s like( StdInt )
D FatalError s like( StdLgl )
/free

clear FatalError;
clear RtnValue;
rc = SQLAllocEnv(env);
rc = SQLAllocConnect(env: conn);
rc = SQLSetConnectAttrI( conn
: SQL_ATTR_DBC_SYS_NAMING
: SQL_TRUE
: %size(SQLINTEGER) );
rc = SQLConnect(conn: '*LOCAL': SQL_NTS: *NULL: SQL_NTS: *NULL: SQL_NTS);
rc = SQLAllocStmt( conn: stmt );
rc = SQLExecDirect( stmt : %trim( i_SQLSTMT ): SQL_NTS );
rc = SQLBindCol( stmt
: 1
: SQL_INTEGER
: %addr(RtnValue)
: %size(RtnValue)
: *omit );
rc = SQLFetch( stmt );
rc = SQLFreeStmt( stmt : SQL_DROP );
rc = SQLDisconnect( conn );
rc = SQLFreeConnect( conn );
rc = SQLFreeEnv( env );
//// Arrggh - try moving the value to a completely separate field
//// Return RtnValue;
WillThisWork = RtnValue;
Return WillThisWork;

---- Msg sent via Internet America Webmail - http://www.internetamerica.com/


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.