ORA-02393 in an APEX PL/SQL Procedure
Hi,
I have a PL/SQL procedure in APEX that runs queries against a remote Database using a DB link. I do multiple calls to the DB in a FOR LOOP query. The procedure is failing with the error: "ORA-02393: exceeded call limit on CPU usage"
I was wondering if this could be caused by the way that APEX handles db sessions. How or when does APEX close the db session? Or is it leaving it open?
Do you have any suggestions on how to close the DB session so I don't run into this error?
Appreciate your help.
Alejandro
You want to add this to your DAD
PlsqlMaxRequestsPerSession 100
Where 100 is the max number of requests a database session will serve before closing. 100 is just an example. The highest number you can have without causing the issue would be what you want.
By default, Mod_plsql uses a connection pool, and the default value is 1000 page serves prior to closing the session. PlsqlMaxRequestsPerSession will set that to the value specified.
Anton
Similar Messages
-
ORA-01458 error while using Pro*C to invoke PL/SQL procedure, pls help
I am using Pro*C (Oracle 10g on Itanium platform) to invoke PL/SQL procedure to read RAW data from database, but always encoutered ORA-01458 error message.
Here is the snippet of Pro*C code:
typedef struct dataSegment
unsigned short len;
unsigned char data[SIZE_DATA_SEG];
} msg_data_seg;
EXEC SQL TYPE msg_data_seg IS VARRAW(SIZE_DATA_SEG);
EXEC SQL BEGIN DECLARE SECTION;
unsigned short qID;
int rMode;
unsigned long rawMsgID;
unsigned long msgID;
unsigned short msgType;
unsigned short msgPriority;
char recvTime[SIZE_TIME_STRING];
char schedTime[SIZE_TIME_STRING];
msg_data_seg dataSeg;
msg_data_seg dataSeg1;
msg_data_seg dataSeg2;
short indSeg;
short indSeg1;
short indSeg2;
EXEC SQL END DECLARE SECTION;
qID = q_id;
rMode = (int)mode;
EXEC SQL EXECUTE
BEGIN
SUMsg.read_msg (:qID, :rMode, :rawMsgID, :msgID, :msgType, :msgPriority, :recvTime,
:schedTime, :dataSeg:indSeg, :dataSeg1:indSeg1, :dataSeg2:indSeg2);
END;
END-EXEC;
// Check PL/SQL execute result, different from SQL
// Only 'sqlcode' and 'sqlerrm' are always set
if (sqlca.sqlcode != 0)
if (sqlca.sqlcode == ERR_QUEUE_EMPTY) // Queue empty
throw q_eoq ();
char msg[513]; // Other errors
size_t msg_len;
msg_len = sqlca.sqlerrm.sqlerrml;
strncpy (msg, sqlca.sqlerrm.sqlerrmc, msg_len);
msg[msg_len] = '\0';
throw db_error (string(msg), sqlca.sqlcode);
and here is the PL/SQL which is invoked:
SUBTYPE VarChar14 IS VARCHAR2(14);
PROCEDURE read_msg (
qID IN sumsg_queue_def.q_id%TYPE,
rMode IN INTEGER,
raw_msgID OUT sumsg_msg_data.raw_msg_id%TYPE,
msgID OUT sumsg_msg_data.msg_id%TYPE,
msgType OUT sumsg_msg_data.type%TYPE,
msgPrior OUT sumsg_msg_data.priority%TYPE,
msgRecv OUT VarChar14,
msgSched OUT VarChar14,
msgData OUT sumsg_msg_data.msg_data%TYPE,
msgData1 OUT sumsg_msg_data.msg_data1%TYPE,
msgData2 OUT sumsg_msg_data.msg_data2%TYPE
) IS
BEGIN
IF rMode = 0 THEN
SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY sched_time, raw_msg_id)
WHERE ROWNUM = 1;
ELSIF rMode = 1 THEN
SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY recv_time, raw_msg_id)
WHERE ROWNUM = 1;
ELSE
SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY priority, raw_msg_id)
WHERE ROWNUM = 1;
END IF;
UPDATE sumsg_msg_data SET status = 1 WHERE raw_msg_id = raw_msgID;
EXCEPTION
WHEN NO_DATA_FOUND THEN
raise_application_error (-20102, 'Queue empty');
END read_msg;
where sumsg_msg_data.msg_data%TYPE, sumsg_msg_data.msg_data1%TYPE and sumsg_msg_data.msg_data2%TYPE are all defined as RAW(2000). When I test the PL/SQL code seperately, everything is ok, but if I use the Pro*C code to read, the ORA-01458 always happen, unless I change the SIZE_DATA_SEG value to 4000, then it passes, and the result read out also seems ok, either the bigger or smaller value will encounter ORA-01458.
I think the problem should happen between the mapping from internal datatype to external VARRAW type, but cannot understand why 4000 bytes buffer will be ok, is it related to some NLS_LANG settings, anyone can help me to resolve this problme, thanks a lot!It seems that I found the way to avoid this error. Now each time before I read RAW(2000) data from database, i initialize the VARRAW.len first, set its value to SIZE_DATA_SEG, i.e., the outside buffer size, then the error disappear.
Oracle seems to need this information to handle its data mapping, but why output variable also needs this initialization, cannot precompiler get this from the definition of VARRAW structure?
Anyone have some suggestion? -
Insertin Data useing SQL Procedure Getting Error ORA-00942 and ORA-06512
I have two Schemas ISYS and ISYSTWO
I had created a Stored Procedure RECINC2 in Schema ISYS
as
procedure recinc2(cName IN CHAR,cWhere IN CHAR,cTable in CHAR)
AS
cQry VARCHAR2(1000);
BEGIN
cQry := 'INSERT INTO '||cName||'.'||cTable||' SELECT * FROM '||cTable|| ' WHERE ||cWhere;
dbms_output.put_line(cqry);
EXECUTE IMMEDIATE cQry;
end;
NOW WHEN in Run it gives error
SQL> begin
2 recinc2('ISYSTWO','CODE=4','AGENTS');
3 end;
4 /
INSERT INTO ISYSTWO.AGENTS SELECT * FROM AGENTS WHERE CODE=4
begin
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "ISYS.RECINC2", line 8
ORA-06512: at line 2
BUT IF I EXECUTE
the DBMS output
INSERT INTO ISYSTWO.AGENTS SELECT * FROM AGENTS WHERE CODE=4
it executes and gives fine result
Please help
Thanks
Chaand kackriaSQL> conn ISYSTWO/ISYSTWO
Connected.
SQL> grant all on agents to isys;
Grant succeeded.
SQL> conn isys/isys
Connected.
SQL> exec recinc2('ISYSTWO','CODE=4','AGENTS');
INSERT INTO ISYSTWO.AGENTS SELECT * FROM AGENTS WHERE CODE=4
PL/SQL procedure successfully completed. -
ORA-02393 Exceeded Call Limit on CPU Usage
I have created a Profile and attached it to a user, in this example:
Create Profile percall
Limit
CPU_PER_CALL 10
IDLE_TIME 5;
I have attached it to one user - USER1
When USER1 runs a SQL Statement -
SELECT COUNT(*) FROM TABLE1 A WHERE A.EFFDT = (SELECT MAX(B.EFFDT) WHERE B.EMPLID = A.EMPLID AND B.EFFDT <= SYSDATE);
I get an error (Which I want to receive) ORA-02393 Exceeded Call Limit on CPU Usage.
The SQL statement shows in the table DBA_COMMON_AUDIT_TRAIL, but shows a success even though the user received an error ORA-02393.
What I want is a way for a DBA to be able to report on those ORA-02393 errors. I don't see any entries in the Log files, and don't notice any errors in the Oracle Tables.
I would like to be able to show the user (after a week when they bring up the issue) what the SQL statement was and why it Exceeded the CPU Usage. If the error could place the SQL statement in a table or just display it in an error log with the Statement to verify that THIS is the statement which exceeded the CPU Usage.
Thank you
Aaroncan you modify the procedure in which the SELECT resides.
If so, trap & log the error. -
Unable to capture the parameter values from a PL/SQL procedure
hi.
i'm trying to capture the parameter values of a PL/SQL procedure by calling inside a anonymous block but i'm getting a "reference to uninitialized collection error" ORA-06531.
Please help me regarding.
i'm using following block for calling the procedure.
declare
err_cd varchar2(1000);
err_txt VARCHAR2(5000);
no_of_recs number;
out_sign_tab search_sign_tab_type:=search_sign_tab_type(search_sign_type(NULL,NULL,NULL,NULL,NULL));
cntr_var number:=0;
begin
rt843pq('DWS','3000552485',out_sign_tab,no_of_recs,err_cd,err_txt);
dbms_output.put_line('The error is ' ||err_cd);
dbms_output.put_line('The error is ' ||err_txt);
dbms_output.put_line('The cntr is ' ||cntr_var);
for incr in 1 .. OUT_SIGN_TAB.count
loop
cntr_var := cntr_var + 1 ;
Dbms_output.put_line(OUT_SIGN_TAB(incr).ref_no||','||OUT_SIGN_TAB(incr).ciref_no||','||OUT_SIGN_TAB(incr).ac_no||','||OUT_SIGN_TAB(incr).txn_type||','||OUT_SIGN_TAB(incr).objid);
end loop;
end;
Error is thrown on "for incr in 1 .. OUT_SIGN_TAB.count" this line
Following is some related information.
the 3rd parameter of the procedure is a out parameter. it is a type of a PL/SQL table (SEARCH_SIGN_TAB_TYPE) which is available in database as follows.
TYPE "SEARCH_SIGN_TAB_TYPE" IS TABLE OF SEARCH_SIGN_TYPE
TYPE "SEARCH_SIGN_TYPE" AS OBJECT
(ref_no VARCHAR2(22),
ciref_no VARCHAR2(352),
ac_no VARCHAR2(22),
txn_type VARCHAR2(301),
objid VARCHAR2(1024))............We don't have your rt843pq procedure, but when commenting that line out, everything works:
SQL> create TYPE "SEARCH_SIGN_TYPE" AS OBJECT
2 (ref_no VARCHAR2(22),
3 ciref_no VARCHAR2(352),
4 ac_no VARCHAR2(22),
5 txn_type VARCHAR2(301),
6 objid VARCHAR2(1024))
7 /
Type is aangemaakt.
SQL> create type "SEARCH_SIGN_TAB_TYPE" IS TABLE OF SEARCH_SIGN_TYPE
2 /
Type is aangemaakt.
SQL> declare
2 err_cd varchar2(1000);
3 err_txt VARCHAR2(5000);
4 no_of_recs number;
5 out_sign_tab search_sign_tab_type:=search_sign_tab_type(search_sign_type(NULL,NULL,NULL,NULL,NULL));
6 cntr_var number:=0;
7 begin
8 -- rt843pq('DWS','3000552485',out_sign_tab,no_of_recs,err_cd,err_txt);
9 dbms_output.put_line('The error is ' ||err_cd);
10 dbms_output.put_line('The error is ' ||err_txt);
11 dbms_output.put_line('The cntr is ' ||cntr_var);
12 for incr in 1 .. OUT_SIGN_TAB.count
13 loop
14 cntr_var := cntr_var + 1 ;
15 Dbms_output.put_line(OUT_SIGN_TAB(incr).ref_no||','||OUT_SIGN_TAB(incr).ciref_no||','||OUT_SIGN_TAB(incr).ac_no||','||OUT_SIGN
TAB(incr).txntype||','||OUT_SIGN_TAB(incr).objid);
16 end loop;
17 end;
18 /
The error is
The error is
The cntr is 0
PL/SQL-procedure is geslaagd.Regards,
Rob. -
How to get data from URL in a PL/SQL procedure
Hi!<br>
<br>
I want to pass values in APEX from a report with a link to a PL/SQL procedure through URL.
How can I make this?<br>
<br>
For example:<br>
<br>
I have a report:<br>
<br>
select<br>
id,<br>
name,<br>
akt,<br>
case<br>
when akt is NULL then '< a href="f?p=&APP_ID.:27:&SESSION.:START_PROCESS" name="test_link" >set< /a >'<br>
end choice<br>
from<br>
USERS;<br>
<br>
I want to pass the value "id" in the link ( named "test_link" ) . And want to use this value in a process like this:<br>
<br>
DECLARE<br>
v_user_id NUMBER(10);<br>
BEGIN<br>
--I want to read this value from the url<br>
if :REQUEST='START_PROCESS' then<br>
v_user_id := ????;<br>
<br>
...<br>
end if;<br>
END;<br>
<br>
<br>
Thanks!<br>
MartonHi,
1- Create a hidden item P27_USER_ID on page 27
2- Change your code :
SELECT ID, NAME, akt,
CASE
WHEN akt IS NULL
THEN '< a href="f?p=&APP_ID.:27:&SESSION.:START_PROCESS:NO::P27_USER_ID:'
|| ID
|| '" name="test_link" >set< /a >'
-- refer to f?p=App:Page:Session:Request:Debug:ClearCache:itemNames:itemValues:PrinterFriendly
END choice
FROM users;
And then
DECLARE
v_user_id NUMBER (10);
BEGIN
--I want to read this value from the url
IF :request = 'START_PROCESS'
THEN
v_user_id := :p27_user_id;
--your code
END IF;
END;Hope this helps,
Grégory -
How to secure a PL/SQL procedure that is called from the web browser
If you have ever seen the sample document management application, and tried to download a file that was stored in the system, you are probably familiar with the apex_util.count_click URL that is used to download the file. If you copy that URL and paste it into a new browser, you will not be prompted to login to download the requested file. I'm using SSO with Apex as a partner application. How can I secure a pl/sql procedure like this to redirect to the login page before beginning the download?
Thanks,
KrisYou can use the second method described here:
http://apex.oracle.com/pls/otn/f?p=31517:15
You would use an application process instead of pasting the procedure call in the browser. In the case I describe, you don't need to grant execute to public on the download procedure.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Error when try to call a pl/sql procedure from the .xsql file
I tried to call a pl/sql procedure like this:
<?xml version="1.0"?>
<page connection="omtest5" xmlns:xsql="urn:oracle-xsql">
<xsql:include-owa>
sampleowaxml.testone
</xsql:include-owa>
</page>
but I got the following error message:
<?xml version="1.0" ?>
- <page>
- <xsql-error action="xsql:include-owa">
<statement>declare buf htp.htbuf_arr; param_names owa.vc_arr; param_values owa.vc_arr; rows integer := 32767; outclob CLOB;begin param_names(1) := 'HTTP_COOKIE'; param_values(1) := ''; param_names(2) := 'SERVER_NAME'; param_values(2) := 'mxfang-nt.us.oracle.com'; param_names(3) := 'SERVER_PORT'; param_values(3) := '80'; param_names(4) := 'SCRIPT_NAME'; param_values(4) := '/servlets/oracle.xml.xsql.XSQLServlet'; param_names(5) := 'PATH_INFO'; param_values(5) := '/xsql/test/myproject.xsql'; param_names(6) := 'HTTP_USER_AGENT'; param_values(6) := 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)'; owa.init_cgi_env(6,param_names,param_values); sampleowaxml.testone owa.get_page(buf,rows); dbms_lob.createtemporary(outclob,true,dbms_lob.session); for i in 1..rows loop dbms_lob.writeappend(outclob,length(buf(i)),buf(i)); end loop; ? := outclob; ? := DBMS_LOB.INSTR(outclob,CHR(10)| |CHR(10));end;</statement>
<message>ORA-06550: line 3, column 3: PLS-00103: Encountered the symbol "OWA" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "OWA" to continue.</message>
</xsql-error>
- <xsql-error action="xsql:include-owa">
<message />
</xsql-error>
</page>
This error message is very similiar to the message that Shanthir posted on Jan, 21. I did run the dbmslob.sql, but it doesn't help. Anybody has ideas how to solve it?
I used the PL/SQL web toolkit provided by OAS4.0.8.1. I believe oracle web agent is replaced by this toolkit.
Thanks,
Min
nullHi,
Glad that somebody else too got this problem. Well, as I had mentioned in my previous posting too, I think there are some procedures in the package, dbms_lob, like the writeappend, createtemporary etc.. which is not found in my dbms_lob.sql file, I am using 8.0.5, but I found these procedures in the 8i, I think it is becos of that.
By the way if anybody got this solution and got any workaround, please help me too.
I am still waiting for the solution to that.
Shanthi -
PL/SQL procedure "Not Defined"
I have created a PL/SQL procedure, compiled it successfully, and am trying to call it from
an "onmouseover=" construction in the Link Attributes for a report column.
I have created an application process entry for this procedure in Shared Components/Application Processes.
When I place the mouse pointer over the column in the report I get an error stating
the procedure is "Not Defined".
I am trying to implement this onmouseover event in a manner similar to how it is implemented in the "Aria People, 0.92" packaged application I have downloaded from the Oracle/APEX web site. In the downloaded "Aria People, 0.92" application I have installed the onmouseover="ARIA_DETAIL(this,'#PERSON_ID#")" call works fine (on page 1 of the app).
Interestingly, if I take the exact same call to the ARIA_DETAIL() procedure and place it in my application I also get a 'Not Defined' error on the ARIA_DETAIL() procedure.
Clearly I am failing to do what is needed to have a PL/SQL procedure "Defined" for an APEX application. Can some kind soul please tell me what I have failed to do here?
Thank you in advance.
Jim LewisJim,
Sorry to go to the basics but am I correct about the following?
1. You created the pl/sql process as an ondemand process.
2. You added the ARIA_DETAIL javascript function to the page on which your calling it.
I'm just guessing but it sounds like you missed the second step there. Take a look at the application you got the code from and look at the Page Attributes. You should see some code in the HTML Header. That's what you need to add to your app.
Dan -
ORA-01031: insufficient privileges in PL/SQL but not in SQL
I have problem with following situation.
I switched current schema to another one "ban", and selected 4 rows from "ed"
alter session set current_schema=ban;
SELECT * FROM ed.PS WHERE ROWNUM < 5;
the output is OK, and I get 4 rows like
ID_S ID_Z
1000152 1
1000153 1
1000154 1
1000155 1
but following procedure is compiled with warning
create or replace
procedure proc1
as
rowcnt int;
begin
select count(*) into rowcnt from ed.PS where rownum < 5;
end;
"Create procedure, executed in 0.031 sec."
5,29,PL/SQL: ORA-01031: insufficient privileges
5,2,PL/SQL: SQL Statement ignored
,,Total execution time 0.047 sec.
Could you help me why SELECT does work in SQL but not in PL/SQL procedure?
Thanks.
Message was edited by:
MattSkPrivs granted via a role are only valid from SQL - and not from/within stored PL/SQL code.
Quoting Tom's (from http://asktom.oracle.com) response to this:I did address this role thing in my book Expert one on one Oracle:
<quote>
What happens when we compile a Definer rights procedure
When we compile the procedure into the database, a couple of things happen with regards to
privileges. We will list them here briefly and then go into more detail:
q All of the objects the procedure statically accesses (anything not accessed via dynamic SQL)
are verified for existence. Names are resolved via the standard scoping rules as they apply to the
definer of the procedure.
q All of the objects it accesses are verified to ensure that the required access mode will be
available. That is, if an attempt to UPDATE T is made - Oracle will verify the definer or PUBLIC
has the ability to UPDATE T without use of any ROLES.
q A dependency between this procedure and the referenced objects is setup and maintained. If
this procedure SELECTS FROM T, then a dependency between T and this procedure is recorded
If, for example, I have a procedure P that attempted to 'SELECT * FROM T', the compiler will first
resolve T into a fully qualified referenced. T is an ambiguous name in the database - there may be
many T's to choose from. Oracle will follow its scoping rules to figure out what T really is, any
synonyms will be resolved to their base objects and the schema name will be associated with the
object as well. It does this name resolution using the rules for the currently logged in user (the
definer). That is, it will look for an object owned by this user called T and use that first (this
includes private synonyms), then it will look at public synonyms and try to find T and so on.
Once it determines exactly what T refers to - Oracle will determine if the mode in which we are
attempting to access T is permitted. In this case, if we as the definer of the procedure either
owns the object T or has been granted SELECT on T directly or PUBLIC was granted SELECT, the
procedure will compile. If we do not have access to an object called T by a direct grant - the
procedure P will fail compilation. So, when the object (the stored procedure that references T) is
compiled into the database, Oracle will do these checks - and if they "pass", Oracle will compile
the procedure, store the binary code for the procedure and set up a dependency between this
procedure and this object T. This dependency is used to invalidate the procedure later - in the
event something happens to T that necessitates the stored procedures recompilation. For example,
if at a later date - we REVOKE SELECT ON T from the owner of this stored procedure - Oracle will
mark all stored procedures this user has that are dependent on T, that refer to T, as INVALID. If
we ALTER T ADD some column, Oracle can invalidate all of the dependent procedures. This will cause
them to be recompiled automatically upon their next execution.
What is interesting to note is not only what is stored but what is not stored when we compile the
object. Oracle does not store the exact privilege that was used to get access to T. We only know
that procedure P is dependent on T. We do not know if the reason we were allowed to see T was due
to:
q A grant given to the definer of the procedure (grant select on T to user)
q A grant to public on T (grant select on T to public)
q The user having the SELECT ANY TABLE privilege
The reason it is interesting to note what is not stored is that a REVOKE of any of the above will
cause the procedure P to become invalid. If all three privileges were in place when the procedure
was compiled, a revoke of ANY of them will invalidate the procedure - forcing it to be recompiled
before it is executed again. Since all three privileges were in place when we created the procedure
- it will compile successfully (until we revoke all three that is). This recompilation will happen
automatically the next time that the procedure is executed.
Now that the procedure is compiled into the database and the dependencies are all setup, we can
execute the procedure and be assured that it knows what T is and that T is accessible. If something
happens to either the table T or to the set of base privileges available to the definer of this
procedure that might affect our ability to access T -- our procedure will become invalid and will
need to be recompiled.
This leads into why ROLES are not enabled during the compilation and execution of a stored
procedure in Definer rights mode. Oracle is not storing exactly WHY you are allowed to access T -
only that you are. Any change to your privileges that might cause access to T to go away will cause
the procedure to become invalid and necessitate its recompilation. Without roles - that means only
'REVOKE SELECT ANY TABLE' or 'REVOKE SELECT ON T' from the Definer account or from PUBLIC. With
roles - it greatly expands the number of times we would invalidate this procedure. If some role
that was granted to some role that was granted to this user was modified, this procedure might go
invalid, even if we did not rely on that privilege from that role. ROLES are designed to be very
fluid when compared to GRANTS given to users as far as privilege sets go. For a minute, let's say
that roles did give us privileges in stored objects. Now, most any time anything was revoked from
ANY ROLE we had, or any role any role we have has (and so on -- roles can and are granted to roles)
-- many of our objects would become invalid. Think about that, REVOKE some privilege from a ROLE
and suddenly your entire database must be recompiled! Consider the impact of revoking some system
privilege from a ROLE, it would be like doing that to PUBLIC is now, don't do it, just think about
it (if you do revoke some powerful system privilege from PUBLIC, do it on a test database). If
PUBLIC had been granted SELECT ANY TABLE, revoking that privilege would cause virtually every
procedure in the database to go invalid. If procedures relied on roles, virtually every procedure
in the database would constantly become invalid due to small changes in permissions. Since one of
the major benefits of procedures is the 'compile once, run many' model - this would be disastrous
for performance.
Also consider that roles may be
q Non-default: If I have a non-default role and I enable it and I compile a procedure that
relies on those privileges, when I log out I no longer have that role -- should my procedure become
invalid -- why? Why not? I could easily argue both sides.
q Password Protected: if someone changes the password on a ROLE, should everything that might
need that role be recompiled? I might be granted that role but not knowing the new password - I
can no longer enable it. Should the privileges still be available? Why or Why not? Again, arguing
either side of this is easy. There are cases for and against each.
The bottom line with respect to roles in procedures with Definer rights are:
q You have thousands or tens of thousands of end users. They don't create stored objects (they
should not). We need roles to manage these people. Roles are designed for these people (end users).
q You have far fewer application schema's (things that hold stored objects). For these we want
to be explicit as to exactly what privileges we need and why. In security terms this is called the
concept of 'least privileges', you want to specifically say what privilege you need and why you
need it. If you inherit lots of privileges from roles you cannot do that effectively. We can manage
to be explicit since the number of development schemas is SMALL (but the number of end users is
large)...
q Having the direct relationship between the definer and the procedure makes for a much more
efficient database. We recompile objects only when we need to, not when we might need to. It is a
large efficiency enhancement.
</quote> -
How to make pl/sql procedure not auto-commit?
I wish to be able to execute a create statement, and then rollback if there is a problem with any sql that follows. It seems that you cannot rollback? Why is this?
(My problem is that I wish to execute a series of sql statements and run a rollback if anything before it fails, including the creation of the table)
set serveroutput on;
declare
rcount INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
execute immediate 'create table bsdconv_s1stc_code (id number)';
dbms_output.put_line('Table created successfully');
rollback;
exception
when others then dbms_output.put_line('Error while creating table. Probably already exists.');
end;Ni hao, Dong Yage!
I think using procedure and handling on call you might be able to do it.
SQL> create table test (i int);
Table created.
SQL> insert into test values (1);
1 row created.
SQL> select * from test;
I
1
SQL> set serveroutput on;
SQL> declare
2 rcount INTEGER;
3 PRAGMA AUTONOMOUS_TRANSACTION;
4 begin
5 execute immediate 'create table bsdconv_s1stc_code (id number)';
6 dbms_output.put_line('Table created successfully');
7 -- rollback;
8 exception
9 when others then
10 dbms_output.put_line('Error while creating table. Probably already exists.');
11 rollback;
12 end;
13 /
Table created successfully
PL/SQL procedure successfully completed.
SQL> desc bsdconv_s1stc_code
Name Null? Type
ID NUMBER
SQL> select * from test;
I
1
SQL> insert into test values (2);
1 row created.
SQL> set serveroutput on;
SQL> declare
2 rcount INTEGER;
3 PRAGMA AUTONOMOUS_TRANSACTION;
4 begin
5 execute immediate 'create table bsdconv_s1stc_code (id number)';
6 dbms_output.put_line('Table created successfully');
7 -- rollback;
8 exception
9 when others then
10 dbms_output.put_line('Error while creating table. Probably already exists.');
11 rollback;
12 execute immediate 'drop table bsdconv_s1stc_code';
13 end;
14 /
Error while creating table. Probably already exists.
PL/SQL procedure successfully completed.
SQL> select * from test;
I
1
2
SQL> rollback;
Rollback complete.
SQL> select * from test;
no rows selected
SQL> desc bsdconv_s1stc_code;
ERROR:
ORA-04043: object bsdconv_s1stc_code does not exist
On executing PL/SQL block secondly,
it raises exception, displays error messages and drops table
but main transaction is not rolled back.
This is because rollback belongs to only inseide of
AUTONOMOUS_TRANSACTION PL/SQL block.
Now, let us try using procedure.
SQL> grant create table to ushi;
SQL> create or replace
2 procedure create_table
3 is
4 PRAGMA AUTONOMOUS_TRANSACTION;
5 begin
6 execute immediate 'create table bsdconv_s1stc_code (id number)';
7 dbms_output.put_line('Table created successfully');
8 exception
9 when others then
10 dbms_output.put_line('Error while creating table. Probably already exists.');
11 execute immediate 'drop table bsdconv_s1stc_code';
12 raise;
13 end;
14 /
Procedure created.
SQL> select * from test;
no rows selected
SQL> begin
2 insert into test values (1);
3 create_table;
4 exception
5 when others then
6 dbms_output.put_line('Error on Creating table or Transaction');
7 rollback;
8 end;
9 /
Table created successfully
PL/SQL procedure successfully completed.
SQL> select * from test;
I
1
SQL> commit;
Commit complete.
SQL> desc bsdconv_s1stc_code
Name Null? Type
ID NUMBER
SQL> begin
2 insert into test values (2);
3 create_table;
4 exception
5 when others then
6 dbms_output.put_line('Error on Creating table or Transaction');
7 rollback;
8 end;
9 /
Error while creating table. Probably already exists.
Error on Creating table or Transaction
PL/SQL procedure successfully completed.
SQL> select * from test;
I
1
SQL> desc bsdconv_s1stc_code
ERROR:
ORA-04043: object bsdconv_s1stc_code does not exist -
ORA-00604: error occurred at recursive SQL when calling proc via db_link
Hi,
I'm on 9.2.0.8 and got strange issue with simple test case
on source db:
CREATE OR REPLACE PROCEDURE ADMIN.gg_ref(out_tokens OUT SYS_REFCURSOR) is
BEGIN
OPEN out_tokens for select dummy from dual;
END ;
Now testing code localy:
SQL> var r refcursor
SQL> declare
2 output sys_refcursor;
3 begin
4 adminx.gg_ref(output);
5 :r:=output;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> print r
D
X
So its working.
I've got db_link to that db , and now call that proc via dblink from other 9.2.0.8 DB:
var r refcursor
1 declare
2 output sys_refcursor;
3 begin
4 admin.gg_ref@LINK_NAME(output);
5 :r:=output;
6* end;
SQL> /
declare
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00900: invalid SQL statementWhats wrong with my code ?
Are there any restriction I'm not aware of ?
Regards
GregGGregG wrote:
What should my code look like now ?
Should I rewrite this as function returning index by collection or something ?You can use DBMS_SQL - but use the remote package and not the local one. This is a little bit more complex ito call interface than using a ref cursor, but is the very same thing on the server side. DBMS_SQL also provides a more comprehensive set of features than using the ref cursor interface.
The main issue though is additional coding - as DBMS_SQL is a lower level interface (a lot closer to the real Oracle Call Interface/OCI):
--// on remote database the procedure returns a DBMS_SQL cursor instead of a ref cursor
SQL> create or replace procedure FooProc( cur in out number, deptID number ) is
2 rc number;
3 begin
4 cur := DBMS_SQL.open_cursor;
5
6 DBMS_SQL.parse(
7 cur,
8 'select ename from emp where deptno = :deptID',
9 DBMS_SQL.native
10 );
11
12 DBMS_SQL.Bind_Variable( cur, 'deptID', deptID );
13
14 rc := DBMS_SQL.Execute( cur );
15 end;
16 /
Procedure created.
--// from the local database side we call this remote proc
SQL> declare
2 c number; --// instead of using sys_refcursor
3 empName varchar2(10); --// buffer to fetch column into
4 begin
5 FooProc@testdb( c, 10 ); --/ call the proc that creates the cursor
6
7 --// we need to define our fetch buffer for the 1st column in the
8 --// SQL projection of that cursor (10 byte fetch buffer for 1st column)
9 DBMS_SQL.define_column@testdb( c, 1, empName, 10 );
10
11 --// we now fetch from this cursor, but via the DBMS_SQL
12 --// interface
13 loop
14 --// fetch the row (exit when 0 rows are fetched)
15 exit when DBMS_SQL.Fetch_Rows@testdb( c ) = 0;
16
17 --// copy value of 1st column in row into the local PL/SQL buffer
18 DBMS_SQL.column_value@testdb( c, 1, empName );
19
20 --// record value it via dbms output
21 DBMS_OUTPUT.put_line( 'name='||empName||' deptID=10' );
22 end loop;
23
24 --// close it explicitly as you would a ref cursor
25 DBMS_SQL.Close_Cursor@testdb( c );
26 end;
27 /
name=CLARK deptID=10
name=KING deptID=10
name=MILLER deptID=10
PL/SQL procedure successfully completed.
SQL> -
ORA-00604:error occurred at recursive SQL level 1ORA-01003:no stmnt parsed
Following PL/SQL block works fine when executed as SQL statement but throws
2147217900:ORA-00604: error occurred at recursive SQL level 1ORA-01003: no statement parsed
error, when called from application (Visual Basic 6.0).
Procedure xyz(pStartDt IN VARCHAR2,pEndDt IN VARCHAR2,pErrorDesc OUT VARCHAR2, pReportData OUT SYS_REFCURSOR) IS
Begin
Open pReportData For
WITH Dataset AS
(SELECT SUBSTR(forename,1,1) FName, trim(surname) SurName, trim(NVL(address_1, address_2)) Addr,
DECODE(UPPER(hacc_num),'999999999',NULL,'N/A', NULL,'NA', NULL, 'NON GIVEN', NULL, 'NOT GIVEN', NULL, 'UNKNOWN', NULL,'NONE GIVEN', NULL,hacc_num) HaccNum,
TRUNC(receipt_date) RcptDate,
UPPER(SUBSTR(forename,1,1)||trim(surname)||trim(NVL(address_1, address_2))) NameAddr,
casenum, customer_title, forename, address_1, address_2, postcode, comp_date
FROM bprit_act_current
WHERE proc_code = 'CF2'
AND receipt_date BETWEEN ADD_MONTHS(TO_DATE(p_dtEnd,'dd/mm/yyyy'), -3)+1
AND TO_DATE(p_dtEnd,'dd/mm/yyyy')
AND ((ForeName IS NOT NULL AND SurName IS NOT NULL AND NVL(address_1, address_2) IS NOT NULL)
OR hacc_num IS NOT NULL)),
RequiredData AS (SELECT *
FROM Dataset
WHERE RcptDate BETWEEN TO_DATE(p_dtStart,'dd/mm/yyyy') AND TO_DATE(p_dtEnd,'dd/mm/yyyy')),
DuplicateData AS (SELECT a.nameaddr, NULL haccnum, COUNT(a.Addr) Cnt
FROM Dataset a, RequiredData b
WHERE (a.NameAddr = b.NameAddr)
GROUP BY a.nameaddr
HAVING COUNT(1) >1
UNION ALL
SELECT NULL nameaddr, a.haccnum, COUNT(1) Cnt
FROM Dataset a, RequiredData b
WHERE (a.haccnum = b.haccnum)
GROUP BY a.haccnum
HAVING COUNT(1) >1)
SELECT DISTINCT a.casenum "Case No.", a.customer_TITLE "Title", a.FORENAME "Forename", a.SURNAME "Surname", a.HACCNUM "Holding/Account No.",
a.ADDRESS_1 "Address Line1", a.ADDRESS_2 "Address Line 2",a.POSTCODE "Post Code", a.RcptDate "Receipt Date", a.comp_date "Complete Date"
FROM Dataset a, DuplicateData b
WHERE (a.nameaddr = b.nameaddr) OR (a.haccnum = b.haccnum)
ORDER BY a.haccnum, a.forename, a.surname, a.address_1, a.address_2;
EXCEPTION
WHEN OTHERS THEN
pErrorDesc := SUBSTR(SQLERRM, 1, 255);
END XYZ;Any help will be appreciated.
Oracle version is 9.2.0.6.0.
SQL commands works fine if executed alone but calling from vb application throw following error,
[12:53:23][ERR]getReportData::-2147217900:ORA-00604: error occurred at recursive SQL level 1ORA-01003: no statement parsed
Edited by: rav_bhu on 05-May-2009 05:30Few points
1. Use {noformat} <put your code here> {noformat} tags to format your code. Its ugly without formatting.
2. Please remove the WHEN OTHERS THEN from your code and run again. Get the full error message with line number and post it here.
3. Mention your database version. -
ORA-00604:error occurred at recursive SQL level string
Hi all,
Oracle Version :- 11.2.0.2
I found a error in a trigger(Statement Level)
ORA-00604:error occurred at recursive SQL level string.
Before Finding this issue,Once the DB Response was slow . Will this be the issue Of DB Slow response. The Above trigger fires for each entry in an transaction table.
The code is Patched and was executed . The above issue was found during another issue and not the DB Slow response.
My Doubt is Whether DB response slow issuewould be because of this. Now after fixing this Slow response was not reported.
Your inputs are highly appreciated.it helps if you can post the complete stack of error messages (I'm suspecting you have several more messages than just ORA-00604).
A cut-n-paste of the SQL*Plus session with the SQL statement and the error message(s) below would give the info as to what the actual problem is.
Do you have INSERT priv. on that table? Are you doing this from within a stored procedure or at SQL prompt? -
Deploy warnings using a PL/SQL procedure (from a Public Transform Package)
OWB Version: 10.2
I am receiving the following warnings when I attempt to deploy a map that contains a reference to a custom pl/sql procedure that is setup in a public transformation package:
Warning
ORA-06550: line 115, column 32:
PLS-00112: end-of-line in quoted identifier
ORA-06550: line 115, column 9:
PLS-00103: Encountered the symbol "." when expecting one of the following:
:= . ( @ % ; not null range default character
I reviewed the OWB generated code and I discovered the OWB is a adding two double quotes in front of any reference to the package name. For example.....
BEGIN
COMMIT;
sql_stmt := 'ALTER SESSION DISABLE PARALLEL DML';
EXECUTE IMMEDIATE sql_stmt;
IF NOT ""ZZTEST"."INIT_SF_USER_CLAS_St" THEN
* note the "" in front of ZZTEST, which is the package name.
Has anyone else encountered this issue? I can manually correct the generated the code, but it would be overridden every the time the map is deployed. I encounter the same issue if I import a custom pl/sql procedure from the database into OWB using the Metadata Import Wizard and use the imported procedure in a map. However, I can setup an standalone procedure or function as a public transformation and the map deploys successfully. Please advise.
Regards,
MattYou have to create a job to start your procedure.
Example :
* http://psoug.org/reference/OLD/dbms_job.html
Then create a procedure to start your job, call it from your dashboard and you're done.
Success
Nico
Maybe you are looking for
-
Powerbook 15" w/ Tiger won't read Maxtor One Touch II External Hard Drive
Hi all: For some reason my G4 Powerbook can't recognize my Maxtor One Touch II external hard drive. I am trying to find a firewire cable that fits, as the Maxtor just gave me a USB and says that the cable won't work with mac. I am trying to find a ca
-
How do update latest operating system to my mac 10.4.11
My mac is outdated and doesn't even support my iphone.....I tried to download the new lion operating sytem but it said I need to have Leopard already installed, so I realized I'm starting a journey that may have no end! Bascially my current mac is f
-
I have to create various XML files importing data from differnet RFC functions and XSL files. Then when I finished the XML files I have to integrate all the information in one unique XML file that is the source for my external MRP. I have developed t
-
Photos constantly re-rendering during viewing.
Hi all, Since upgrading to Aperture 3, I've noticed that clicking through the photos in my project causes the "loading" indicator to come up for every photo. This used to happen in the Aperture 2, but once the photo loaded once, it was as if the syst
-
I have two sites I've been working on in iWeb with each site destined to go to different servers. I worked through the Site Seperation system and feel pretty sure that I followed it step by step. BUT, when I went to work on the folder of my second si