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



BOY! Did this get mutilated!

I'll put the code sample back in...hopefully it won't get reformatted again.

// connect to local DB to retrieve some data

exec sql CONNECT reset; exec sql select * into :tttDS from tttable;

// release and commit added in response to suggestions in the SQL 0805 error message

exec sql RELEASE ALL; exec sql commit;

// connect to remote machine - tested the connection during one of the runs and verified connectivity

exec sql CONNECT TO remote_machine USER :user USING :pwd;

// prepare TESTCursor to retrieve data from remote system

exec sql close TESTCursor;
exec sql declare TESTCursor cursor for select * from needles.TEST;
exec sql open TESTCursor; <-- Failure point

// read remote system data
exec sql fetch TESTCursor into :testDS;

Steve Needles


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Needles,Stephen J
Sent: Monday, July 28, 2014 1:55 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Accessing Remote Database using SQL - requesting an SQL Package?

I am on release 7.1 and the latest TR.

I had a program that used DDM to read data from a remote IBMi (same release level). Recent changes have caused a CLOB column to be added to the table. This renders DDM a problem.

So I thought to use SQL to solve the issue.

I get an SQL805 error when running this code:


// connect to local DB to retrieve some data exec sql CONNECT reset; exec sql select * into :tttDS from tttable;

// release and commit added in response to suggestions in the SQL 0805 error message exec sql RELEASE ALL; exec sql commit;

// connect to remote machine - tested the connection during one of the runs and verified connectivity exec sql CONNECT TO remote_machine USER :user USING :pwd;

// prepare TESTCursor to retrieve data from remote system exec sql close TESTCursor; exec sql declare TESTCursor cursor for select * from needles.TEST;
exec sql open TESTCursor; <-- Failure point

// read remote system data
exec sql fetch TESTCursor into :testDS;


At the point where the cursor TESTCursor is opened, I encounter an SQL0805 error.

SQL package TESTPGM99 in LIBRARY not found at DRDA Server.


Message ID . . . . . . : SQL0805 Severity . . . . . . . : 30
Message type . . . . . : Diagnostic
Date sent . . . . . . : 07/28/14 Time sent . . . . . . : 13:45:01

Message . . . . : SQL package TESTPGM99 in LIBRARY not found at DRDA
Server.
Cause . . . . . : A remote request was attempted to remote_machine for SQL package
TESTPGM99 in LIBRARY. The SQL package was not found. If you are using
Interactive SQL or Query Manager, an attempt to create a package on the
remote system failed and the package requested does not exist.
Recovery . . . : The most common cause of this problem in an Interactive
SQL session to a server that is not DB2 for IBM i is that the connection is
not updateable. In that case the package cannot be automatically created.
To ensure the connection is updateable, do a RELEASE ALL command followed by
a COMMIT before connecting to the relational database.
In other cases, the SQL package can be created by using the CRTSQLPKG
command. Also, precompiling an SQL program with the RDB parameter specified
will create an SQL package on the system. Create or restore the SQL package.
Run the application again.
If you are using Interactive SQL or Query Manager or SQL Call Level
Interface, exit the product or application and enter a CL COMMIT or ROLLBACK
command. This will enable you to continue processing at the local system.
Determine why the package creation failed by examining the job log. Correct
the problem and attempt the Interactive SQL or Query Manager session again.

I've no experience of consciously using SQL Packages before and, in spite of RTFM, I can't figure this out.

Steve Needles

________________________________
This communication, including attachments, is confidential, may be subject to legal privileges, and is intended for the sole use of the addressee. Any use, duplication, disclosure or dissemination of this communication, other than by the addressee, is prohibited. If you have received this communication in error, please notify the sender immediately and delete or destroy this communication and all copies.

TRVDiscDefault::1201
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.


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.