Views of functions or stored procedures
Hi all
11.2.0.3.10
AIX6
Y at - he views $ v for stored procedures that list the tables that are accessed by it?
Thank you
MK
user_ | all_ | dba_dependencies
You seem to specialize in issues for which you can find the answer yourself, with little effort, the so-called 'questions doc '.
Sooner or later people here refuse to answer your questions.
Sybrand Bakker
Senior Oracle DBA
Tags: Database
Similar Questions
-
Creating views, dynamic SQL within stored procedure
I'm having a problem with the creation of dynamic views of in a stored procedure. The following declare block works fine:
DECLARE
parameter i_nom_table varchar2 (200): = 'abc ';
xyz cursor script, SELECT step
STARTING from scripts
WHERE table_name = i_nom_table parameter
ORDER BY step CAD;
l_sql scripts.script%TYPE;
l_step scripts.step%TYPE;
l_error VARCHAR2 (200);
l_code VARCHAR2 (200);
Start
XYZ OPEN;
LOOP
XYZ-FETCH INTO l_step, l_sql;
OUTPUT WHEN xyz % NOTFOUND;
immediately run l_sql;
insert into ingest_log values (null, sysdate, i_nom_table, l_step, l_sql, 'Success' parameter);
END LOOP;
CLOSE XYZ;
insert into ingest_log values (null, sysdate, parameter i_nom_table, 0, "Accomplished all the steps.", "Success");
EXCEPTION WHEN OTHERS THEN
l_error: = substr (SQLERRM, 1, 200);
l_code: = SQLCODE;
insert into ingest_log values (null, sysdate, parameter i_nom_table, l_step, l_sql, l_code |) ' - ERROR - ' | l_error);
END;
However, if I create a procedure with this block and try to run it I get an insufficient privileges error. Do not know why. All tables, views, procedures are under the same user, and the user that I'm connected as the runtime of the declare block. The user has the following privileges:
Connect, resource, xdbadmin, s/n
Any reason you can think of for this? Script values are generally "CREATE OR REPLACE VIEW As.... » ;Permissions in Oracle to do indirectly through roles are not available when compiling packages, functions, and stored procedures. Direct subsidies are required during the creation of these objects in the database.
http://articles.TechRepublic.com.com/5100-10878_11-6183799.html
-
How to query the DDL lock functions or stored procedures and packages?
Hello!
The subject says it all: how to display existing DDL locks on the functions or stored procedures and packages?
While running a procedure, it cannot be deleted or replaced, so there must be a DDL lock on it. The information does not seem to be in V$ LOCK or V$ LOCKED_OBJECTS.
Thank you!
Marcus
Published by: David on November 21, 2009 15:43Hello
You have the DBA_DDL_LOCKS view.
Best regards
Jean Valentine -
Materialized view, based on the stored procedure
Hi all
is it possible to create a materialized view on the results returned by a stored procedure?
If this is not the case, do you think that any other way except for filling a table with data from the stored procedure and then founded the MV on it?
Thanks in advance.
MichaelTsilikidis wrote:
Sorry I don't speak properly. In fact the procedure does not return a value, it fills one of its parameters (of the ref cursor type) of data. That's what I wanted.
No it's not.
REF CURSOR don't store data, so it's not possible.
A Ref cursor is just a pointer to a query... and you can't "select from" a ref cursor, you can retrieve only one open.
PL/SQL 101: Understand the Ref Cursor
As correctly stated above, you can't question from a procedure to a function, and a materialized view is based on a query, you cannot use a procedure in a materialized view.
You could use a function pipeline instead of a procedure, or have the pipeline function obtain the results of the procedure and pipelines, and then the materialized view could be based on the results of this function in the pipeline.
example of function pipeline:
SQL > CREATE or REPLACE TYPE AS OBJECT num_descript (num number, descript varchar2 (30))
2.Type of creation.
SQL >
SQL > CREATE or REPLACE TYPE tbl_num_descript AS TABLE OF THE num_descript
2.Type of creation.
SQL >
SQL >
SQL > CREATE or REPLACE PACKAGE AS-reftest
2 FUNCTION pipedata (number p_choice) tbl_num_descript RETURN PIPELINED;
3 END;
4.Package created.
SQL >
SQL > CREATE or REPLACE PACKAGE BODY AS-reftest
2 FUNCTION pipedata (number p_choice) tbl_num_descript RETURN PIPELINED IS
3 v_obj num_descript: = num_descript (NULL, NULL);
4 v_rc sys_refcursor;
5 BEGIN
6. IF p_choice = 1 THEN
7 v_rc OPEN to SELECT empno as num, ename like descript FROM emp;
8 ELSIF p_choice = 2 THEN
9 OPEN v_rc to SELECT deptno as num, dname as descript OF THE Department;
10 END IF;
11 LOOP
12 FETCH v_rc INTO v_obj.num, v_obj.descript;
EXIT 13 WHEN v_rc % NOTFOUND;
14 PIPE ROW (v_obj);
15 END LOOP;
16 v_rc NARROW;
RETURN 17;
18 END;
END 19;
20.Package body created.
SQL > select * from table (reftest.pipedata (1));
DESCRIPT NUM
---------- ------------------------------
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
KING 7839
7844 TURNER
7876 ADAMS
JAMES 7900
7902 FORD
7934 MILLER14 selected lines.
SQL > select * from table (reftest.pipedata (2));
DESCRIPT NUM
---------- ------------------------------
10 ACCOUNTING
SEARCH 20
30 SALES
40 OPERATIONS -
Difference between function and stored procedure
Hi guys, I don't understand the exact difference between a function and a stored procedure. I have a lot of google but still. Can someone explain in simple terms. Thank you.Hello
Here is an example of a user-defined function:
CREATE OR REPLACE FUNCTION factorial ( in_num IN PLS_INTEGER ) RETURN PLS_INTEGER DETERMINISTIC IS BEGIN IF in_num IS NULL THEN RETURN NULL; ELSIF in_num <= 1 THEN RETURN 1; ELSE RETURN in_num * factorial (in_num - 1); END IF; END factorial; / SHOW ERRORS
This function returns an integer. You can use the function (or, more exactly, the integer returned) everywhere where a whole expression is allowed.
For exampleSELECT ROWNUM , factorial (ROWNUM) AS f , loc , SUBSTR ( loc , 1 , factorial (ROWNUM) ) AS s FROM scott.dept;
Output:
` ROWNUM F LOC S ---------- ---------- ------------- ------------- 1 1 NEW YORK N 2 2 DALLAS DA 3 6 CHICAGO CHICAG 4 24 BOSTON BOSTON
-
Function of stored procedure defined by the user of the appellant
Hi all -
I am trying to call a function defined by the user of a stored procedure. I'm using something like
the above is correct.IF condition1 THEN function1(param1, param2); END IF;
I have PLS-00221 function1 is not a stored procedure or is not defined?Well, if it is a function, you will need to assign its result value in a variable.
Like this:
DECLARE some_variable [of the right datatype]; ... IF condition1 THEN some_variable := function1(param1, param2); END IF;
-
Import data dictionary stored procedures
It's the rewamp of an old archived thread:
.. relevant even today with DataModeleter 4.1 (standalone) on Oracle 12 c: I seem not to be able to import any stored procedure / function of the well data dictionary that following the steps (see link) and reaching even to the summary confirming the detection of target objects:
However, at the time of the merger, previews DDL (to import/merge, no generation) says:
-CREATE THE PROCEDURE 0 -CREATE FUNCTION 0 Am I missing a trivial step?
THX
Hello
I think I know what is the cause of the problem.
There is a bug in version 4.1 where different types of objects (including functions and stored procedures) do not appear in the tree view to compare if the property "include physical properties to compare the feature ' is not defined.
So the solution is to ensure that this property is set. It is on the Data Modeler > DOF > DDL/comparison of preferences page.
This bug in the next version.
David
-
ADF view object and stored procedure
Hi all
I am facing a problem with the view object, the case is, I created a stored procedure with an input and an output parameter
view object I need to call this procedure inside the request object view and define the attribute transient output parameter
could you please help me in this case, please give an example
Thanks in advance
Mohamed,
Can you explain your use case to help you.
Is it possible to convert the stored procedure in function (and change the output parameter to return the parameters) and create a display object using the function.
Ex: Create a display object "read access only via the SQL query" for the query: SELECT HR. PLSQLTEST2 staff (first_name) OF
K
-
Required privilege to view the source code for the stored procedure
RDBMS Version: 11.2.0.4
Platform: Oracle Linux 6.4
In our Production database, we have an application schema named CRM_PROD. And we have a read-only user named steve in this PB.
Steve must be able to view the source code of all stored procedures, functions and packages in the CRM_PROD schema. But steve shouldn't be able to run these procedures, functions and packages in the CRM_PROD schema. What a privilege should give Steve for this?
SYS is owner of the dictionary of data and tables for the source code. See configuration of privilege and role authorization - 11 g Release 2 (11.2).
Select it no matter what dictionary grant will give user (read) access to the full data dictionary.
-
would you use a stored procedure or a function
Hello
I have a very long query. I reduced a large number of sections of it with views.
But now I have a section that is repeated several times, about 40 times. It is about 15 lines of SQL code.
The variation between these blocks are two fields which change their value and I always join the result of these blocks using the same ID.
Of course, I think I can extract in a central block (DRY) and call them from a main request, the question is how.
My first approach would be a stored procedure. But all the examples I found that you use some PL/SQL or Java, that I could also... but isn't it overkill?
The function?
Any recommendation?
Thank you!refer wrote:
who would do it, I guess that
now the newbie question: in the function block: how to assign select va1 and va2 from a query results in the attributes of the object? I couldn't find an example where this is demonstrated (if possible).I should have simplified:
create or replace function ma_fonction (a number, b varchar2) return my_type
as
my_type my_obj;
Start
-here:
Select val1, val2 from table1 - is always only one line
-my_obj: = my_type (a, b); -How can I assign those here?
Return my_obj;
end
;select my_type(val1,val2) into my_obj from table1;
Published by: Toon Koppelaars on February 24, 2011 10:16
-
Call of function/stored procedure of dashboards
Hi all
My requirement is to call a stored procedure /function of dashboard and display the result in the dashboard.
I created a function that takes in 2 dates and restores the lines in this date range
(1) creation of function
create or replace FUNCTION FUNC3 (BDATE TIMESTAMP, EDATE TIMESTAMP) return as sys_refcursor
R1 sys_refcursor;
BEGIN open for r1
SELECT * FROM EMP WHERE HIREDATE BETWEEN BDATE AND EDATE.
Return (R1);
END;
(2) created a dashboard quickly start date and the end date and the variable defined as variable presentation 'Pre_B1Date' & 'Pre_E1Date '.
(3) created a request directly to the database as
SELECT FUNC3 (to_date (' @{Pre_B1Date} ',' YYYY/MM/DD hh: mi PM'), to_date (' @{Pre_B1Date} ',' YYYY/MM/DD hh: mi PM')) FROM DUAL
(4) that I've created a dashboard with the above command prompt & demand live, but when I try to open the dashboard why the BI server is blocking down.
gave me an error
Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 12002] Communication to the socket call = recv error: (10054 = number) an existing connection has to be closed by the remote host. (HY000)
Publ. SQL: {call NQSGetQueryColumnInfo (' EXECUTE the PHYSICAL "Con pool Scott" CONNECTION POOL SELECT FUNC3 (to_date ("@{Pre_BDate}","YYYY/MM/DD hh: mi PM"), to_date ("@{Pre_BDate}","YYYY/MM/DD hh: mi PM")) FROM DUAL')}
have one never faced this problem?
or is there another way to call a funcation stored dashboards, /procedure
where you can pass the variables of the presentation and view the output put this /procedure function
Thank you
sangovYes.
You can't return a cursor in a column in a select statement. You must use a piplined function (also known as table function).
http://gerardnico.com/wiki/language/PLSQL/plsql_pipelined_functionYou'll find yourself with:
select * from FUNC3(BDATE,EDATE)
See you soon
NicoPublished by: gerardnico on July 31, 2009 11:35 remove the data type in the select
-
Internal error: catalog view incompatible when calling a stored procedure
Hello
I use JDeveloper 11.1.1.4
When you call a stored procedure from AppModuleImpl, I get this error internal error: inconsistent display catalog
I'll call the stored procedure of this way
String lErrCode;
String lErrMsg;
Result of an integer;
ARRAY inputArray = null;
Table STRUCT that can be passed to a PLSQL PROCEDURE
inputArray =
JdbcSqlMapper.preparePlSqlArrayUsingVOAttrbs (conn, recordType,
view, rm);
OracleCallableStatement st =
(OracleCallableStatement) conn.prepareCall ("{?}") = call ("+
procedureName +.
"(?,?,?))}");
st.registerOutParameter (1, Types.INTEGER);
st.setObject (2, inputArray, OracleTypes.ARRAY);
st.registerOutParameter (2, OracleTypes.ARRAY,
recordType.getTableType ());
st.registerOutParameter (3, Types.VARCHAR);
st.registerOutParameter (4, Types.VARCHAR);
St.Execute ();
I checked the subsidies for this package to all users. All users with grants to this package.
I don't know where I start to debug this issue.
Kindly help.
Thank you and best regards,
John.
Have yo uchecked the right of the types of data used (at least the TABLE) to the user (referred to Pokusak blog: JPublisher - incompatible catalog display)?
Timo
-
Create a stored procedure in the settings view
I want to be able to create a view with the parameters of a stored procedure.
Oracle 11g.
don't know how to use the variable in immediate execution.
CREATE OR REPLACE
PROCEDURE TEST_GENERIC (TBL IN VARCHAR2, VWNAME IN VARCHAR2)
AS
BEGIN
RUN IMMEDIATELY "CREATE OR REPLACE VIEW VWNAME AS SELECT SYSDATE FROM TBL";
COMMIT;
END;
exec ('BIRD', 'DUAL') TEST_GENERIC
Thanks for any help
Hello
Single quotes enclose a literal string; in other words, the text between the quotes literally means what it says, without reference to any variables.
So, when you say:
RUN IMMEDIATELY "CREATE OR REPLACE VIEW VWNAME AS SELECT SYSDATE FROM TBL";
CREATE the word literally means to CREATE. You may or may not have also a variable called CREATE, but that is irrelevant.
The word OR means OR literally. You may or may not have also a variable called operation GOLD, but that is irrelevant.
REPLACE the word literally means REPLACE. You may or may not have also a variable called to REPLACE, but that is irrelevant.
...
The TBL Word literally means TBL. You may or may not have also a variable called TBL, but that is irrelevant.
If you want to reference a variable called TBL, then use TBL outside single quotes, like this:
...
sql_text: = "CREATE or REPLACE VIEW VWNAME AS SELECT SYSDATE FROM '
|| TBL;
dbms_output.put_line (sql_text |) "= sql_text before EXECUTE IMMEDIATE'); -For debugging
EXECUTE IMMEDIATE sql_text.
...
On the rare occasions when you use dynamic SQL statements, always put the dynamic SQL statement in a string variable (for example, sql_text, above) so that you can easily display for debugging purposes and to ensure that the command you are viewing is the same exact command that you should run.
I guess the code you posted is a first test version of something that will be much, much different when it is finished. Creating objects from database (such as views) in PL/SQL is almost always a terrible idea, and it seems that opinion that this code is attempting to produce would be very useful, anyway.
-
With the help of Oracle 11 g
Front End .NET
To display the data on the front end, we must query the DB tables and display. In this case, that is the best solution - views or procedures stored?1 b says:
Is it okay that mantra?
SQL > PL/SQL > C > JAVA
and the view's SQL only, so it is better for performance reasons? TXYes. But the mantra in this case means not PL/SQL allows to read the rows in the view, copy (fetch) in a collection (residing in the expensive PGA in memory) and who returns to the caller.
It is false and so horribly.
The right approach would be for the appellant NOT to use the view.
Why? Because the appellant (program and app developer) need to understand the data model, need to understand SQL Oracle and the concepts of performance and so on.
If the data model or the view changes - the app program should also be updated.
This is why the use of a PL/SQL procedure is preferable. He resides in the database. (I hope), it is written by experienced database developers. The procedure can be modified to support the new features and changes to the data model, without having to touch a single line of code in the app program.
All the procedure has to do is accept the call by the app program, decide how to build the SQL (on the view/table/whatever) for the caller, create a SQL Server Shared pool cursor and then return the handle of the cursor (using a ref cursor data type) to the appellant.
Instead of the source of passage calling SQL for Oracle and get a cursor handle, the appellant seeks, so a PL/SQL procedure that returns the SQL cursor handle.
The app program is now abstract concepts and database layer techniques Oracle and SQL, recursive SQL, analytical Oracle performance, Oracle CBO advice and so on. The PL/SQL procedure takes care of all this.
This is why using a PL/SQL stored procedure would be a better choice that the client application dealing with the language of Oracle SQL and Oracle (such a view) in the database objects.
-
Simple question-how to call a stored procedure or function of apex?
Simple question-how to call a stored procedure or function of apex?
Thanks advance.
DougHi Doug,.
You can call a procedure or function of apex. It depends on what you want to do with the function or procedure. If you want to retrieve table data in a specific area, you can try something like this-The following statement creates the function get_bal on the oe.orders of sample table (PL/SQL is in italics):
CREATE FUNCTION get_bal (acc_no in NUMBER)
RETURN NUMBER
IS acc_bal NUMBER (11.2);
BEGIN
SELECT order_total
IN acc_bal
Orders
WHERE customer_id = acc_no;
Return (acc_bal);
END;
/The function created in the previous example can be used in a SQL statement. For example:
SELECT get_bal (165) FROM DUAL;
GET_BAL (165)
------------
2519hope this will help,
Kind regards
Pascal M
http://Tajuddin.whitepagesbd.com
Maybe you are looking for
-
I am running 10.10 Maverick Mercat and cannot get a more recent version of Firefox.
I can download Firefox 28 and extract the files, but nothing happens after that. I had to work, but it only lasted a few minutes and then back to Firefox 11.
-
How can I change Firefox 8 language from English to German
I want that Firefox 8 Beta in the GermanVersion
-
No storage has left my iPhone 6 even if I deleted a lot
I get this message that I have "no storage is left on my device. When I check my settings it says I have 0 bytes left. Then I noticed that it said that I have 2700 photos on my phone when I don't really have 250. Why? My phone looks full and I can st
-
Satellite M60-164 sometimes boot, sometimes not
I have what has been a fairly reliable Toshiba Satellite M60. A few weeks ago I tried to start and the power led came on the deflected light disc momentarily and the fan went. Within 2 to 3 seconds, the fan stopped, the drive light is also out. Durin
-
Cannot install updates Office Professional 2003 of three; gives me code error 57F
I have windows Vista Home Basic. Updates of the problem are updated to Windows Office Professional 2003 security. I have the set machine to download and install updates automatically. All other updates are downloading and the installation without