exec('declare cursor_insert cursor for select c# from cs')
--注意:只有声明的时候是动态的。
declare @i int
open cursor_insert
fetch cursor_insert into @i
while @@fetch_status=0
begin
print @i
fetch cursor_insert into @i
end
close cursor_insert
deallocate cursor_insert
ls_sqltxt='select c_articleid,c_articlename,c_unit,c_cprice,c_bprice,c_zprice'&
+' from xt_article where (c_typecode = ?) and (c_brandcode = ?) and (c_breedcode = ?) and ((c_mpcode is null) or (c_mpcode like ' + "'%'" + ')) and not (c_brandcode is null)'
prepare sqlsa from :ls_sqltxt;
open dynamic art using :is_typecode,:is_brandcode,:is_breedcode;
ls_sqltxt='select c_articleid,c_articlename,c_unit,c_cprice,c_bprice,c_zprice'&
+' from xt_article where (c_typecode = ?) and (c_brandcode = ?) and (c_breedcode = ?) and ((c_mpcode is null) or (c_mpcode like ' + "'%'" + ')) and not (c_brandcode is null)'
prepare sqlsa from :ls_sqltxt;
open dynamic art using :is_typecode,:is_brandcode,:is_breedcode;