Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL !

Re: PL/SQL !

From: Jerry Metz <jmetz1_at_ix.netcom.com>
Date: Tue, 21 Aug 2001 21:14:05 GMT
Message-ID: <3B82CEB5.7AE4C340@ix.netcom.com>


If I read your code correctly (and it's certainly possible that I'm not with the day that I've had today!), your function will return FALSE even if the table exists but has no rows in it. That might be OK for the questioner's needs, but my guess is that their next step would be to create the table or quit if the table actually does not exist. I don't think that your function, as is, will give them the right answer.

George Barbour wrote:

> Try this
> FUNCTION sp_tableexists( i_s_tablename IN VARCHAR2) RETURN BOOLEAN IS
>
> CURSOR cq_usertab (i_s_tablename VARCHAR2) IS
> SELECT table_name FROM user_tables
> WHERE table_name = i_s_tablename;
>
> l_r_tablerow cq_usertab%rowtype;
>
> BEGIN
> OPEN cq_usertab (i_s_tablename);
> FETCH cq_usertab INTO l_r_tablerow;
> IF cq_usertab%notfound THEN
> CLOSE cq_usertab;
> RETURN FALSE;
> ELSE
> CLOSE cq_usertab;
> RETURN TRUE;
> END IF;
> END sp_tableexists;
>
> George Barbour.
>
> "Rahul" <rahul_europe_at_yahoo.com> wrote in message
> news:923a99a4.0108201211.f59a523_at_posting.google.com...
> > hi there:
> >
> > I was wondering if you have the answer of following two questions:
> >
> > a. Inside PL/SQL block, how to check that a particular table does not
> > exist.
> >
> > I know this one,but there will be some other better ways as well, so
> > do you know some of them?
> >
> > if(rad_cursor2%NOTFOUND) then
> > dbms_output.put_line('the table is emply');
> >
> >
> > b. how to call a trigger block from PL/SQL block.
> >
> >
> > regards,
> > rahul


Received on Tue Aug 21 2001 - 16:14:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US