简体   繁体   中英

Oracle function or package to execute SQL and return records

I need to call a package or function from Excel and cause the processing to be done on the server rather than on the local machine. To do this I need to pass a SELECT SQL statement to a package or function and it will return the record set.

The reason for this is that we have 100s of SQL statements that are currently processed in Excel but due to VPN slowness they are taking much longer. I have tried a single package to run an SQL when called and it is significantly quicker. Any approach to pass only SELECT SQL statements to a function and just return the records will be a great help.

Oracle version 11.

Have you access to Linux?

If you have created the statement and you only need the result of select in your output. The most beautiful task is do:

SPOOL </my_folder/my_file.csv>

The below mentioned SELECT

SPOOL OFF;

If you create a SELECT statement like:

SELECT col1 || ';' || col2 || ';' || ... || ';' || coln FROM MY_TABLE;

You will have CSV file, wherever you run your Oracle.

If you must create the SELECT STATEMENT with variables, You must work with REFCURSOR.

Regards.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM