Re: SQLPLUS Question

From: Vladimir M. Zakharychev <vladimir.zakharychev_at_gmail.com>
Date: Thu, 21 Jan 2010 07:37:40 -0800 (PST)
Message-ID: <0b6c2d7b-eba1-4923-8127-dd5b7dde582d_at_p24g2000yqm.googlegroups.com>



On Jan 17, 7:34 pm, Jeremy <jeremy0..._at_gmail.com> wrote:
> In article <hithhv$d1..._at_solani.org>, gogala.mla..._at_gmail.com says...>
>
>
>
> > On Sat, 16 Jan 2010 20:24:36 +0000, Jeremy wrote:
>
> > > In article <hit6ej$ph..._at_solani.org>, gogala.mla..._at_gmail.com says...>
> > >> On Sat, 16 Jan 2010 18:37:24 +0000, Jeremy wrote:
>
> > >> > Can you create sqlplus scripts with "conditions" such that if for
> > >> > example a SQL statement returns a particular value or error condition
> > >> > then path A or path B is followed?
>
> > >> Yes. It's called PL/SQL and is available as of the version 6.
>
> > > Is that intended to be serious answer?
>
> > Yes. That is precisely what PL/SQL is intended for: you run SQL and
> > follow some logic path depending on the outcome.
>
> Perhaps I assumed I had conveyed more of my requirements to the post
> than I did.
>
> It's about conditional execution of .sql files - am looking at ways to
> automate install/upgrades which cannot be done using PL/SQL.
>
> --
> jeremy

SQL*Plus can do a lot more than most people expect. Check out how folks at Oracle are doing it: take any recent CPU patch and inspect catcpu.sql and you'll immediately see a way to launch .sql scripts conditionally; or take a look at _at_?/rdbms/admin/catbundle.sql for more complex example of conditional script *generation* and execution. The technique itself is not new: you combine PL/SQL for evaluating conditions and choosing scripts to run, bind variables to convey arguments and hold results, and SQL*Plus user variables to actually launch chosen scripts, possibly with chosen arguments. These patch application scripts are an excellent example of the technique you can build on.

Regards,

   Vladimir M. Zakharychev
   N-Networks, makers of Dynamic PSP(tm)    http://www.dynamicpsp.com Received on Thu Jan 21 2010 - 09:37:40 CST

Original text of this message