2

A view with Sybase engine cannot take parameters. Is there a way to do this?

BlueMark
  • 247
  • 1
  • 3
  • 15

1 Answers1

4

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
BlueMark
  • 247
  • 1
  • 3
  • 15