db2 使用存储过程将数据插入现有表[已关闭]

z6psavjg  于 2023-01-05  发布在  DB2
关注(0)|答案(1)|浏览(201)

5小时前关门了。
Improve this question
我创建了一个student表,并尝试使用存储过程将数据插入到该student表中。
帮助我使用存储过程插入数据。

CREATE TABLE students
(
    student_id   integer not null ,
    student_name varchar(100),
    student_age  integer,
    mobile_no    varchar(20)
);

CREATE PROCEDURE sp_student
    (@student_id   int,
     @student_name varchar(100),
     @student_age  varchar(100),
     @mobile_no    varchar(20)) 
AS
BEGIN
    INSERT INTO students (student_id, student_name, student_age, mobile_no)
    VALUES (@student_id, @student_name, @student_age, @mobile_no);
END;
w9apscun

w9apscun1#

我假设您在LUW上,请删除CREATE PROCEDURE ...语句中的AS

CREATE PROCEDURE sp_student(
                            @student_id   int,
                            @student_name varchar(100),
                            @student_age  varchar(100),
                            @mobile_no    varchar(20)
                            )
BEGIN
...

参见CREATE PROCEDURE (SQL) statement

相关问题