Perocat
Perocat

Reputation: 1521

Load *LIBL (library list) defined in CRTJOBD when connecting to db2 with PDO

It seems nobody had this problem yet.... With db2_connect I found docs that decrible how to load a default library list (*LIBL) on connection but with PDO nothing!

I'd like to perform statements without specifing always the library name in front of file name. I already created a JOB DESCRIPTION to load the libraries, and when I log in with the PC5250 emulator those library are online.

But if I run a query with PDO without specifying the library name following is returned:

Error executing sth in testGet for AS400 SQLSTATE[42S02]:
Base table or view not found: 0 
[IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 -
TESTFILE in WEB type *FILE not found.
(SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206)

Upvotes: 1

Views: 995

Answers (3)

Korinne Adler
Korinne Adler

Reputation: 676

If you're talking about these docs, then that is if you're using PDO_IBM on IBM i. I don't think those settings are supported on any other platform. From your error message, it seems that you are using the IBM i Access ODBC driver through PDO_ODBC. The IBM i Access ODBC driver connects to a QZDASOINIT prestart job running in QUSRSYS subsystem. If you want those jobs to use a different job description, you need to use CHGPJE to change it: CHGPJE SBSD(QUSRSYS) PGM(QSYS/QZDASOINIT) JOBD(MYLIB/MYJOBD). If you're using SSL connections, also change QZDASSINIT jobs. You'll need to end any existing QZDASOINIT/QZDASSINIT jobs and the new pre-start jobs will pick up the new settings. Note that this will affect all ODBC, JDBC, OLEDB, .NET connections for IBM i Access drivers.

You can configure the library list through the DSN as well, by setting the DBQ connection string or DefaultLibraries ODBC.INI setting or setting the "Library List" value under the Server tab from the DSN configuration GUI on Windows.

Upvotes: 0

Brandon Peterson
Brandon Peterson

Reputation: 405

I know it's been awhile since you posted but I came across some info on how to do library lists using the PDO driver... see http://yips.idevcloud.com/wiki/index.php/XMLSERVICE/PHPPDOChangeLog.

So for example you could do something like this:

$options = [
    PDO::ATTR_PERSISTENT => true,
    PDO::ATTR_AUTOCOMMIT => true,
    PDO::I5_ATTR_DBC_SYS_NAMING => true,
    PDO::I5_ATTR_DBC_LIBL => "LIB1 LIB2 LIB3",
];

$db = new PDO("ibm:SYSTEM", "user", "password", $options);

Keep in mind this will probably require a recent Zend Server (since Dec 2014). I know the latest stuff is in the new ZS 8.5 but I'm not sure about older releases.

You might also be able to leave off the library list option - in my limited testing this appears to let it use the library list from the job description. I'm not sure about the current library and YMMV but I'd be curious to hear back if it works for you or not.

Also for what it's worth an email address for the official maintainer is listed on http://pecl.php.net/package/PDO_IBM. Questions could also be sent to the WEB400 mailing list (http://lists.midrange.com/mailman/listinfo/web400), I think people who are involved in the development of the pdo_ibm driver are on there as well.

Upvotes: 1

WarrenT
WarrenT

Reputation: 4542

To use the library list, you will need to make sure your connection attributes specify system naming, and I would avoid setting a current schema.

Without much knowledge of PHP + PDO, the stackoveflow tag wiki gives a good introduction. Check that PDO is configured for proper settings for DB2 for i, not LUW or z. Likewise check db2_connect settings. (Why are you using that, instead of straight ODBC?)

Upvotes: 1

Related Questions