RE: Executing Informix Stored procedure from PB
Posted in 1995
Pete,
First, the answer... Your environment variables are not being
set when you execute the system() command from a PowerBuilder called
stored procedure. That is, when you are coming in from an
I-Net connection, you have only a minimal environment. In your
case, the dbload command is not in the path. Prove this to yourself
by trying:
LET cmd = "env > /tmp/spl.log";
SYSTEM(cmd);
LET cmd = "echo $PATH >> /tmp/spl.log";
SYSTEM(cmd);
As a suggestion, whenever you spawn a system command from within
a stored procedure, redirect stdout and stderr so you can find out
why it failed. Especially in this case, it would have saved you a
lot of aspirin!
Off the top of my head, I'd say you should think about creating
a script which would setup the environment variables and execute
a command you give it. If, for example, this scripts name was
"setup_and_run" you could do something like:
LET cmd = "/usr/bin/setup_and_run 'dbload -d cip -c ...'";
SYSTEM(cmd);
Finally, here's a theory to answer the "..but why does it work
from isql..?" question. When you run isql, it inherits your environment.
Then, when you run a stored procedure, it inherits the environment from
isql which was inherited from you. Then, when the system() call is
made, the same environment is inherited yet again.
Now, all this is true when the procedure is called from PowerBuilder.
The difference, however, is the I-Net socket. With the network
connection, no "real" login is ever performed. Therefore, each step
is inheriting a very basic environment.
Good luck!
--Craig (craig@chemistry.utah.edu)
>
> Hi, I am getting the following error when executing a procedure from
> PB. Actually, this is the messages made by the trace command in
> Informix SPL.
>
> let cmd = dbload -d cip -c /usr/informix/dev/load/load.cmd -l /tmp/err_log
> system : dbload -d cip -c /usr/informix/dev/load/load.cmd -l /tmp/err_log
>
> exception : looking for handler
> SQL error = -668 ISAM error = -1 error string = = ""> exception : no appropriate handler
>
>
> I am able to run this procedure from ISQL with no problems as the user
> Informix. I am running it through PowerBuilder as informix also. There
> are additional commands in the stored procedure that are executed
> correctly, but it always bombs on this part.
>