Regarding calling an INFORMIX procedure from a UNIX shell script
Posted in 1999
Topics: Stored Procedures & SPL
Hi, This question is from a novice in INFORMIX. I have a problem. I have to call an INFORMIX procedure from a UNIX shell script. This INFORMIX procedure will have a query and writes the output of the query to a file in the current directory. I have to getback the pointer to the same shell script after execution. Later on I have to execute some oracle stored procedures. Eg: Consider x.sh is the shell script. This has to call an informix procedure say informix1.proc. Then what syntax, configuration setup is required.FYI- The same shell script later on depending on the output of the INFORMIX procedure calls some oracle stored procedures. Hope I am clear with my question. Expecting your reply... Thanks, Girish
Not too clear !!
In shell ( whether ksh, bsh or csh ) you can simply run a SQL script
embedded in the shell script then, once the SQL script has finished, use the
ksh script to check the output generated by the SQL.
e.g.
The following example is a shell script that runs a SQL script then checks
the output:-
INFORMIXDIR=/home/informix DB=baan
TEMPDIR=/tmp/dba
dbaccess sysmaster << EOF 2>> $TEMPDIR/sql-extents.out
SELECT a.tabname tabname, count(*) extents,
sum(a.size) pages_used
FROM sysextents a,
${DB}:systables b
WHERE a.dbsname = "${DB}"
AND a.tabname = b.tabname
AND b.tabid > 99
GROUP by 1;
EOF
ROWCOUNT=`cat $TEMPDIR/sql-extents.out | wc -l`
if [[ $ROWCOUNT > 10 ]]; then
echo "More than 10 tables found )
else
echo "Extents okay"
fi
Remember, this is just an example. Play around with simple scripts to start
with, but you'll soon get the hang of it !!
As far as Oracle goes, sorry, don't know much about that one.
Hope this helps
Sean
Girish Naropanth wrote in message <369E8063.CCA300EF@hotmail.com>...
>Hi,
>
>This question is from a novice in INFORMIX.
>
>I have a problem. I have to call an INFORMIX procedure from a UNIX shell
>script. This INFORMIX procedure will have a query and writes the output
>of the query to a file in the current directory. I have to getback the
>pointer to the same shell script after execution. Later on I have to
>execute some oracle stored procedures.
>
>Eg:
>Consider x.sh is the shell script. This has to call an informix
>procedure say informix1.proc. Then what syntax, configuration setup is
>required.FYI- The same shell script later on depending on the output of
>the INFORMIX procedure calls some oracle stored procedures.
>
>Hope I am clear with my question. Expecting your reply...
>
>Thanks,
>Girish
I use dbaccess for this purpose.
Syntax is "dbaccess <database> <text file with sql commands>.
Just be sure your informix environment variables are set properly
(INFORMIXSERVER, ONCONFIG).
Just open a dbaccess session from within your shell script. When the dbaccess
session completes, you'll pick up where you left off.
EXAMPLE:
#! /bin/ksh
# script name: x.sh
#
...
dbaccess my_database - 2>/dev/null <<EOC
EXECUTE PROCEDURE informix1_proc();EOC
...
Bob
------
In article <369E8063.CCA300EF@hotmail.com>,
Girish Naropanth <gnaropanth@hotmail.com> wrote:
> Hi,
>
> This question is from a novice in INFORMIX.
>
> I have a problem. I have to call an INFORMIX procedure from a UNIX shell
> script. This INFORMIX procedure will have a query and writes the output
> of the query to a file in the current directory. I have to getback the
> pointer to the same shell script after execution. Later on I have to
> execute some oracle stored procedures.
>
> Eg:
> Consider x.sh is the shell script. This has to call an informix
> procedure say informix1.proc. Then what syntax, configuration setup is
> required.FYI- The same shell script later on depending on the output of
> the INFORMIX procedure calls some oracle stored procedures.
>
> Hope I am clear with my question. Expecting your reply...
>
> Thanks,
> Girish
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own