此代码接受zipcode,city和state的输入,然后将其插入到表创建的Address中 . 在插入数据之前,它将检查zipcode是否已经在表中,如果是,则调用过程(错误)以显示错误代码 .
我得到一个错误代码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;
/
2 回答
我不确定你要做什么,但以下内容可能更接近你的想法:
祝你好运 .
我不知道我是否正确理解你的问题,但我想解决一些问题,以解决你的问题
试试这个: