CREATE PROCEDURE band
@band_id NUMBER(8,2) = NULL,
@band_name VARCHAR(15) = NULL ,
@band_size NUMBER (8,2) = NULL ,
@band_genre VARCHAR(15) = NULL ,
@number_of_songs NUMBER (8,2) = NULL,
@average_song_time VARCHAR(15) = NULL ,
@festival_id NUMBER(8,2) = NULL,
@stage_id NUMBER(8,2) = NULL
AS
BEGIN
INSERT INTO band
(band_id,
band_name,
band_size,
band_genre,
number_of_songs,
average_song_time)
VALUES (@band_id,
@band_name,
@band_size,
@band_genre,
@number_of_songs,
@average_song_time)
END
sql insert procedure无法正常工作“成功,但编译错误”
希望实现一个允许用户将自己的数据插入应用程序构建器表单页面上“band”表的过程
答案 0 :(得分:0)
过程名称必须符合标识符规则,并且在架构中必须是唯一的。
如果您将datatype NUMBER更改为NUMERIC,则此存储过程将起作用,但根据您的设计要求,您可能希望探索其他数字数据类型。
CREATE PROCEDURE [dbo].[p_band]
@band_id numeric(8,2) = NULL,
@band_name VARCHAR(15) = NULL,
@band_size numeric (8,2) = NULL,
@band_genre VARCHAR(15) = NULL,
@number_of_songs numeric(8,2) = NULL,
@average_song_time VARCHAR(15) = NULL ,
@festival_id numeric(8,2) = NULL,
@stage_id numeric(8,2) = NULL
AS
BEGIN
INSERT INTO band
(
band_id,
band_name,
band_size,
band_genre,
number_of_songs,
average_song_time
)
VALUES
(
@band_id,
@band_name,
@band_size,
@band_genre,
@number_of_songs,
@average_song_time
)
END
答案 1 :(得分:-3)
首次更改过程名称
CREATE PROCEDURE Insertband
@band_id NUMBER(8,2) = NULL,
@band_name VARCHAR(15) = NULL ,
@band_size NUMBER (8,2) = NULL ,
@band_genre VARCHAR(15) = NULL ,
@number_of_songs NUMBER (8,2) = NULL,
@average_song_time VARCHAR(15) = NULL ,
@festival_id NUMBER(8,2) = NULL,
@stage_id NUMBER(8,2) = NULL
AS
BEGIN
INSERT INTO band
(band_id,
band_name,
band_size,
band_genre,
number_of_songs,
average_song_time)
VALUES (@band_id,
@band_name,
@band_size,
@band_genre,
@number_of_songs,
@average_song_time)
END
这将有效