use pubs
go
create proc prcgreater
@pub_id char(4)
@price money output,
@pubdate datetime output
as
begin
select @price=price,@pubdate=pubdate
from titles
where pub_id=@pub_id
endcreate proc prcgq
@pub_id char(4)
as
begin
declare @price money
declare @pubdate datetime
exec prcgreater @pub_id ,@price output,@pubdate output
if @@error<>0
begin
print 'error'
end
else
begin
select @price as price,@pubdate as pubdate
end
endexec prcgq 'BU1111' --这个号是存在的,为什么不显示@price,@pubdate
go
create proc prcgreater
@pub_id char(4)
@price money output,
@pubdate datetime output
as
begin
select @price=price,@pubdate=pubdate
from titles
where pub_id=@pub_id
endcreate proc prcgq
@pub_id char(4)
as
begin
declare @price money
declare @pubdate datetime
exec prcgreater @pub_id ,@price output,@pubdate output
if @@error<>0
begin
print 'error'
end
else
begin
select @price as price,@pubdate as pubdate
end
endexec prcgq 'BU1111' --这个号是存在的,为什么不显示@price,@pubdate
服务器: 消息 266,级别 16,状态 2,过程 prcgreater,行 65535
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。
error
服务器: 消息 266,级别 16,状态 2,过程 prcgq,行 65535
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。
是因为你的
select @price=price,@pubdate=pubdate from titles output where pub_id=@pub_id
的错误,
改成扬兄那样就对了!
use pubs
go
create proc prcgreater
@pub_id char(4)
as
begin
DECLARE @price money,
@pubdate datetimecreat table #temptable
(price money,
pubdate datetime)select @price=price,@pubdate=pubdate
from titles
where pub_id=@pub_id
insert into #temptable(price,pubdate)
values(@price,@pubdate)
endcreate proc prcgq
@pub_id char(4)
as
begin
declare @price money
declare @pubdate datetimecreat table #temptable
(price money,
pubdate datetime)insert exec prcgreater @pub_id if @@error<>0
begin
print 'error'
end
else
begin
select * from #temptable
end
end