oracle存储过程编译不通过,求各位大虾帮我看下
CREATEORREPLACEprocedureinsert_person(NUMININT)ASIDINT;NAMEVARCHAR2;ageNUMBER;emailVA...
CREATE OR REPLACE procedure insert_person(
NUM IN INT
)
AS
ID INT;
NAME VARCHAR2;
age NUMBER;
email VARCHAR2;
sex NUMBER;
birthday DATE;
create_time TIMESTAMP;
BEGIN
ID:=NUM;
NAME:='张三';
age:=25;
email:='shangsan';
birthdaty:=DATE'1992-05-01';
create_time:=SYSTIMESTAMP;
FOR i IN 1...1000 LOOP
sex:=1;
IF(i<500)THEN
sex:=0;
END IF;
INSERT ID,NAME,age,email,sex,birthday,create_time INTO person VALUES(
NUM+i,
NAME||i,
age,
email||i||'@163.com',
sex,
birthday,
create_time
);
END LOOP;
COMMIT;
dbms_output.put_line('执行结束');
END; 展开
NUM IN INT
)
AS
ID INT;
NAME VARCHAR2;
age NUMBER;
email VARCHAR2;
sex NUMBER;
birthday DATE;
create_time TIMESTAMP;
BEGIN
ID:=NUM;
NAME:='张三';
age:=25;
email:='shangsan';
birthdaty:=DATE'1992-05-01';
create_time:=SYSTIMESTAMP;
FOR i IN 1...1000 LOOP
sex:=1;
IF(i<500)THEN
sex:=0;
END IF;
INSERT ID,NAME,age,email,sex,birthday,create_time INTO person VALUES(
NUM+i,
NAME||i,
age,
email||i||'@163.com',
sex,
birthday,
create_time
);
END LOOP;
COMMIT;
dbms_output.put_line('执行结束');
END; 展开
2016-05-12
展开全部
FOR i IN 1...1000 LOOP 语法错误 是两个点!
,INSERT ID,NAME,age,email,sex,birthday,create_time INTO person VALUES(
这一段的insert 这个一行也是有错误
--1-birthday DATE 与birthdaty:=DATE'1992-05-01'; 不是同一个变量
--以下是更过后的,可以参考下 希望对你有帮助1
create or replace procedure insert_person(
NUM IN INT
)
AS
ID INT;
NAME VARCHAR2(10);
age NUMBER;
email VARCHAR2(10);
sex NUMBER;
birthday DATE;
create_time TIMESTAMP;
BEGIN
ID:=NUM;
NAME:='张三';
age:=25;
email:='shangsan';
birthday:=to_date('1992-05-01','yyyy-mm-dd');
create_time:=SYSTIMESTAMP;
FOR i IN 1..1000 LOOP
sex:=1;
IF(i<500)THEN
sex:=0;
END IF;
INSERT INTO person( ID,NAME,age,email,sex,birthday,create_time) VALUES(
NUM+i,
NAME||i,
age,
email||i||'@163.com',
sex,
birthday,
create_time
);
END LOOP;
COMMIT;
dbms_output.put_line('执行结束');
END;
,INSERT ID,NAME,age,email,sex,birthday,create_time INTO person VALUES(
这一段的insert 这个一行也是有错误
--1-birthday DATE 与birthdaty:=DATE'1992-05-01'; 不是同一个变量
--以下是更过后的,可以参考下 希望对你有帮助1
create or replace procedure insert_person(
NUM IN INT
)
AS
ID INT;
NAME VARCHAR2(10);
age NUMBER;
email VARCHAR2(10);
sex NUMBER;
birthday DATE;
create_time TIMESTAMP;
BEGIN
ID:=NUM;
NAME:='张三';
age:=25;
email:='shangsan';
birthday:=to_date('1992-05-01','yyyy-mm-dd');
create_time:=SYSTIMESTAMP;
FOR i IN 1..1000 LOOP
sex:=1;
IF(i<500)THEN
sex:=0;
END IF;
INSERT INTO person( ID,NAME,age,email,sex,birthday,create_time) VALUES(
NUM+i,
NAME||i,
age,
email||i||'@163.com',
sex,
birthday,
create_time
);
END LOOP;
COMMIT;
dbms_output.put_line('执行结束');
END;
追问
多谢指点出了三个错误,可编译还是不通过,这是我自己看存储过程时练手写的,不知道还有其他什么问题
追答
我贴进来的你不能编译还是有错 是吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询