A view with Sybase
engine cannot take parameters. Is there a way to do this?
1 Answer
Solution is to create procedure with use of dynamic query:
CREATE PROCEDURE view_with_parms( in str1 varchar(255), in str2 varchar(50) )
RESULT(
myID integer,
someName varchar(255))
BEGIN
EXECUTE ( 'select myID, someName from ' || str1 || ' order by ' || str2 || ' asc' );
END
then:
select * from view_with_parms('test_table','myID');
Tested with:
- SQL Anywhere 9
- SQL Anywhere 12