[Info-ingres] Ingres Terminal Monitor - Conditional Execution
Roy Hann
specially at processed.almost.meat
Fri Oct 3 16:50:15 UTC 2014
Shelia White wrote:
> Hello,
>
> Is it possible to have a conditional execution in a Unix script which is
> running Ingres Terminal monitor e.g.
>
> #!/bin/csh
>
> echo "Input parameter is $1"
>
> sql dbname <<END
>
> create a session table... \g
>
> update session table... \g
>
> select from table ...\g
>
> if $1 ="UPDATE" then
>
> update data_table from session.table
> set field=new_field
> where etc.
> \g
> end if;
>
> END
>
>
>
> So I only want to run the update part of my script if the input
> parameter is set to UPDATE. I've tried various forms of this but can't
> get it work. Is it even possible?
>
> I suppose I can generate the script on the fly but that's a bit messy.
I can think of a couple of ways to do what you want. Probably the least
freaky way of doing it would be to use the terminal monitor (sql) macro
facility.
It takes some careful study to use it but it allows conditional
branching in sql scripts.
Take a look at the SQL Reference Guide chapter on Terminal Monitor where
you'll find a section on Terminal Monitor Macros.
Roy
More information about the Info-ingres
mailing list