このコードは、郵便番号、都市、および州の入力を受け取り、それを Address で作成されたテーブルに挿入します。データを挿入する前に、zipcode が既にテーブルにあるかどうかをチェックし、そうであれば、procedure(error) を呼び出してエラー コードを表示します。
エラー コード pls-00103 が表示されます: コードを実行しようとしたときに、シンボル "CREATE" が発生しました。これまでの私のコードは次のとおりです。事前に助けてくれてありがとう。
drop table address;
create table address(zipcode NUMBER, city varchar2(30), state varchar2(20));
create or replace procedure error as
begin
dbms_output.put_line('Error Zip Code already found in table');
end error;
declare
zzip number;
ccity varchar2(30);
sstate varchar2(30);
create or replace procedure location(p_zipcode NUMBER,
p_city varchar2,
p_state varchar2) is
zip address.zipcode%type;
cit address.city%type;
st address.state%type;
begin
select count(*) from address into zip where zipcode = zip;
if any_rows_found then
error;
else
Insert into address values(zip, cit, st);
end if;
end location;
begin
select &zipcode into zzip from dual;
select &city into ccity from dual;
select &state into sstate from dual;
procedure location(zzip, ccity, sstate);
end;
/