In PL / SQL, I would like to pass the source schema as a parameter to the stored procedure. For instance:
BEGIN CURSOR my_cursor IS SELECT my_field FROM <schema>.my_table ...
I want the value of "schema" to come from an input parameter to a stored procedure. Does anyone know how I can do this?
PS Sorry if this is a stupid simple question, but I'm new to PL / SQL and should get some features quickly.
In addition to what Mark Brady said, another dynamic SQL option is to use REF CURSOR. Since your sample code contains a cursor, this will be most relevant.
PROCEDURE select_from_schema( the_schema VARCHAR2) IS TYPE my_cursor_type IS REF CURSOR; my_cursor my_cursor_type; BEGIN OPEN my_cursor FOR 'SELECT my_field FROM '||the_schema||'.my_table'; -- Do your FETCHes just as with a normal cursor CLOSE my_cursor; END;
This needs to be done using dynamic sql.
DBMS_SQL, Execute Immediate.
FROM.
ALTER SESSION SET Current_Schema = '' < - , .
. SO, , SQL .
Source: https://habr.com/ru/post/1699368/More articles:How to clean files that are decrypted at runtime are cleared? - c ++Using RSpec for iPhone Controllers - ruby | fooobar.comWhy does SSRS ignore data from specific columns returned by the web method? - soapLinq to XML: XElement.Save to file - c #NHibernate - populates one property from a stored procedure - nhibernateWhat is the best way to export your own data to Excel without introducing an Office dependency? - excelWhat is the best practice for providing JSON data in JSP? - javaWhere is the best place to create and close a Silverlight WCF service using a Silverlight application? - web-servicesWhat is the best way to implement a friendly URL in ASP.net? - asp.netHack search to prevent application rewriting without using session variables - session-variablesAll Articles