SQL only runs with dot qualifier SQLNAMING SYS has no effect

General discussion on Zend Server for IBM System i
Post Reply
vhflores
Posts: 18
Joined: Fri May 22, 2009 5:04 pm

SQL only runs with dot qualifier SQLNAMING SYS has no effect

Post by vhflores » Tue Aug 23, 2016 2:37 pm

SQL only runs with dot qualifier SQLNAMING SYS has no effect.

Trying to run SQL, but it doesnt like the slash qualifier.
I tried changing SQLNAMING to SYS so it would accept the slash, but it makes no difference,
it still doesnt like the slashes.
If i change the slash to a dot, then the sql works (with or without SQLNAMING SYS)


i5_connect:
I5_OPTIONS_SQLNAMING=>'SYS' is not working
in fact, i would say NONE of the 'options' have any effect- i say this, because
i can put garbage values, and the results are the same.

This is the code. . .

$cmg = i5_connect("nn.nn.nnn.nnn", "myuser", "mypw", array('I5_OPTIONS_SQLNAMING'=>'SYS')) or die(i5_errormsg());
$connResource = $cmg->getConnection();
if (!$connResource) {
echo "<p>Connection not successful</p>";
$k = i5_errormsg();
echo "<p>".$k."</p>";
die(i5_errormsg());
}
else {
$qryString = "Select * from MYLIB/MYTABLE";
$statement = db2_prepare($connResource, $qryString);

etc

if i change the / to . then it works fine

BUT THE REAL PROBLEM, is that if i leave it unqualified, it doesnt know to go thru the libl,
and the table cant be found- all because SYS is not taking!!!

How do i get SYS to take??

vhflores
Posts: 18
Joined: Fri May 22, 2009 5:04 pm

Re: SQL only runs with dot qualifier SQLNAMING SYS has no ef

Post by vhflores » Tue Aug 23, 2016 2:40 pm

By the way, I've tried with quotes, with single quotes, with double quotes, etc. . . .
left above, it as
array('I5_OPTIONS_SQLNAMING'=>'SYS')

but I've tried all the combinations to no avail
array(I5_OPTIONS_SQLNAMING=>'SYS')
array(I5_OPTIONS_SQLNAMING=>"SYS")
array(I5_OPTIONS_SQLNAMING=>SYS)
etc . . . .

jvalance
Posts: 5
Joined: Fri Mar 18, 2011 9:53 pm

Re: SQL only runs with dot qualifier SQLNAMING SYS has no ef

Post by jvalance » Wed Aug 24, 2016 5:41 am

You need to use this format in your options array (4th parameter of db2_connect):
array('i5_naming' => DB2_I5_NAMING_ON)

This is detailed in the php manual for db2_connect(): http://php.net/manual/en/function.db2-connect.php
Search for i5_naming

You can also specify i5_libl as an option, but if you leave it off, library list will come from the *JOBD of the user connecting.

vhflores
Posts: 18
Joined: Fri May 22, 2009 5:04 pm

Re: SQL only runs with dot qualifier SQLNAMING SYS has no ef

Post by vhflores » Wed Aug 24, 2016 3:06 pm

thank you, jvalance.

i'm actually using i5_connect, and not db2_connect()

sounds like you're saying i should be using db2_connect(),
and thanks for the details.

jvalance
Posts: 5
Joined: Fri Mar 18, 2011 9:53 pm

Re: SQL only runs with dot qualifier SQLNAMING SYS has no ef

Post by jvalance » Wed Aug 24, 2016 9:17 pm

Sorry - I should have studied your code a bit closer. Looks like you're trying to use the old procedural Zend Toolkit for IBM i. The toolkit allows you to call programs, run CL commands, and access native iOS objects like spool files, system values, etc., all from within a PHP script. You can also run SQL via the toolkit, but if you just want to run SQL I would recommend using the db2_connect() and related db2_* functions that are built-in to the PHP core. They are all documented on php.net.

If you want to call programs, run commands and do the things the toolkit does well, I would recommend you check out the new OO Toolkit, based on XMLSERVICE. A good introduction to this can be found here: http://www.slideshare.net/aseiden/new-p ... e-on-ibm-i, and you can deploy sample toolkit applications on your IBM server via the Zend server admin console, which can be accessed at http://<your-ibm-i-ipaddress>:10081/ZendServer/. Instructions for deploying the samples can be found here: http://files.zend.com/help/Zend-Server- ... s_ibmi.htm.

FYI - If you already have applications using the old Easycom/Aura procedural toolkit, there is a Compatibility Wrapper which wraps the new toolkit objects/methods as procedural functions that look exactly like the old toolkit functions. That way you can install the new toolkit without rewriting all your code, and incrementally move to the new toolkit and use its more robust features.

If you need more help with the db2 functions, feel free to contact me, at johnv@div1sys.com.

Post Reply