Re: Executing SQL in the Background?
Posted in 2000
From: "Mark D. Stock" <mdstock@mydas.freeserve.co.uk>
>
>Obnoxio The Clown wrote:
> >
> > In the year of Our Lord Fri, 15 Dec 2000 23:21:08 GMT, Jonathan Leffler
> > <jleffler@informix.com> broke a vow of silence to utter:
> >
> > >Nebojsa Sevo wrote:
> > >> On Thu, 14 Dec 2000 16:59:02 -0500, Don Ignacio
><dignacio@openratings.com>
> > >> wrote:
> > >>
> > >> >UNIX:
> > >> > You can place the sequence of sql statements in a file
> > >> > with an extension of ".sql". And enter the command:
> > >> > "dbaccess <file>.sql" as a cron job.
> > >> >
> > >> OR
> > >> nohup dbaccess db_name <file>.sql &
> > >
> > >While admirable solutions as far as they go, these answers really
> > >acknowledge Peter's second paragraph and don't address Peter's first
> > >question -- can you achieve the same effect inside a single running
>copy
> > >of DB-Access.
> > >
> > >The answer to that is 'No', because the only way to achieve it would be
> > >with a multi-threaded application, and DB-Access is not multi-threaded.
> > >Neither is SQLCMD, so my usual fallback remedy for the ills of
>DB-Access
> > >is no help this time.
> > >
> > >It's interesting to contemplate how to design the language to express
> > >that two SQL statements should be run in parallel. How would you
>handle
> > >the errors and output from the two statements?
> >
> > Well, ignoring errors, how about:
> >
> > dbaccess dbname <<! # could be from a file too!
> > !dbaccess dbname script1 &
> > !dbaccess dbname script2 &
> > !dbaccess dbname script3 &
> > !dbaccess dbname script4 &
> > !dbaccess dbname script5 &
>
>Isn't that the same as:
>
>dbaccess dbname script1 &
>dbaccess dbname script2 &
>dbaccess dbname script3 &
>dbaccess dbname script4 &
>dbaccess dbname script5 &
>
>?
Yes, but yours uses the power (?) of the shell. Mine just uses dbaccess,
which was, I believe, original question.
You could do something insanely daft like:
dbaccess dbname <<!
insert into tab1 values ("script1");
insert into tab1 values ("script2");
insert into tab1 values ("script3");
insert into tab1 values ("script4");
insert into tab1 values ("script5");
insert into tab1 values ("script6");
insert into tab1 values ("script7");
insert into tab1 values ("script8");...
!
dbaccess dbname <<!
OUTPUT TO PIPE "dbaccess dbname" WITHOUT HEADINGS
SELECT "!dbaccess dbname " || scriptname || " &"
FROM tab1
....
!
<Shudder>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.