Re: one code for two tables

From: <sybrandb_at_yahoo.com>
Date: 18 Sep 2003 00:37:31 -0700
Message-ID: <a1d154f4.0309172337.3df75646_at_posting.google.com>


"Julia Sats" <julia.sats_at_sympatico.ca> wrote in message news:<mr7ab.6954$hF3.915423_at_news20.bellglobal.com>...
> Can I do something like it:
>
> if i = 0 then
> for cur_var in (select * from t0) loop
> else
> for cur_var in (select * from t1) loop
>
> /*
> a lot of lines here
> */
>
> end loop;
>
>
>
> even if I would try to do like it:
>
> v_refcursor refcursor;
> v_rec0 t0%rowtype;
> v_rec1 t1%rowtype;
>
> BEGIN
> if i = 0 then
> OPEN v_refcursor FOR SELECT * FROM t0
> else
> OPEN v_refcursor FOR SELECT * FROM t1
> end if;
>
> I need to use different record_variables for FETCH and repeat my /* a lot of
> lines here */ couples time for different record variables.
>
> Any idea how to do code only once ?
>
> Thanks

Redesign your database (recommended) and get rid of this mess or use dynamic sql (not recommended, as you will end up with an unscalable application).
Instead of hacking yourself out, like you seem to do consistently, please try to *learn* and use approved practices, *design* your programs and stop creating spaghetti.

Sybrand Bakker
Senior Oracle DBA Received on Thu Sep 18 2003 - 09:37:31 CEST

Original text of this message