存储过程为每个用户、每个银行、每个卡类型(借记卡、信用卡)和每个卡名(主卡、签证)存储一个 16 位随机数。请检查出了什么问题。只有每个 for bank 的循环工作正常。而卡类型和卡名称的其他循环不起作用,并且仅存储一种卡类型和一个卡名称的信息..请检查我在哪里弄错了..
ALTER PROCEDURE dbo.storecardinfo(@uer_id INT)
/*
(
@parameter1 int = 5,
@parameter2 datatype OUTPUT
)
*/
AS
/* SET NOCOUNT ON */
declare
@c_type_id int ,
@c_name_id int ,
@b_id int ,
@c_name varchar(50) ,
@c_type varchar(50) ,
@b_name varchar(50),
@rand_no varchar(50)
begin
set @c_type_id=(select min(card_type_id) from tbl_card_type);
set @c_name_id=( select min(card_id) from tbl_card_master);
set @b_id=(select min(bank_id) from tbl_bank_master);
while @c_type_id is not null
begin
while @c_name_id is not null
begin
while @b_id is not null
begin
set @c_name=(select card_name from tbl_card_master where card_id=@c_name_id);
set @c_type=(select card_type_name from tbl_card_type where card_type_id=@c_type_id);
set @b_name=(select bank_name from tbl_bank_master where bank_id=@b_id);
set @rand_no=(SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 )
+ (DATEPART(ss, GETDATE()) * 1000 )
+ DATEPART(ms, GETDATE()) ));
insert into tbl_card_info(user_id,card_name,card_type,card_bank,card_number) values(@uer_id,@c_name,@c_type,@b_name,@rand_no);
set @b_id=(select min(bank_id) from tbl_bank_master where (@b_id<bank_id));
end
set @c_name_id=(select min(card_id) from tbl_card_master where (@c_name_id<card_id));
end
set @c_type_id=(select min(card_type_id) from tbl_card_type where (@c_type_id<card_type_id));
end
end