我在sql中有这个代码,它在sql server 2005上运行完美。但是当我在isql plus中运行这个代码时,它会出错,我应该做些什么更改来运行它。
代码是---
DECLARE @stu_Name VARCHAR(50), @stu_Address VARCHAR(50)
SELECT @stu_Name = g.stu_Name,@stu_Address= g.stu_address
FROM student as g
WHERE unique_no = 's121'
INSERT INTO
dbo.student(stu_no, stu_name, dateofbirth,stu_unique_no, stu_name,stu_address)
VALUES
(13, 'John', '1990-12-12','s121', @stu_Name, @stu_Address);
答案 0 :(得分:2)
@ A.B.Cade给出the efficient way of doing things。当然,他的语法也适用于SQL Server。因此,预计练习的目的是将T-SQL准确地转换为PL / SQL。
DECLARE
l_stu_Name. student.stu_Name%type;
l_stu_Address student student.stu_address%type;
BEGIN
SELECT stu_Name, stu_Address
into l_stu_Name, l_stu_address
FROM student as g
WHERE unique_no = 's121' ;
INSERT INTO
dbo.student(stu_no, stu_name, dateofbirth,stu_unique_no, stu_name,stu_address)
VALUES
(13, 'John', '1990-12-12','s121', l_stu_Name, l_stu_Address);
END;
/
您应该知道Oracle文档是全面的,在线的和免费的。你应该学会导航它。 find it here。的问题。
答案 1 :(得分:0)
INSERT INTO
dbo.student(stu_no, stu_name, dateofbirth,stu_unique_no, stu_name,stu_address)
SELECT 13, 'John', to_date('1990-12-12','yyyy-mm-dd'),g.unique_no, g.stu_Name, g.stu_address
FROM student as g
WHERE unique_no = 's121';
没有检查,但这是一个开始......