I am having a problem with sql file that is saved in my pc. What i really is that i can create a view of that sql file that people can add extra tables to it but core will be always taken from my file. I have created a simple file and can load it to SQL Developer using define @"C:\\Users\\name.surname\\Desktop\\stock.sql"
However, I don't know how to work with it or create a view of it. Tried a simple way:
create view VW_MINE AS
select *
from
( @"C:\Users\name.surname\Desktop\stock.sql") X;
But getting an error Invalid table name
How can i work with that loaded SQL from file?
I have not tried with SQL developer, but this definitely works in SQL* Plus.
/*contents of mysqlfile.sql */
select * from hr.employees
DECLARE
sql_file VARCHAR2(32767) := '
@@C:\Users\kaushik\Desktop\stock.sql
';
--read the whole contents of the file into
--a variable. mysqlfile.sql cannot contain an "@" in itself.
--the @@ expression must be in a separate line
BEGIN
EXECUTE IMMEDIATE 'create or replace view myview as ' || sql_file; --execute it dynamically.
END;
/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.