I am converting a MSSQL script to Oracle, and I haven\'t been able to figure out the syntax to use a variable in place of a table name or column.
Here is a simple ex
WHERE
clauseINTO
needs to be part of the EXECUTE IMMEDIATE
, not part of the dynamic SQL statement.EXECUTE IMMEDIATE
statement should end with a semicolonPutting those together, something like this should work
declare
VR_TABLE VARCHAR2(256);
VR_UPDATE VARCHAR2(256);
begin
VR_TABLE :='SYSTEM_STATUS';
EXECUTE IMMEDIATE 'select UPDATE_VERSION from ' || VR_TABLE || ' where rownum < 2'
INTO VR_UPDATE;
end;
Of course, since you're not doing anything with VR_UPDATE
, nothing will be displayed when this anonymous block is executed.