Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2001-09-12 : 22:33:03
|
| i have a small problem may not be to ui have a stored procedure which has a parameter @actbased on the value of @act my cursor declare will changeif i will write a block it will like thisdeclare @act varchar(8)beginset @act='01924762'if (@act is not null)begin select a.Unit_Id,acctno from subscriber a ,charges b where a.Chg_Id=b.Chg_Id and status='C' and a.acctno=@act union select unit_id,acctno from unit_events where Bill_Flg='N' and acctno=@act order by acctno,a.unit_idendelsebegin select a.Unit_Id,acctno from subscriber a ,charges b where a.Chg_Id=b.Chg_Id and status='C' union select unit_id,acctno from unit_events where Bill_Flg='N' order by acctno,a.unit_idendendif i declare a cursorif (@act is null)begin declare Acct_Unit cursor for select a.Unit_Id,acctno from subscriber a ,charges b where a.Chg_Id=b.Chg_Id and status='C' union select unit_id,acctno from unit_events where Bill_Flg='N' order by acctno,a.unit_idendelseif (@act is not null)begin declare Acct_Unit cursor for select a.Unit_Id,acctno from subscriber a ,charges b where a.Chg_Id=b.Chg_Id and status='C' and a.acctno=@act union select unit_id,acctno from unit_events where Bill_Flg='N' and acctno=@act order by acctno,a.unit_idendbut the problem is when i run the stored procedure it gives a error cursor already open or cursor with this name already exist |
|
|
|
|
|
|
|