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
Tags: Database
Similar Questions
-
How to create the cursor in a stored procedure
How to create the slider in the stored procedure. I want a simple example
procedure - cursor - open-fetch - insert - last slider farm
any idea or examples... Please help friends
Thanks in advanceHello
Search for explicit cursors in this link
http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/static.htm#insertedID2
Kind regards
Prazy -
How to create a table in a stored procedure
Please help me to answer the following question...
How to create a table inside the stored procedure... I want a detailed explanation... Please help mePlease see this link:
http://tinyurl.com/cmq5vo -
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 -
Creating classic report to the stored procedure.
How can we create a report based on a stored procedure out parameter.
Can someone please help.
Thank you
Nani.
Nani4850 wrote:
Out parameter is a multi-level object type.
I found a way to sort of basis a report on the parameter OUT procedure. The approach is:
1. call the procedure in a process before PL/SQL areas, convert the object returned in an XML document and store in a collection XMLType column:
declare k_rate_query varchar2(255) := 'RATE_QUERY'; l_rate_type_code number; l_rate_query rate_rec; l_xml xmltype; l_seq_id number; begin l_rate_type_code := to_number(:p1_rate_type_code); api_pkg.rate_query(l_rate_type_code, l_rate_query); l_xml := xmltype.createXML(l_rate_query); if not apex_collection.collection_exists(k_rate_query) then apex_collection.create_collection(k_rate_query); end if; select seq_id into l_seq_id from apex_collections where collection_name = k_rate_query and n001 = l_rate_type_code; apex_collection.update_member_attribute(k_rate_query, l_seq_id, 1, l_xml); exception when no_data_found then apex_collection.add_member( p_collection_name => k_rate_query , p_n001 => l_rate_type_code , p_xmltype001 => l_xml); end;
2. use a SQL/XML query on the XML collection in the region report source:
select rq.* from apex_collections ac , xmltable( '/RATE_REC/RATE_TBL/RATE_REC_TYPE' passing ac.xmltype001 columns action_code varchar2(20) path 'ACTION_CODE' , rate_key number path 'RATE_KEY' , rate_type_code varchar2(5) path 'RATE_TYPE_CODE' , program_key varchar2(12) path 'PROGRAM_KEY' , rate number(8,5) path 'RATE' , effective_date date path 'EFFECTIVE_DATE' , current_yn varchar2(1) path 'CURRENT_YN' , non_current_dt date path 'NON_CURRENT_DT' , non_current_by_id varchar2(4) path 'NON_CURRENT_BY_ID' , non_current_reason varchar2(400) path 'NON_CURRENT_REASON') rq where ac.collection_name = 'RATE_QUERY' and ac.n001 = to_number(:p1_rate_type_code)
-
A loop dynamic sql in the procedure
Hi guys,.
I'm having a procedure that will have two input start_date and end_date parameters
I need a loop in alter procedure statement something like this using dynamic sql
CHANGE TABLE M1
SWAP PARTITION FOR (TO_DATE('01-JAN-2015','dd-MON-yyyy'))
WITH TABLE T2
INCLUDING THE INDEX;
CHANGE TABLE M1
BY EXCHANGE COMPETITION FOR (TO_DATE('02-JAN-2015','dd-MON-yyyy'))
WITH TABLE T3
INCLUDING THE INDEX;
.
.
.
For example I have dates in setting something like January 1, 2015-4 January 2015
I need something like this, where T is a constant variable, I need to add T1, T2. T3 according to the dates of the range.
Hello
your procedure can not simply be rolled up, but the call session can be rolled up the output to a file.
Try something like this
col act_date noprint new_value act_date SET TERMOUT OFF select to_char(sysdate, 'yyyy_mm_dd_hh24miss') act_date from dual; SET TERMOUT ON set serveroutput on set feedback off set linesize 3000 col statement for a200 heading "-- alter statements" spool d:\temp\&act_date._&_CONNECT_IDENTIFIER._alter_partition.sql -- exec your_procedure -- or simple plain sql with data (start_date, end_date) as ( select to_date('01/01/2016', 'dd/mm/yyyy'), to_date('05/01/2016', 'dd/mm/yyyy') from dual ) select --level, to_char(start_date + (level - 1), 'dd-MON-yyyy' ) cur_date 'ALTER TABLE M1 EXCHANGE PARTITION FOR (TO_DATE(''' || to_char(start_date + (level - 1), 'dd-MON-yyyy' ) || ''',''dd-MON-yyyy'')) WITH TABLE T2 INCLUDING INDEXES;' || chr(10) || 'ALTER TABLE M1 EXCHANGE PARTITION FOR (TO_DATE(''' || to_char(start_date + (level - 1), 'dd-MON-yyyy' ) || ''',''dd-MON-yyyy'')) WITH TABLE T3 INCLUDING INDEXES;' as statement from data connect by level <= end_date - start_date + 1; spool off set feedback on prompt @d:\temp\mk_alter.sql
concerning
Kay -
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
-
SQL Server, stored procedure call error
Using the JDBC Service to call a stored procedure causes an error. A simple statement execution using SQL that connects on the same SQL database server works as expected.
CALL PAF_SAVE_FORMDATA (?,?)
At the call of my approach, I refer the following error below. Any help would be appreciated.
ALC-DSC-005-000: com.adobe.idp.dsc.DSCNotSerializableException: no serializable
Caused by: ALC-DSC-000-000: com.adobe.idp.dsc.DSCRuntimeException: internal error.
at com.adobe.idp.dsc.transaction.impl.ejb.EjbTransactionProvider.execute (EjbTransactionProvi der.java:207)
at com.adobe.idp.dsc.transaction.impl.DefaultTransactionTemplate.execute (DefaultTransactionT emplate.java:79)
at com.adobe.idp.workflow.dsc.invoker.WorkflowDSCInvoker.handleFault (WorkflowDSCInvoker.java:752)
at com.adobe.idp.workflow.dsc.invoker.WorkflowDSCInvoker.transientInvoke (WorkflowDSCInvoker. java: 366)
at com.adobe.idp.workflow.dsc.invoker.WorkflowDSCInvoker.invoke(WorkflowDSCInvoker.java:157)
at com.adobe.idp.dsc.interceptor.impl.InvocationInterceptor.intercept (InvocationInterceptor. java: 140)
at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed (RequestInterceptor ChainImpl.java:60)
to com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor$ 1.doInTransaction (Transa ctionInterceptor.java:74)
at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterBean.execute (EjbTr ansactionCMTAdapterBean.java:342)
at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterBean.doRequiresNew (EjbTransactionCMTAdapterBean.java:284)
at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EJSLocalStatelessEjbTransactionCMTAdapter_ caf58c4f.doRequiresNew (unknown Source)
at com.adobe.idp.dsc.transaction.impl.ejb.EjbTransactionProvider.execute (EjbTransactionProvi der.java:143)
at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor.intercept (TransactionInt erceptor.java:72)
at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed (RequestInterceptor ChainImpl.java:60)
at com.adobe.idp.dsc.interceptor.impl.InvocationStrategyInterceptor.intercept (InvocationStra tegyInterceptor.java:55)
at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed (RequestInterceptor ChainImpl.java:60)
at com.adobe.idp.dsc.interceptor.impl.InvalidStateInterceptor.intercept (InvalidStateIntercep tor.java:37)
at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed (RequestInterceptor ChainImpl.java:60)
at com.adobe.idp.dsc.interceptor.impl.AuthorizationInterceptor.intercept (AuthorizationInterc eptor.java:132)
at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed (RequestInterceptor ChainImpl.java:60)
at com.adobe.idp.dsc.interceptor.impl.JMXInterceptor.intercept(JMXInterceptor.java:48)
at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed (RequestInterceptor ChainImpl.java:60)
at com.adobe.idp.dsc.engine.impl.ServiceEngineImpl.invoke(ServiceEngineImpl.java:115)
at com.adobe.idp.dsc.routing.Router.routeRequest(Router.java:118)
at com.adobe.idp.dsc.provider.impl.base.AbstractMessageReceiver.invoke (AbstractMessageReceiv er.java:315)
at com.adobe.idp.dsc.provider.impl.soap.axis.sdk.SoapSdkEndpoint.invokeCall (SoapSdkEndpoint. java: 138)
at com.adobe.idp.dsc.provider.impl.soap.axis.sdk.SoapSdkEndpoint.invoke (SoapSdkEndpoint.java:81)
at sun.reflect.GeneratedMethodAccessor178.invoke (unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1087)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.adobe.idp.dsc.provider.impl.soap.axis.InvocationFilter.doFilter (InvocationFilter.java:43)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter (FilterInstanceWrapper.java: 190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:837)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:680)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:524)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest (CacheServletWrapper.jav one: 90)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:751)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:125)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination (HttpInboundLink .java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation (HttpInboundLink .java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators (NewConn ectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete (NewConnectionInitia lReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted (AioReadCompletionLi stener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
to com.ibm.io.async.AsyncChannelFuture$ 1.run(AsyncChannelFuture.java:205)
to com.ibm.ws.util.ThreadPool$ Worker.run (ThreadPool.java:1497)
Caused by: com.ibm.websphere.csi.CSITransactionRolledbackException: rollbackonly marked Transaction
at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:200)
at com.ibm.ejs.csi.RequiresNew.postInvoke(RequiresNew.java:93)
at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3986)
at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EJSLocalStatelessEjbTransactionCMTAdapter_ caf58c4f.doRequiresNew (unknown Source)
at com.adobe.idp.dsc.transaction.impl.ejb.EjbTransactionProvider.execute (EjbTransactionProvi der.java:143)
... more than 65at com.adobe.idp.dsc.provider.impl.base.AbstractResponseHolder.handleException (AbstractRespo nseHolder.java:136)
at com.adobe.idp.dsc.provider.impl.soap.axis.sdk.SoapSdkBindingStubUtil.deSerializeResponse (SoapSdkBindingStubUtil.java:122)
at com.adobe.idp.dsc.provider.impl.soap.axis.sdk.SoapAxisDispatcher.doSend (SoapAxisDispatche r.java:128)
at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send (AbstractMessageDispat dear .java: 57)
at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:208)
at com.adobe.common.utils.invoke.InvokeWithProgressRunner.invokeServiceOperation (InvokeWithP rogressRunner.java:170)
at com.adobe.common.utils.invoke.InvokeWithProgressRunner.run (InvokeWithProgressRunner.java: 97)
to org.eclipse.jface.operation.ModalContext$ ModalContextThread.run (ModalContext.java:113)The call should be at {} as {CALL PAF_SAVE_FORMDATA (?,?)}
did you?
Nith
-
Dynamic insertion within the procedure error
Hi allI use under oracle database on HP - UX.
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE Production 10.2.0.5.0
AMT for HP - UX: 10.2.0.5.0 - Production Version
NLSRTL Version 10.2.0.5.0 - ProductionI'm not able to run the procedure below and it returns the error. The insert in the procedure returns error. If I execute manually only the insert statement, it works well.
Can someone help me with this issue?Procedure
===========
create or replace procedure test_proc
as
v_sql varchar2 (2000);
Start
v_sql: =' insert into TABLE1 (select owner, object_type, object_name, "S", "Y" of dba_objects@LINK1 )
where owner = "ABC" and object_type = "TABLE" less
Select the owner, object_type, object_name, "S", "Y" from dba_objects where owner = "ABC" and object_type = "TABLE") ';immediately run v_sql;
commit;
end;
/exec test_proc;
Error:
===========ERROR on line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SYSTEM. TEST_PROC", line 8
ORA-06512: at line 1user running this procedure doesn't have permission to read data from DBA_OBJECTS. Grant select permission on that to the user running this procedure and it should work.
Onkar
-
creating a dynamic list within a static list
Hello
I use 5 APEX with universal theme and so I have the static navigation on the left side menu.
I have the following in the list:
Orders
Admin
View profile
It is a static so each link to a page of the list.
However I want to have it so that when I click on the controls bind it then displays a dynamic list of the commands in the menu, then it should look like this,
Orders
Order 1
Order 2
Order 3
Admin
View profile
So I have a dynamic list that creates the list commands. How can I "attach" it in the static so that the parent is the link of orders in the static list?
Thanks for your help.
Jeremy
Jezzer says:
I use 5 APEX with universal theme and so I have the static navigation on the left side menu.
I have the following in the list:
Orders
Admin
View profile
It is a static so each link to a page of the list.
However I want to have it so that when I click on the controls bind it then displays a dynamic list of the commands in the menu, then it should look like this,
Orders
Order 1
Order 2
Order 3
Admin
View profile
So I have a dynamic list that creates the list commands. How can I "attach" it in the static so that the parent is the link of orders in the static list?
If none of the entries in the list are dynamic, then the entire list must be dynamic. See using lists/Navigation Menu to universal theme APEX5 for a similar scenario.
-
Creating a table using a stored procedure, error
MY querry is as follows:
create or replace
PROCEDURE New_Account_Activations)
MYDATE_DD OUT VARCHAR2,
MYDATE_MM OUT VARCHAR2,
MYDATE_YYYY OUT VARCHAR2,
MYDATE OUT VARCHAR2,
VAR1 OUT VARCHAR2,
VAR2 OUT VARCHAR2,
VAR3 OUT VARCHAR2,
TABLE_NAME OUT VARCHAR2) ISBEGIN
SELECT TO_CHAR (SYSDATE-2, 'YYYY') INTO MYDATE_YYYY FROM DUAL;
SELECT TO_CHAR (SYSDATE-2, "MM") INTO MYDATE_MM FROM DUAL;
SELECT TO_CHAR (SYSDATE-2, 'DD') INTO MYDATE_DD FROM DUAL;
MYDATE: = MYDATE_YYYY | MYDATE_MM | MYDATE_DD | '000000.000Z';
-TABLE_NAME: = "NEWACCOUNTACTI_TEST";
VAR1: = 'B ';.
VAR2: = 'A ';
VAR3: = 'Y ';
Table_name: = "NewAccountActi" | '_' || MYDATE_YYYY | '_'|| MYDATE_MM | '_'|| MYDATE_DD;
run immediately "CREATE TABLE tbl_name AS SELECT * FROM NEWACCOUNTACTI_TEST WHERE 1 = 0';"END;
ERRORS
ORA-01031: insufficient privileges
ORA-06512: at "JACK. NEW_ACCOUNT_ACTIVATIONS', line 21
ORA-06512: at the level of line 12
Process is complete.
WRONG FORUM!
This forum is for Sql Developer issues only. Please mark the thread ANSWERED and repost it in SQL and PL/SQL forum.
https://forums.Oracle.com/community/Developer/English/oracle_database/sql_and_pl_sql
As says the Exception, your user JACK does NOT CREATE TABLE privileges granted DIRECTLY to them (not through a role) on the NEWACCOUNTACTI_TEST table. Grant privileges directly to the user.
If that does not meet your question repost your question in the forum; do NOT here.
-
Create the user of the stored procedure.
Hi, look at this and tell me where is the error:
Oracle 10g R2 datbase.
Conn SYS AS SYSDBA
****************************
create user HR22 identified by HR22;
create or replace
change_password procedure)
p_password varchar2)
as
Start
run immediately 'edit user' | the user: ' identified by ' | p_password;
end;
/
****************************
GRANT CONNECT, CHANGE USER TO HR22;
GRANT EXECUTE ON change_password to HR22;
Disc;
CONN HR22/HR22
execute SYS.change_password ('DATA');
Error: Privileges insuficients.
Roberto.Hello..
When performing a procedure, the procedure works as the owner of the procedure. In this case, Don t you must assign the 'ALTER USER' privilege to the user HR22; You must assign the user owner of the procedure in your sys case username.
You example...
SYSTEM@> create user HR22 identified by HR22; User created. SYSTEM@> create or replace 2 procedure change_password( 3 p_password varchar2) 4 as 5 6 begin 7 execute immediate 'alter user '||user||' identified by ' ||p_password; 8 end; 9 / Procedure created. SYSTEM@> GRANT CONNECT TO HR22; Grant succeeded. SYSTEM@> SYSTEM@> grant alter user to system; Grant succeeded. SYSTEM@> SYSTEM@> GRANT EXECUTE ON change_password TO HR22; Grant succeeded. SYSTEM@> conn HR22@db Enter password: **** Connected. HR22@> exec system.change_password('new'); PL/SQL procedure successfully completed.
Published by: dask99 on December 23, 2008 16:31
Additional test cases -
Tables created in a stored procedure cannot be used with dynamic SQL? The impact?
There is a thread on the forum which explains how to create tables within a stored procedure (How to create a table in a stored procedure , however, it does create a table as such, but not how to use it (insert, select, update, etc.) the table in the stored procedure.) Looking around and in the light of the tests, it seems that you need to use dynamic SQL statements to execute ddl in a stored procedure in Oracle DB. In addition, it also seems that you cannot use dynamic SQL statements for reuse (insert, select, update, etc.) the table that was created in the stored procedure? Is this really the case?
If this is the case, I am afraid that if tables cannot be 'created and used"in a stored procedure using the dynamic SQL, as is the case with most of the servers of DB dynamic SQL is not a part of the implementation plan and, therefore, is quite expensive (slow). This is the case with Oracle, and if yes what is the performance impact? (Apparently, with Informix, yield loss is about 3 - 4 times, MS SQL - 4 - 5 times and so on).
In summary, tables created within a stored procedure cannot be 'used' with dynamic SQL, and if so, what is the impact of performance as such?
Thank you and best regards,
Amedeo.
Published by: AGF on March 17, 2009 10:51AGF says:
Hi, Frank.Thank you for your response. I understand that the dynamic SQL is required in this context.
Unfortunately, I am yet to discover "that seeks to" using temporary tables inside stored procedures. I'm helping a migration from MySQL to Oracle DB, and this was one of the dilemmas encountered. I'll post what is the attempt, when more.
In Oracle, we use [global temporary Tables | http://www.psoug.org/reference/OLD/gtt.html?PHPSESSID=67b3adaeaf970906c5e037b23ed380c2] aka TWG these tables need only be created once everything like a normal table, but they act differently when they are used. The data inserted in TWG will be visible at the session that inserted data, allowing you to use the table for their own temporary needs while not collide with them of all sessions. The data of the TWG will be automatically deleted (if not deleted programmatically) when a) a commit is issued or b) the session ends according to the parameter that is used during the creation of the TWG. There is no real need in Oracle to create tables dynamically in code.
I noticed that many people say that the "Creation of the tables within a stored procedure" is not a good idea, but nobody seems necessarily explain why? Think you could elaborate a little bit? Would be appreciated.
The main reason is that when you come to compile PL/SQL code on the database, all explicit references to tables in the code must correspond to an existing table, otherwise a djab error will occur. This is necessary so that Oracle can validate the columns that are referenced, the data types of those columns etc.. These compilation controls are an important element to ensure that the compiled code is as error free as possible (there is no accounting for the logic of programmers though ;)).
If you start to create tables dynamically in your PL/SQL code, so any time you want to reference this table you must ensure that you write your SQL queries dynamically too. Once you start doing this, then Oracle will not be able to validate your SQL syntax, check the types of data or SQL logic. This makes your code more difficult to write and harder to debug, because inevitably it contains errors. It also means that for example if you want to write a simple query to get that one out in a variable value (which would take a single line of SQL with static tables), you end up writing a dynamic slider all for her. Very heavy and very messy. You also get the situation in which, if you create tables dynamically in the code, you are also likely to drop tables dynamically in code. If it is a fixed table name, then in an environment multi-user, you get in a mess well when different user sessions are trying to determine if the table exists already or is the last one to use so they can drop etc. What headache! If you create tables with table names, then variable Dynamics not only make you a lot end up creating (and falling) of objects on the database, which can cause an overload on the update of the data dictionary, but how can ensure you that you clean the tables, if your code has an exception any. Indeed, you'll find yourself with redundant tables lying around on your database, may contain sensitive data that should be removed.
With the TWG, you have none of these issues.
Also, what is the impact on the performance of the dynamic SQL statements in Oracle? I read some contrasting opinions, some indicating that it is not a lot of difference between static SQL and SQL dynamic in more recent versions of Oracle DB (Re: why dynamic sql is slower than static sql is this true?)
When the query runs on the database, there will be no difference in performance because it is just a request for enforcement in the SQL engine. Performance problems may occur if your dynamic query is not binding variable in the query correctly (because this would cause difficult analysis of the query rather than sweet), and also the extra time, to dynamically write the query running.
Another risk of dynamic query is SQL injection which may result in a security risk on the database.
Good programming will have little need for the tables of dynamically created dynamically or SQL.
-
How to convert MS SQL Server 2008 Stored Procedures of Oracle 11 g SPs?
We have an application from MS SQL Server 2008. We want to migrate to Oracle 11 g.
What is the recommended Oracle method for
(1) migration of data (Tables, triggers, sequences, views etc..)
(2) the stored Procedure migration.
What is the recommended tool or method pls?
We have 100s of MS Sql Server stored procedures. Then, needing a tool or method. We can rewrite all of them from scratch.Hello
Let me clarify some of the issues that you mention. But I advise you to get some professional help with migration because:
1. you must understand the architectural differences between SQL Server and Oracle. They are of different databases.
2. understand data type mappings.
3. understand the complete migration process. Just using the OTN article as a migration guide won't help because it just shows how use SQL Developer to this task.
4. understand that 100% of successful Oracle conversion is not possible with all the tools. There will always be gaps, gaps in functionality, bugs etc. So there will be some amount of manual work involved.
5. There are many other tasks involved in the migration that cannot be accomplished with SQL Developer.Get now your questions:
1. in 3.1, there is migration option for the "capture of database in offline mode". It is under the Tools option. So in 3.1 we do not have a separate tab, called "Migration."
2. use 3.1 because it is much better than 2.1 in terms of capabilities.
3 migration Wizard is the easiest way to migrate. Where are you getting confused?
4 "column data" seems to be a stored procedure in SQL Server. If it is not there in the underlying table, why he uses in the SQL statement in the procedure then? I think that we have a problem of "reserved word" with the name of column "Data". Will have to check that.
5 VARCHAR (@max) must be mapped to VARCHAR2 (4000) in Oracle. It may be a bug in SQL Developer. So during the mapping of data type in the migration wizard, you can change the default mappings.Concerning
Prakash
-
BPEL does not receive "return value" of MS SQL, stored procedure
Hello
We are facing this problem citing a MS SQL stored procedure the BPEL (jdbc 1.2 driver). We have created the wsdl for the stored procedure correctly using a command line utility tool provided with Oracle SOA Suite.
But the question is THAT BPEL is not able to get the data present in the statement of "return" of the procedure. We receive null output. But it is able to extract the data from the output variable, if any. Case 1 below is for the return statement. Case 2 is for the output variable
Case 1: in the following, the output is returned using the return statement. The BPEL that calls this procedure is to obtain a NULL value as an answer to this.
ALTER PROCEDURE [dbo]. [AddNumbersRet]
-Add the parameters for the procedure
@Number1 int,
@Number2 int
AS
BEGIN
-SET NOCOUNT ON added to avoid additional results sets from
-interfering with SELECT statements.
SET NOCOUNT ON;
-Controls insert for procedure here
Return (@Number1 + @Number2);
END
Case 2: in the following, the output is returned using the SumOfNums output variable. The BPEL that calls this procedure is to obtain a correct answer.
ALTER PROCEDURE [dbo]. [AddNumbers]
@Number1 int,
@Number2 int,
@SumOfNums int output
AS
BEGIN
-SET NOCOUNT ON added to avoid additional results sets from
-interfering with SELECT statements.
SET NOCOUNT ON;
Set @SumOfNums = (@Number1 + @Number2);
END
Case 1 is a failure and case 2 is successful. We cannot change our procedures similar to case 1 to use variables of output because of dependencies on other applications.
All the world is facing this problem? This looks like a bug in BPEL. Please, share your experiences.
Thanks and greetings
Mohan
Published by: user10980910 on December 8, 2009 05:16There is a gap in the command line utility that was addressed in the adapter configuration (AS11gR1) Wizard. The API is a procedure, not a function, so does not return the query for the parameters that the utility made anything for the RETURN statement.
The adapter configuration wizard is unable to say if there is a RETURN statement either, but it provides the user with a check box that can be used to indicate the presence of the declaration. In the wizard, if you check the checkbox, a parameter is added to the XSD to the RETURN statement. In essence, the adapter will process the procedure as a function and you will get the value of the PERFORMANCE.
Usually, I wish to indicate that you certainly should NOT change the generated XSD. But you might be able to do it, by adding the necessary element to the OutputParameters for your RETURN statement. Add the following immediately AFTER the element of 'Lines', which occurs first in the XSD and BEFORE all items for the other none.
Use a value for the "
" that is meaningful to you. The wizard uses the name of the stored procedure with the name of the element. We could call this "RETURN_VALUE" or else if is more to your liking. Add the item after you generate the XSD using the command line utility, and then use the XSD when you model your BPEL processes. The WSDL should already have the content for this element handling.
Maybe you are looking for
-
Tecra M3 - BSOD if I install the graphics driver
I bought a Tecra M3 about 4 years ago. He has recently started to give the BSOD. I started in safe mode, and it is fine. I uninstalled the graphics driver and rebooted and it works - just without the graphics driver. As soon as I reinstall the graphi
-
Need a little help to understand the features of measure or-scope
-
HP EliteBook 8560w Win8.1 does not fingerprint IE11
CZE: Hi, Vlastnim for laptop HP EliteBook 8560w u Saada jsem provedl update na CZE Win 8.1 Pro x 64. Bohužel in. installation nastroje HP Password Manager 8.0.1.1328 a jeho současti v IE11 přihlašovani nefunguje mi. Přihlašeni počitače funguje v pořa
-
9050: HP LaserJet 9050 printer
Could you help me check it is this model can be printing/scanning through wireless? Could you let me know the wireless configuration link where? Best regards
-
where can I find driver DVD digital copy protection, decoder, card vidio
When I try to play a vidio on windows media player, I get an error message that I need to update my DVD decoder, digital copy protection and vidio card. I don't know how to do this.