SQL View with table variables

585 Views Asked by At

Is it possible to create a view and that view to contain table variables for example like this:

create view "USERS_VIEW" as 

    tt = select * from "UsersTable" where "UserID" in (128,129);
    select * from :tt
with READ ONLY;
1

There are 1 best solutions below

0
On BEST ANSWER

Table variables are only available in SQLSCRIPT but not in standard SQL.

So, that doesn’t work with CREATE VIEW.

However, it’s possible to create a procedure with a view to access the procedure result set.
To do that use the WITH RESULT VIEW (see documentation) keyword with the CREATE PROCEDURE statement.