-
need help at sort become a parameter
Hi all,
I have store procedure
create proc select_test
(@SubType varchar(50),
@sort varchar(4)
)
AS
..................
order by SampleYear @sort and I got error at @sort
any hit??
Thank you!
________
Starcraft Replays
Last edited by sql; 03-06-2011 at 01:51 AM.
-
You need to use functions, rather than sp , if you want to use them in the select statment.
-
hi
any detail? the reason I write a store procedure is i want to call from java bean. can I call a function from java ??
thank you
________
Vaporite Solo
Last edited by sql; 03-06-2011 at 01:51 AM.
-
If sql server,
create proc select_test
(@SubType varchar(50),
@sort varchar(4)
)
AS
select * from sysobjects order by
case @sort when '1' then info
else id end
-
Hi mak,
I did use MS Sql, I try the suggestion and still got error
rop proc select_Type
go
create proc select_Type
(@SubType varchar(50),
@sort varchar(4)
)
AS
begin
begin transaction
select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
from ViruName00
where SubType like'%' +@SubType+ '%'
union
select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
from ViruName01
where SubType like'%' +@SubType+ '%'
union
select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
from ViruName02
where SubType like'%' +@SubType+'%'
union
select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
from ViruName03
where SubType like'%' +@SubType+'%'
union
select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
from ViruName04
where SubType like'%' +@SubType+ '%' order by case @sort
when '1' then
SampleYear asc
else SampleYear desc
if @@error <>0 or @@rowcount !=1
begin
rollback
return
end
commit transaction
end
________
Suzuki rm65
Last edited by sql; 03-06-2011 at 01:51 AM.
-
Hi ,
any suggestions?
________
C200
Last edited by sql; 03-06-2011 at 01:52 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|