这个存储过程怎么写、怎么调用?

guiyings 2003-11-12 05:11:00
在sql server2000里面建立两张表(表test1,表text2).
表test1里 含有如下字段:id int,
s1 numberic (18,2) ,
s2 numberic(18,2).
表Test2里含有如下字段 sum numeric(18,2),
money varchar.
建立存储过程1 Pro_test1:
Test2.sum = test1.s1 + test1.s2 ,
Test2.money= Pro_test2存储过程的返回值.
建立存储过程2 Pro_test2:
(1)选取test1表里id字段的最大值Max1,
(2)变量PHT="pz+YYYYMMDDHHMMSS(当前的年月日时分秒,精确到秒)+Max1",返回PHT.
然后在PB里面做个界面:上面是个文本框,下面是三个按钮(确定,取消,退出).每按一次确定,文本框里面就出现一串号码(就是一个序列号啦), 这个号码就是调用存储过程2 Pro_test2里的那个返回值.pz是个固定的字符串,它再加个时间+Max1,肯定是个序列号的
请问:那两个存储过程在Sql Server2000里面怎么建立?PB里怎么调用啊?.要从create procedure.....开始写,要完整答案啦,谁会的教教我罗,先谢谢了!!!
...全文
97 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
clicked事件调用
string ls_title = 'aaa',ls_output
DECLARE protest2 PROCEDURE FOR pro_test2
@pz = :ls_title,
@PHT = :ls_output output;
execute protest2;
if sqlca.sqlcode <> 0 then
messagebox("错误","错误信息:"+ sqlca.SQLErrText)
return
end if
fetch protest2 into :ls_output;
close protest2;
sle_1.text = ls_output
  • 打赏
  • 举报
回复
建议pro_test1前首先建立pro_test2
存储过程pro_test2
CREATE procedure pro_test2(@pz varchar(30),@PHT varchar(40) output) as
begin
declare
@maxid int,
@mynow datetime,
@temp varchar(40)
IF EXISTS (SELECT max(id) FROM test1)
select @maxid=max(id) from test1
else
select @maxid=01
select @mynow = getdate() from test1
select @temp = convert(char(20),@mynow,120)
select @temp = substring(@temp,1,4) + substring(@temp,6,2) + substring(@temp,9,2) + substring(@temp,12,2) + substring(@temp,15,2)
select @temp = @pz + @temp + CAST(@maxid AS varchar(5))
set @PHT = @temp
end
GO
  • 打赏
  • 举报
回复
存储过程pro_test1
CREATE procedure pro_test1
as
begin
declare
@test2_sum float,
@test2_money varchar(20)
select @test2_sum = 0
select @test2_money = ''
IF EXISTS (SELECT * FROM test1)
select @test2_sum=test1.s1+test1.s2 from test1
where id =(select max(id) from test1)

EXECUTE pro_test2 'aaa', @PHT = @test2_money OUTPUT
IF EXISTS (SELECT * FROM test2)
update test2 set um = @test2_sum,money2=@test2_money;
else
insert into test2 (um,money2) values(@test2_sum,@test2_money);
end
GO
htp_htp 2003-11-12
  • 打赏
  • 举报
回复
不想写了

自己看看书吧
dotnba 2003-11-12
  • 打赏
  • 举报
回复
我原来给过你啊
你自己看看啊,修改就可以了

sqlca.autocommit = true

DECLARE sp_GetNewID PROCEDURE FOR @rtn = GetNewID @TableName = :as_tablename;

EXECUTE sp_GetNewID;

Fetch sp_GetNewID into :ll_NewId;

Close sp_GetNewID;

sqlca.autocommit = False

return ll_NewId

1,077

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧