Re: PL/SQL Exception handling
Date: Thu, 20 Mar 2003 22:05:17 +0100
Message-ID: <3E7A2D0D.7080705_at_netscape.net>
davidmac wrote:
> Beware Newbie Question.
>
> I have a simple pl/sql script that I am trying to write that is
> driving me bloomy! It seems that the contents of my exception is
> being run even if there should be no exception raised. If I find a
> value that is valid, the exception runs then I get the output
> expected.
>
>
> DECLARE
>
> v_physician physician%rowtype;
> v_PHYS_ID CHAR(3);
> v_PHYS_NAME VARCHAR2(20);
> v_PHYS_PHONE CHAR(12);
> v_PHYS_SPECIALTY VARCHAR2(20);
>
> BEGIN
> DBMS_OUTPUT.ENABLE;
> v_PHYS_ID := '&PID';
> select *
> into v_physician
> from physician
> where PHYS_ID=v_PHYS_ID;
> dbms_output.put_line ( v_physician.PHYS_ID||' '||
> v_physician.PHYS_NAME||' '||
> v_physician.PHYS_PHONE||' '||
> v_physician.PHYS_SPECIALTY);
>
> EXCEPTION
>
> when no_data_found
>
> then
> DBMS_OUTPUT.PUT_LINE('Phys_ID not found, please enter new data');
> begin
> v_PHYS_NAME := '&PNAME';
> v_PHYS_PHONE := '&PPHONE';
> v_PHYS_SPECIALTY := '&PSPECIALTY';
>
> insert into physician(PHYS_ID, PHYS_NAME, PHYS_PHONE, PHYS_SPECIALTY)
> values ( v_PHYS_ID, v_PHYS_NAME, v_PHYS_PHONE, v_PHYS_SPECIALTY);
> commit work;
> end;
>
> END;
> /
>
>
> are these lines the problem?
>
> v_PHYS_NAME := '&PNAME';
> v_PHYS_PHONE := '&PPHONE';
> v_PHYS_SPECIALTY := '&PSPECIALTY';
>
>
> tia
[Quoted] And you expect SQL*Plus to kick in and ask about the values of PNAME, PPHONE and PSPECIALITY? No dice. That's plus, not pl/sql
-- Regards, Frank van BortelReceived on Thu Mar 20 2003 - 22:05:17 CET
