create proc usp_InsertUserInfor @UserName varchar(20),@UserPwd varchar(40),@UserIdentity int,@IsDel bit = 0 as insert into UserInfor values(@UserName,@UserPwd,@UserIdentity,@IsDel)
时间: 2023-05-21 17:01:52 浏览: 77
这是一个存储过程的代码,用于向 UserInfor 表中插入用户信息。其中 @UserName 是用户名,@UserPwd 是用户密码,@UserIdentity 是用户身份,@IsDel 是是否删除的标志位。如果 @IsDel 未指定,则默认为 0。
相关问题
create trigger tri_jieshu on reader_borrow for insert as declare @id varchar(50) select @id=borrow_id from inserted update book_borrowing set book_surplus=book_surplus-1 where book_id=@id create trigger tri_huanshu on reader_back for insert as declare @id varchar(50) select @id=back_id from inserted update book_borrowing set book_surplus=book_surplus+1 where book_id=@id create proc payment @id varchar(20),@name varchar(20) as begin select borrow_date,back_date from reader_back,reader_borrow where back_id=borrow_id and back_id=@id and borrow_bookname=back_bookname and (select datediff(day, borrow_date,back_date) FROM reader_back,reader_borrow)>7 end create view view_pay as select * from reader_back,reader_borrow where (borrow_id=back_id and borrow_bookname=back_bookname) create proc proc_pay (@id varchar(20)) as select back_id,back_bookname,back_date,borrow_date from view_pay where back_id=@id exec proc_pay @id='1'该代码有什么语法错误
在触发器 tri_jieshu 和 tri_huanshu 中,update 语句中的 where 子句需要指定 book_id 而不是 borrow_id 和 back_id。应该修改为:
```
update book_borrowing set book_surplus=book_surplus-1 where book_id=(select book_id from inserted)
```
和
```
update book_borrowing set book_surplus=book_surplus+1 where book_id=(select book_id from inserted)
```
在 payment 存储过程中,应该将 datediff 函数的返回值赋值给一个变量,然后使用该变量进行比较。应该修改为:
```
create proc payment @id varchar(20),@name varchar(20) as
begin
declare @days int
select @days = datediff(day, borrow_date,back_date) FROM reader_back,reader_borrow
where back_id=borrow_id and back_id=@id and borrow_bookname=back_bookname
if (@days > 7)
begin
select borrow_date,back_date from reader_back,reader_borrow
where back_id=borrow_id and back_id=@id and borrow_bookname=back_bookname
end
end
```
在 proc_pay 存储过程中,应该将 @id 的数据类型修改为 varchar(50),并且在查询结果中使用别名来避免列名冲突。应该修改为:
```
create proc proc_pay (@id varchar(50)) as
begin
select b.back_id, b.back_bookname, b.back_date, r.borrow_date
from reader_back b, reader_borrow r
where b.back_id = r.borrow_id and b.back_id = @id and b.borrow_bookname = r.back_bookname
end
exec proc_pay @id='1'
```
阅读全文