Executing procedures in packages.
<p>Hi </p><p>I am using CR XI developer edition.</p><p>I want to call stored procedures that currently resides in a package. In database explorer it shows me:</p><p>"mypackage.testProcedure" when I select it to execute, it gives me an error telling me <user>.testProcedure must be declared. It drops the "mypackage" reference. Is there a value in <databaseStructure> I can set to make it recoginize and run my procedures in packages??</p><p> <GenericJDBCDriver><br /> <Option>No</Option><br /> <strong> <DatabaseStructure>catalogs,schemas,tables</DatabaseStructure><br /></strong> <StoredProcType>Oracle</StoredProcType><br /> <LogonStyle>Oracle</LogonStyle><br /> </GenericJDBCDriver></p><p>what values can <databaseStructure> have??</p><p> Shirley</p>
PLEASE POST YOUR QUESTIONS TO THE DEV FORUMS.
Requirements of Oracle Stored Procedures
In order for Crystal Reports to report off Oracle stored procedures, all of the
following requirements must exist.
u2022 To use an ODBC connection to access an Oracle stored procedure, you
must create a package that defines the REF CURSOR. This REF CURSOR
must be strongly bound to a static pre-defined structure (see Strongly Bound
REF CURSORs vs Weakly Bound REF CURSORs). This package must be
created separately and before the creation of the stored procedure.
u2022 A native connection to Oracle in Crystal Reports 9 and Crystal Reports 10
can be used to access an Oracle stored procedure that was created within a
package and also an Oracle stored procedure that references a weakly bound
REF CURSOR
u2022 The stored procedure must have a parameter that is a REF CURSOR type.
Crystal Reports uses this parameter to access and define the result set that
the stored procedure returns.
u2022 The REF CURSOR parameter must be defined as IN OUT (read/write
mode). After the stored procedure has opened and assigned a query to the
REF CURSOR, Crystal Reports will perform a FETCH call for every row
from the queryu2019s result. This is why the parameter must be defined as IN
OUT.
u2022 The parameters can only be defined as IN (input) parameters. Crystal
Reports is not designed to work with OUT parameters.
u2022 The REF CURSOR variable must be opened and assigned its query within
the procedure.
Crystal Reports Oracle Stored Procedures
2/18/2004 2:55 PM Copyright © 2004 Business Objects. All rights reserved. Page 4
cr_oracle_stored_procedures.pdf
u2022 The stored procedure can only return one record set. The structure of this
record set must not changed, based on parameters.
u2022 The stored procedure cannot call another stored procedure.
u2022 If using an ODBC driver, it must be the CR Oracle ODBC driver installed
by Crystal Reports.
u2022 If you are using the CR ODBC driver, verify that the option u2018Procedure
Return Resultsu2019 is selected as u2018Onu2019 in the ODBC Driver Configuration setup
under the u2018Advancedu2019 tab.
u2022 If you are using the native Oracle driver and using hard-coded date selection
within the stored procedure, the date selection must use either a string
representation format of YYYY-DD-MM (where the date field = 2004-01-
01) or the To_Date formula function with the same format specified (where
date field = To_Date(2004-01-01u2019,u2019YYYY-MM-DDu2019).
u2022 Most importantly, the stored procedure must be able to execute successfully
in Oracleu2019s SQL *Plus utility.
If all of these requirements have been met, verify that the database driver that
you are using works with that version of Oracle.
Strongly Bound REF CURSORs versus Weakly
Bound REF CURSORs
When declaring the REF CURSOR in an Oracle package, the REF CURSOR
may be strongly bound or it may be weakly bound.
A strongly bound REF CURSOR is bound with the same structure that is used
by the outputted SELECT statement in the Oracle stored procedure.
CREATE OR REPLACE PACKAGE Test_Package
AS TYPE Test_Type IS REF CURSOR RETURN Test_Table%ROWTYPE;
END Test_Package;
The example code in green displays the REF CURSOR strongly bound. In this
example, the REF CURSOR is bound with the row structure of the Test_Table
table.
A weakly bound REF CURSOR is not assigned a structure in the Oracle
package.
CREATE OR REPLACE PACKAGE Test_Package
AS TYPE Test_Type IS REF CURSOR;
END Test_Package;
Although the REF CURSOR is not assigned a structure in the Oracle package,
the Oracle stored procedure itself must return a record set with a structure that
does not change based on parameters.
Crystal Reports Oracle Stored Procedures
2/18/2004 2:55 PM Copyright © 2004 Business Objects. All rights reserved. Page 5
cr_oracle_stored_procedures.pdf
Creating an Oracle Stored Procedure
Samples of stored procedures and their steps on how to create them are
provided. These are samples of Oracle stored procedures that will return a result
set in Crystal Reports. If these samples were executed in the Oracle connection
utility, SQL *Plus, they should run successfully.
NOTE These sample stored procedures are provided as a tip. Refer to your Oracle
documentation for more information on creating stored procedures.
Sample A: Use with ODBC and native
connections in Crystal Reports
1. Create a table.
CREATE TABLE Test_Table
(ID number(5),
Firstname varchar2(30),
Lastname varchar2(30),
Birthday date);
2. Insert values into the table.
INSERT INTO Test_Table VALUES
(1, 'Christopher', 'Jones', '01-Nov-70');
INSERT INTO Test_Table VALUES
(2, 'Maria', 'Marshall', '02-Jan-77');
INSERT INTO Test_Table VALUES
(3, 'Jonathan', 'Campbell', '09-Aug-75');
INSERT INTO Test_Table VALUES
(4, 'Julie', 'Gagnon', '23-Dec-72');
INSERT INTO Test_Table VALUES
(5, 'Daemon', 'Thompson', '11-Feb-69');
3. Create the Package.
CREATE OR REPLACE PACKAGE Test_Package
AS TYPE Test_Type IS REF CURSOR RETURN Test_Table%ROWTYPE;
END Test_Package;
4. Create the stored procedure.
CREATE OR REPLACE PROCEDURE Test_Procedure (
Test_Cursor IN OUT Test_Package.Test_Type,
Test_Parameter IN Test_Table.ID%TYPE)
AS
BEGIN
Crystal Reports Oracle Stored Procedures
2/18/2004 2:55 PM Copyright © 2004 Business Objects. All rights reserved. Page 6
cr_oracle_stored_procedures.pdf
OPEN Test_Cursor FOR
SELECT *
FROM Test_Table
WHERE Test_Table.ID = Test_Parameter;
END Test_Procedure;
5. Once the stored procedure is successfully created on your Oracle database,
execute the stored procedure.
Sample B: Weakly Bound REF CURSOR
Only use this sample with a native connection to Crystal Reports 9 or later.
1. Create a table.
CREATE TABLE Test_Table
(ID number(5),
Firstname varchar2(30),
Lastname varchar2(30),
Birthday date);
2. Insert values into the table.
INSERT INTO Test_Table VALUES
(1, 'Christopher', 'Jones', '01-Nov-70');
INSERT INTO Test_Table VALUES
(2, 'Maria', 'Marshall', '02-Jan-77');
INSERT INTO Test_Table VALUES
(3, 'Jonathan', 'Campbell', '09-Aug-75');
INSERT INTO Test_Table VALUES
(4, 'Julie', 'Gagnon', '23-Dec-72');
INSERT INTO Test_Table VALUES
(5, 'Daemon', 'Thompson', '11-Feb-69');
3. Create the Package.
CREATE OR REPLACE PACKAGE Test_Package
AS TYPE Test_Type IS REF CURSOR;
END Test_Package;
4. Create the stored procedure.
CREATE OR REPLACE PROCEDURE Test_Procedure (
Test_Cursor IN OUT Test_Package.Test_Type,
Test_Parameter IN Test_Table.ID%TYPE)
AS
BEGIN
Crystal Reports Oracle Stored Procedures
2/18/2004 2:55 PM Copyright © 2004 Business Objects. All rights reserved. Page 7
cr_oracle_stored_procedures.pdf
OPEN Test_Cursor FOR
SELECT *
FROM Test_Table
WHERE Test_Table.ID = Test_Parameter;
END Test_Procedure;
5. Once the stored procedure is successfully created on your Oracle database,
execute the stored procedure.
Sample C: Stored procedure created within a
package
Only use this sample with a native connection to Crystal Reports 9 or later.
1. Create a table.
CREATE TABLE Test_Table
(ID number(5),
Firstname varchar2(30),
Lastname varchar2(30),
Birthday date);
2. Insert values into the table.
INSERT INTO Test_Table VALUES
(1, 'Christopher', 'Jones', '01-Nov-70');
INSERT INTO Test_Table VALUES
(2, 'Maria', 'Marshall', '02-Jan-77');
INSERT INTO Test_Table VALUES
(3, 'Jonathan', 'Campbell', '09-Aug-75');
INSERT INTO Test_Table VALUES
(4, 'Julie', 'Gagnon', '23-Dec-72');
INSERT INTO Test_Table VALUES
(5, 'Daemon', 'Thompson', '11-Feb-69');
3. Create the Package.
CREATE OR REPLACE PACKAGE Test_Package
AS TYPE Test_Type IS REF CURSOR RETURN Test_Table%ROWTYPE;
PROCEDURE Test_Procedure (
Test_Cursor IN OUT Test_Type,
Test_Parameter IN Test_Table.ID%TYPE
END Test_Package;
Crystal Reports Oracle Stored Procedures
2/18/2004 2:55 PM Copyright © 2004 Business Objects. All rights reserved. Page 8
cr_oracle_stored_procedures.pdf
4. Create the Package Body (With The Code For The Stored Procedure).
CREATE OR REPLACE PACKAGE BODY Test_Package
AS
PROCEDURE Test_Procedure (
Test_Cursor IN OUT Test_Type,
Test_Parameter IN Test_Table.ID%TYPE
) IS
BEGIN
OPEN Test_Cursor FOR
SELECT *
FROM Test_Table
WHERE Test_Table.ID = Test_Parameter;
END Test_Procedure;
END Test_Package;
5. Once the stored procedure is successfully created on your Oracle database,
execute the stored procedure.
Similar Messages
-
What's wrong with executing procedure in package???
I am new to SQL Developer. I had developed a PL/SQL package<br>
(called COMMON_SQL) and compiled<br>
in my database. I could see my package in USER_OBJECTS<br><p>
COMMON_SQL 13966 PACKAGE 03-APR-07 03-APR-07 2007-04-03:22:46:27 VALID N N N<br>
COMMON_SQL 13967 PACKAGE BODY 03-APR-07 03-APR-07 2007-04-03:22:48:21 VALID N N N<br><p>
I did not find any compilation error on the package in USER_ERRORS,<br>
i.e. the package was compiled and deployed successfully in my database.<br><p>
But when ran the procedure CHECK_AND_DROP_OBJ in the package
as follows:<br>
declare flag integer := 1;<br>
execute COMMON_SQL.CHECK_AND_DROP_OBJ('EXCEPTIONS','TABLE',flag);<br>
/<br><p>
It gave me the following error message:<br>
Error report:<br>
ORA-06550: line 2, column 65:<br>
PLS-00103: Encountered the symbol "end-of-file" when <br>expecting one of the following:<br>
begin function package pragma procedure subtype type use<br>
<an identifier> <a double-quoted delimited-identifier> form<br>
current cursor<br>
06550. 00000 - "line %s, column %s:\n%s"<br>
*Cause: Usually a PL/SQL compilation error.<br>
*Action:<br><p>
where line 2, column 65 pointed to the last semicolon on the second line.<br><p>
So why did it produce such an error?<br>
Can anyone tell me what the problem was?<br>
Do I need to configure or initialize SQL Developer?<br><p>
Thanks for your help in advance,<br><p>
AK<br><p>
P.S. Here is the body of my package COMMON_SQL:<br>
create or replace package body COMMON_SQL<br>
as<br>
<code> -- This procedure check for the existence of any database object by type.<br>
-- It drops the object if it exists.<br>
-- obj is the name of the dtabase object<br>
-- type is the type of the object: table, index, sequence, synonym<br>
-- flag has different types of values. <br>
-- For in, flag = 1 for print debug message.<br>
-- For out, flag = 0 for object not found.<br>
-- flag = 1 for object found and dropped.<br>
-- flag = -1 for error.<br>
procedure CHECK_AND_DROP_OBJ (obj in varchar2, type in varchar2, flag in out integer)<br>
is<br>
obj_type USER_CATALOG.TABLE_TYPE%type;<br>
str varchar2(100);<br>
cursor obj_cur is<br>
select TABLE_TYPE from USER_CATALOG where TABLE_NAME = obj;<br>
begin<br>
open obj_cur;<br>
fetch obj_cur into obj_type;<br>
if obj_cur%NOTFOUND<br>
then<br>
str := 'obj ' || obj || ' is not found';<br>
if flag = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
flag := 0; -- return 0<br>
elsif obj_type = type<br>
then<br>
str := 'drop ' || obj_type || ' ' || obj;<br>
execute immediate(str);<br>
if flag = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
flag := 1; -- return 1<br>
else<br>
str := 'obj ' || obj || ' has type mismatch';<br>
if flag = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
flag := -1; -- return -1<br>
end if;<br>
close obj_cur;<br>
--exception<br>
null; ??<br>
END; --CHECK_AND_DROP_OBJ <br>
END;<br>
</code>
Message was edited by:
user567947
Message was edited by:
user567947
Message was edited by:
user567947
Message was edited by:
user567947
Message was edited by:
user567947smitjb,<br><p>
I modified the package slightly and redeployed the package successfully.<br>
Then I ran the stored procedure as you suggested:<br>
declare debugf integer:=1;<br>
rc integer:=0;<br>
begin<br> SYSTEM.COMMON_SQL.CREATE_AND_DROP_OBJ('MPGCV_USER_SEQ','SEQUENCE',debugf,rc);<br>
end;<br>
/<br><p>
But I still got, sort of, similar error:<br>
Error starting at line 1 in command:<br>
declare debugf integer:=1;<br>
rc integer:=0;<br>
begin<br>
SYSTEM.COMMON_SQL.CREATE_AND_DROP_OBJ('MPGCV_USER_SEQ','SEQUENCE',debugf,rc);<br>
end;<br>
Error report:<br>
ORA-06550: line 4, column 23:<br>
PLS-00302: component 'CREATE_AND_DROP_OBJ' must be declared<br>
ORA-06550: line 4, column 5:<br>
PL/SQL: Statement ignored<br>
06550. 00000 - "line %s, column %s:\n%s"<br>
*Cause: Usually a PL/SQL compilation error.<br>
*Action:<br><p>
I checked USER_ERRORS (found no error), and USER_OBJECTS and found both the package spec and body<br>
So why did it not recognize the package and its stored procedure?<br>
I was using SYSTEM account and should have the correct schema and privilege.<br>
Any idea?<br><p>
Thanks,<br><p>
AK<br><p>
P.S. Here is the body of my package:<br>
<code>
-- This package body contains all the functions/procedures<br>
-- needed by any PL/SQL scripts<br>
create or replace package body SYSTEM.COMMON_SQL<br>
as<br>
-- This procedure check for the existence of any database object by type.<br>
-- It drops the object if it exists.<br>
-- obj is the name of the dtabase object<br>
-- otype is the type of the object: table, index, sequence, synonym<br>
-- debugf indicates to print debugging message or not. <br>
-- rc is the return code, <br>
-- rc = 0 for object not found.<br>
-- rc = 1 for object found and dropped.<br>
-- rc = -1 for error.<br>
procedure CHECK_AND_DROP_OBJ (obj in varchar2, otype in varchar2, debugf in integer, rc out integer)<br>
is<br>
obj_type USER_CATALOG.TABLE_TYPE%type;<br>
str varchar2(100);<br>
cursor obj_cur is<br>
select TABLE_TYPE from USER_CATALOG where TABLE_NAME = obj;<br>
begin<br>
open obj_cur;<br>
fetch obj_cur into obj_type;<br>
if obj_type = otype<br>
then<br>
str := 'drop ' || obj_type || ' ' || obj;<br>
execute immediate(str);<br>
if debugf = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
rc := 1; -- return 1<br>
else<br>
str := 'obj ' || obj || ' has type mismatch';<br>
if debugf = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
rc := -1; -- return -1<br>
end if;<br>
close obj_cur;<br>
exception<br>
when NO_DATA_FOUND<br>
then<br>
str := 'obj ' || obj || ' is not found';<br>
if debugf = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
rc := 0; -- return 0<br>
when OTHERS<br>
then<br>
str := 'error encountered SQLCODE:' || to_char(SQLCODE) || <br>
' SQLERRM:' || SQLERRM;<br>
if debugf = 1<br>
then<br>
DBMS_OUTPUT.PUT_LINE(str);<br>
end if;<br>
rc := -1; -- return -1<br>
END; --CHECK_AND_DROP_OBJ <br>
END;<br>
/<br>
</code> -
Error executing procedure in package
If someone can help me, i'd greatly appreciate it!
I created a package (see code below) in the Portal Navigator and I'm getting the following error when i try to execute the procedure:
ORA-06550: line 2, column 16:
PLS-00201: identifier 'CURSOR' must be declared
ORA-06550: line 2, column 12:
PL/SQL: Item ignored
ORA-06550: line 4, column 46:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
ORA-06550: line 6, column 20:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored (WWV-11230)
Failed to parse as PORTAL - declare
local_var1 REF CURSOR;
begin
"CONCORD"."TAB_LINKS"."GETLINKS" ( VLINKS => local_var1, V_tab=> 'Analytics');
htp.p(htf.br||'OUT parameter values:'||htf.br);
htp.p('VLINKS - '||local_var1||htf.br);
end; (WWV-08300)
Create or Replace Package TAB_LINKS
as
TYPE vrefcur IS REF CURSOR;
procedure getlinks(vlinks OUT tab_links.vrefcur,
v_tab IN VARCHAR2 DEFAULT NULL);
END;
Create or Replace Package BODY TAB_LINKS
AS
procedure getlinks
(vlinks OUT tab_links.vrefcur,
v_tab IN VARCHAR2 DEFAULT NULL)
as
vsql varchar2(3000);
vuser varchar2(50) := orasso.wwctx_api.get_user();
vgroup number := orasso.wwsec_api.get_defaultgroup();
BEGIN
/* retrieves the links based on the title and group name */
vsql := 'select url,target,name
from table_links
where groupid= '''||vgroup||'''
and upper(cornertitle)
= '''||upper(v_cornertitle)||'''
and type = ''sidebar''
order by itemid';
--htp.p(vsql);
open vlinks for vsql;
END getlinks;
END;I tried executing the code in orasso schema
got below error first
Error in creating PACKAGE BODY. (WWV-17098)
Line No. 15 : PLS-00201: identifier 'V_CORNERTITLE' must be declared (WWV-17050)
Line No. 11 : PL/SQL: Statement ignored (WWV-17050)
ORA-24344: success with compilation error (WWV-11230)
Failed to parse as PORTAL - create or replace package body ORASSO.TAB_LINKS as
procedure getlinks
(vlinks OUT tab_links.vrefcur,
v_tab IN VARCHAR2 DEFAULT NULL)
as
vsql varchar2(3000);
vuser varchar2(50) := orasso.wwctx_api.get_user();
vgroup number := orasso.wwsec_api.get_defaultgroup();
Declared 'v_cornertitle' ,the package got created.
Complied also, the status shows valid. -
Executing procedure in package problem
Hi, i have a procedure called Newcar. i have now created a package and put the Newcar procedure inside the package body. but when i want to invoke it (to put data) by running execute packageTest.Newcar('Ferrari', 007) i get ORA-00900: invallid sql statement. what is wrong? the package spec and body gets created ok:
CREATE OR REPLACE PACKAGE packageTest IS
PROCEDURE Newcar(vname IN VARCHAR2, vreg IN NUMBER);
END packageTest;
CREATE OR REPLACE PACKAGE BODY packageTest IS
PROCEDURE Newcar
(vname IN VARCHAR2, vreg IN NUMBER)
IS
l_vreg NUMBER;
BEGIN
l_vreg := vreg;
IF vreg > 999 THEN
l_vreg := 999;
END IF;
INSERT INTO CARS (carname, carreg)
VALUES
(vname, l_vreg);
END Newcar;
END packageTest;
/Worked for me. Are there other details that might be relevant? The table definition perhaps? Triggers? Can you post similar output from your SQL*Plus session?
SQL> CREATE OR REPLACE PACKAGE packageTest IS
2 PROCEDURE Newcar(vname IN VARCHAR2, vreg IN NUMBER);
3 END packageTest;
4 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY packageTest IS
2 PROCEDURE Newcar
3 (vname IN VARCHAR2, vreg IN NUMBER)
4 IS
5 l_vreg NUMBER;
6 BEGIN
7 l_vreg := vreg;
8 IF vreg > 999 THEN
9 l_vreg := 999;
10 END IF;
11
12 INSERT INTO CARS (carname, carreg)
13 VALUES
14 (vname, l_vreg);
15 END Newcar;
16 END packageTest;
17 /
Package body created.
SQL> execute packageTest.Newcar('Ferrari', 007)
PL/SQL procedure successfully completed.
SQL> select * from cars;
CARNAME CARREG
Ferrari 7
SQL> -
Execute procedure in a package using the caller privileges?
Is it possible to execute a procedure within a package using the privileges of the caller rather than the privileges of the package owner? So if we have a procedure that does a select, one that does an insert, and another for update and a 4th for delete, then we just want to grant execute to user X on the select procedure in the package. This is a developer request. I think I just need to tell the requestor to copy or move the procedure out of the package and into it's own procedure so that it's safe to run by user X and not grant execute on the package since I don't believe it is possible to specify what procedures in a package are granted execute since that command is a blanket for the whole package right?
Example - fails due to specifying the proc:
grant execute on scmemaname.pkgname.procname to usr;
There's no other command to do that is there?
Thanks,
Dave
Edited by: Gib on Jan 19, 2010 8:42 AMAUTHID is at the package level ... not the individual function or procedure.
Create a second package. -
GRANT EXECUTE ON SCHEMA.PACKAGE.PROCEDURE TO USER
Hi,
GRANT EXECUTE ON SCHEMA.PACKAGE.PROCEDURE TO USER
returns:
ORA-00905, do you know why? Can I grant privileges on procedure inside package?
thanksAs per my knowledge of oracle, we cannot grant privileges on procedure inside a package.
<br><br>
Raj<br>
<b>www.oraclebrains.com<a>
<br><font color="#FF0000">POWERED by the people, to the people and for the people WHERE ORACLE IS PASSION.</font></b>
<br>
Sorry Leonardo Horikian & Kamal Kishore, I was late and didn't know that you guys have already posted the answer.
Message was edited by:
rajs -
Problem with procedure in package
Problem with procedure in package:
create table accounts
(acno number(10),
name varchar2(20),
balance number(10,2));
create package banking is
procedure new_acct(acno NUMBER, name IN VARCHAR);
procedure acct_dep(acno IN NUMBER, amount IN NUMBER);
procedure acc_wdr(acno IN NUMBER, amount IN NUMBER);
procedure acc_bal(acno IN NUMBER, bal OUT NUMBER);
function acc_drwn(acno IN NUMBER) RETURN BOOLEAN;
end banking;
create or replace package body banking is
procedure new_acct ( acno IN number,
name IN varchar) is
begin
insert into accounts
(acno, name, balance)
values
(acno, name,0);
end;
procedure acct_dep(acno IN NUMBER,
amount IN NUMBER) is
begin
update accounts
set balance = balance + amount
where acno = acno;
end;
procedure acc_wdr(acno IN NUMBER,
amount IN NUMBER) is
begin
update accounts
set balance = balance - amount
where acno = acno;
end;
procedure acc_bal(acno IN NUMBER,
bal OUT NUMBER) is
begin
declare cursor c_balance(i_acno IN accounts.acno%type) is
select balance
from accounts
where acno = i_acno;
acc_bal accounts.balance%type;
begin
if c_balance%isopen then
close c_balance;
end if;
open c_balance(acno);
fetch c_balance into acc_bal;
close c_balance;
end;
end;
function acc_drwn(acno IN NUMBER) RETURN BOOLEAN is
begin
declare cursor c_balance(i_acno IN accounts.acno%type) is
select balance
from accounts
where acno = i_acno;
bal accounts.balance%type;
begin
if c_balance%isopen then
close c_balance;
end if;
open c_balance(acno);
fetch c_balance into bal;
close c_balance;
if bal < 0 then
return true;
else
return false;
end if;
end;
end;
end banking;
begin
banking.new_acct(123,'FRANKS');
end;
execute banking.acct_dep(123,100);
execute banking.acc_wdr(123,50);
Works fine up to this point, however when running the balance check the balance amount is not visible?
SQL> set serveroutput on
SQL> begin
2 declare
3 bal accounts.balance%type;
4 begin
5 banking.acc_bal(123,bal);
6 dbms_output.put_line('Franks balance is '||bal);
7 end;
8 end;
9 /procedure acc_bal(acno IN NUMBER,
bal OUT NUMBER)
is
cursor c_balance(i_acno IN accounts.acno%type) is
select balance
from accounts
where acno = i_acno;
l_acc_bal accounts.balance%type;
begin
open c_balance(acno);
fetch c_balance into l_acc_bal;
close c_balance;
bal := l_acc_bal;
end; -
Error while executing the utl_mail package
Hi All,
I am executing the below package, to test whether the utl_mail package is working or not....basically I want to write a plsql program to send email to the specific users whenever there is ddl event on the database.
SQL> exec sys.utl_mail.send (sender =>'[email protected]',recipients =>'[email protected]',subject => 'Oracle Database Server DOWN',message => 'May be DB Server Down for maintenance.||. but also contact to DBA for further details. .');
BEGIN sys.utl_mail.send (sender =>'[email protected]',recipients =>'[email protected]',subject => 'Oracle Database Server DOWN',message => 'May be DB Server Down for maintenance.||. but also contact to DBA for further details. .'); END;
ERROR at line 1:
ORA-29279: SMTP permanent error: 554 <[email protected]>: Relay access denied
ORA-06512: at "SYS.UTL_SMTP", line 20
ORA-06512: at "SYS.UTL_SMTP", line 98
ORA-06512: at "SYS.UTL_SMTP", line 240
ORA-06512: at "SYS.UTL_MAIL", line 414
ORA-06512: at "SYS.UTL_MAIL", line 608
ORA-06512: at line 1
1. we are running the postfix on the database server.
2. when i am sending the mail through the unix command "mail" it successfully sending the mail.
3. I checked in most of the forums it says relay host settings needs to be changed...
4. I am not sure what are the postfix configuration setting i have to set.
Please help
Ravi
Edited by: user13369249 on Jul 9, 2010 1:22 PM
Edited by: user13369249 on Jul 9, 2010 1:24 PMI assume you are using Oracle 11
Step One Check for existing ACL
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SELECT host, acl FROM dba_network_acls;
Step Two Drop existing of it exists
SQL>
SQL> EXECUTE DBMS_NETWORK_ACL_ADMIN.drop_acl ( acl => 'test_acl_file.xml');
PL/SQL procedure successfully completed.
SQL> SELECT host, acl FROM dba_network_acls;
no rows selected
SQL>
Note : If there are multiple ones, they seem to conflict with each other.
Create an Access Control List (ACL)
As SYS
SQL> BEGIN
2 DBMS_NETWORK_ACL_ADMIN.create_acl (
3 acl => 'test_acl_file.xml',
4 description => 'A test of the ACL functionality',
5 principal => '<YOURUSER>',
6 is_grant => TRUE,
7 privilege => 'connect',
8 start_date => SYSTIMESTAMP,
9 end_date => NULL);
10
11 COMMIT;
12 END;
13 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL>
SQL> BEGIN
2 DBMS_NETWORK_ACL_ADMIN.assign_acl (
3 acl => 'test_acl_file.xml',
4 host => 'relay.?????',
5 lower_port => 25,
6 upper_port => null);
7
8 COMMIT;
9 END;
10 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL>
Make sure you change to you relay and your user.
Edited by: mseberg on Jul 9, 2010 2:32 PM -
Help....on stored procedure (or package)
Hi,
I have any problem to create stored procedure in Oracle, Can you help me?
I have to create a stored procedure (or package) in order to reserve the free rooms to the students in the period comprised between the DATE_START and DATE_END.
Table of the present rooms in building BL1 (RM): SEX 1 = M - SEX 2 = F SEX = 0 (ROOM WITHOUT SEX)
BL_ID.....FL_ID.......RM_ID.........SEX......RM_STD.....RM_CAT
BL1.........1..........101..............1........S........ROOM
BL1.........1..........102..............0........D........ROOM
BL1.........1..........103..............2........T........ROOM
BL1.........2..........201..............2........S........ROOM
BL1.........2..........202..............1........D........ROOM
BL1.........2..........203..............1........T........ROOM
BL1.........3..........301..............2........S........APARTMENT
BL1.........3..........302..............2........D........APARTMENT
BL1.........3..........303..............1........T........APARTMENT
BL1.........3..........304..............1........D........APARTMENT
BL1.........3..........305..............0........D........APARTMENT
Table of the students (EM):
EM_ID...........BL_ID.......FL_ID........RM_ID........COD_STUD
SABRINA..........BL1..........1............102.........524505
TAKEM............BL1..........1............103.........569673
SERAFINO.........BL1..........1............103.........589920
STELLA...........BL1..........1............102.........574659
CHIARA...........BL1..........1............101.........587845
VIDAL............BL1..........1............102.........602877
ROSARIA..........BL1..........2............202.........517070
LUCA.............BL1..........2............201.........602743
DANIELA..........BL1..........2............203.........602865
ANNAMARIA........BL1..........3............305.........588721
LUIGI............BL1..........3............304.........546517
Type of rooms (RM_STD):
RM_STD.......STD_EM........DESCRIPTION
D.............4..............DOUBLE
T.............6..............TRIPLE
S.............2..............SINGLE
Tables of the reservations carried out from the students (RMPCT):
EM_ID......BL_ID........FL_ID......RM_ID......DATE_START.......DATE_END.......COD_STUD
CHIARA......BL1.........1..........101.......11/02/2004.......12/02/2004.......587845
CHIARA......BL1.........1..........101.......03/02/2005.......16/02/2005.......587845
SERAFINO....BL1.........1..........102.......12/02/2004.......19/02/2004.......589920
VIDAL.......BL1.........1..........102.......16/02/2004.......01/03/2004.......602877
SERAFINO....BL1.........1..........103.......01/02/2004.......15/02/2004.......589920
TAKEM.......BL1.........1..........103.......04/02/2005.......10/02/2005.......569673
LUCA........BL1.........2..........201.......03/02/2005.......23/02/2005.......602743
ROSARIA.....BL1.........2..........202.......03/02/2005.......16/02/2005.......517070
DANIELA.....BL1.........2..........203.......03/02/2005.......04/02/2005.......602865
LUIGI.......BL1.........3..........301.......03/02/2005.......23/02/2005.......546517
VALERIA.....BL1.........3..........302.......12/02/2004.......16/02/2004.......515348
CHIARA......BL1.........3..........302.......05/02/2004.......15/02/2004.......587845
CHIARA......BL1.........3..........304.......10/02/2004.......12/02/2004.......587845
CHIARA......BL1.........3..........305.......20/01/2004.......04/02/2004.......587845
ANNAMARIA...BL1.........3..........305.......03/02/2005.......16/02/2005.......588721
INPUT PARAMETERS:
CREATE OR REPLACE Procedure RESERVE_ROOMS (stud_name varchar2,
cod_stud varchar2,
bl_in varchar2,
fl_in varchar2,
rm_in in varchar2,
sex_in varchar2,
date_start_in varchar2,
date_end_in varchar2)
CONDITIONS:
verify if there are students in table EM:
select count (1)
into v_appo
from em
where em_id = stud_name
and cod_stud = cod_stud;
if v_appo = 0 then
insert new student:
insert into em (em_id,cod_sud,sex)
values (stud_name,cod_stud,sex_in);
Now I must verify the free rooms in the period comprised between the DATE_START_IN and DATE_END_IN.
I tried this query: (seem correct...have you any idea?)
select bl_id,fl_id,rm_id,RM_STD
from rm
where (bl_id,fl_id,rm_id,RM_STD) not in (select a.bl_id,a.fl_id,a.rm_id,A.RM_STD
from rm a, rmpct b
where a.bl_id=b.bl_id
and a.fl_id=b.fl_id
and a.rm_id=b.rm_id
AND((b.date_start <= TO_DATE(date_start_in, 'dd-mm-YYYY')
AND b.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY'))
OR ( b.date_end <= TO_DATE(date_end_in, 'dd-mm-YYYY'))
AND b.date_end >= TO_DATE(date_start_in, 'dd-mm-YYYY')
OR ( b.date_start >= TO_DATE(date_start_in, 'dd-mm-YYYY')
and b.date_start <= TO_DATE(date_end_in, 'dd-mm-YYYY')
AND b.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY'))))
with this query I get all free rooms in period date_start_in - date_end_in, but I must,also,verify if there are double or triple rooms (reserved) with minus of 2 (double) or minus of 3 (triple) students. If there are I can reserved these rooms.
I tried to verify with these steps:
CREATE OR REPLACE VIEW COUNT_EM ( BL_ID,
FL_ID, RM_ID, NUMBER_EM ) AS
(SELECT rm.bl_id, rm.fl_id, rm.rm_id, COUNT(*) as numero_em
FROM em, rm
WHERE em.bl_id(+) = rm.bl_id
AND em.fl_id(+) = rm.fl_id
AND em.rm_id(+) = rm.rm_id
and rm.rm_std in ('S', 'D', 'T')
group by rm.bl_id, rm.fl_id, rm.rm_id)
CREATE OR REPLACE VIEW COUNT_RMPCT ( BL_ID,
FL_ID, RM_ID, STD_EM, NUMBER_RMPCT
) AS
SELECT rm.bl_id, rm.fl_id, rm.rm_id, rmstd.std_em, COUNT(*) as numero_rmpct
FROM rm, rmpct,rmstd
WHERE rmpct.bl_id(+) = rm.bl_id
AND rmpct.fl_id(+) = rm.fl_id
AND rmpct.rm_id(+) = rm.rm_id
and rm.rm_std=rmstd.rm_std
and rm.rm_std in ('S', 'D', 'T')
AND((rmpct.date_start <= TO_DATE(date_start_in', 'dd-mm-YYYY')
AND rmpct.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY'))
OR ( rmpct.date_end <= TO_DATE(date_end_in, 'dd-mm-YYYY'))
AND rmpct.date_end >= TO_DATE(date_start_in, 'dd-mm-YYYY')
OR ( rmpct.date_start >= TO_DATE(date_start_in, 'dd-mm-YYYY')
and rmpct.date_start <= TO_DATE(date_end_in, 'dd-mm-YYYY')
AND rmpct.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY')))
group by rm.bl_id, rm.fl_id, rm.rm_id, rmstd.std_em
AND FINALLY:
select a.bl_id, a.fl_id, a.rm_id, a.NUMBER_RMPCT, B.NUMBER_EM, a.std_em, (a.std_em - (a.NUMBER_RMPCT+B.NUMBER_EM)) RM_FREE
from COUNT_RMPCT a, COUNT_EM b
where a.bl_id=b.bl_id
and a.fl_id=b.fl_id
and a.rm_id=b.rm_id
if RM_FREE > 0 THEN there are free rooms (D or T) between those occupied in that period.
Now If the room (bl_in,fl_in,rm_in) is free I can reserve inserting it in the table RMPCT:
INSERT INTO rmpct (bl_id, fl_id, rm_id,em_id,cod_stud,date_start, date_end)
values(bl_in,fl_in,rm_in,stud_name,cod_stud,date_start_in,date_end_in);
If I haven't rm_in (can be null) I must reserve the first free room (random).
after these controls: I update table of the students:
UPDATE em
Set bl_id = BL_IN,fl_id= FL_IN,rm_id=rm_in
where em_id=stud_name
and cod_stud=cod_stud;
Finally I must make a control on the sex of the room, because there are rooms that have sex=0
if RM.SEX <> 0 then
null
else
if rm_cat = 'ROOM' then
UPDATE rm
set sex = sex_in
where bl_id = in
and fl_id = in
and rm_id = in;
if rm_cat = 'APARTMENT' then (update on all rooms)
UPDATE rm
set sex = sex_in
where bl_id = in
and fl_id = in;
IF v_appo > 0 then
Same controls except: insert into em (em_id,cod_sud,sex)
values (stud_name,cod_stud,sex_in);
How I can insert in one stored procedure (or package) all these instructions and controls?
Thanks in advance!In the following demonstation, I have changed the names of some of your variables, in order to standardize them. I have prefaced input parameters with p_ and local variables with v_ and followed them with the name of the column that they are associated with when appropriate. This avoids conflicts with any column names and makes the code easier to read and follow. I have also used table_name.column_name%type to specify the data type associated with the variables instead of using varchar2. That way, if the data type of the columns changes, the code does not have to be updated. This is standard practice.
In your first insert statement, you have attempted to insert sex into the em table, but there is no sex column in the em table data that you displayed, so I removed the sex.
Instead of using a complicated mess of views and such to check whether there is a room available and then assign it, I have used just one select statement to select an available room and used an exception clause that handles a no_data_found exception to deal with when there is no room available.
I have greatly simplified your checking of dates within that select statement.
You were on the right track with the outer joins and grouping and checking for single, double, or triple rooms. Instead of count, I have used sum and nvl2, so that only the occupied rooms are counted and the rows generated by the outer join are zeroes.
I have used the nvl function to allow for null values in the input parameters, so that any room can be selected. I used dbms_random.random to ensure that the rows are ordered randomly, but you can leave that out if it is really not that critical that the result be truly random and any row will do. I have used rownum=1 in an outer query to select just one row.
When you select from a table in pl/sql, you have to select into something. You cannot just issue a select statement, then use an if statement to compare some value in the select statement. For example, you cannot use "if rm.sex ..." you have to select rm.sex into a variable, like v_sex, then use "if v_sex ...". So, I have selected the result of the select statement into local variables, then used those variables for comparisons. I have also used those variables for inserting and updating the appropriate tables, rather than just using the original input parameters, since some of them may have been null.
In the example below, I have demonstrated how the procedure rejects an unavailable room, accepts a specific available room, and randomly assigns a room.
-- procedure:
scott@ORA92> CREATE OR REPLACE PROCEDURE reserve_rooms
2 -- input parameters:
3 (p_em_id IN em.em_id%TYPE,
4 p_cod_stud IN em.cod_stud%TYPE,
5 p_bl_id IN rm.bl_id%TYPE,
6 p_fl_id IN rm.fl_id%TYPE,
7 p_rm_id IN rm.rm_id%TYPE,
8 p_sex IN rm.sex%TYPE,
9 p_date_start IN VARCHAR2,
10 p_date_end IN VARCHAR2)
11 AS
12 -- local variables:
13 v_appo INTEGER;
14 v_bl_id rm.bl_id%TYPE;
15 v_fl_id rm.fl_id%TYPE;
16 v_rm_id rm.rm_id%TYPE;
17 v_rm_cat rm.rm_cat%TYPE;
18 v_sex rm.sex%TYPE;
19 BEGIN
20 -- verify if the student is in table em:
21 SELECT COUNT (*)
22 INTO v_appo
23 FROM em
24 WHERE em_id = p_em_id
25 AND cod_stud = p_cod_stud;
26 -- if the student is not in table em, then insert new student:
27 IF v_appo = 0 THEN
28 INSERT INTO em (em_id, cod_stud)
29 VALUES (p_em_id, p_cod_stud);
30 END IF;
31 BEGIN
32 -- find available room:
33 SELECT bl_id, fl_id, rm_id, sex, rm_cat
34 INTO v_bl_id, v_fl_id, v_rm_id, v_sex, v_rm_cat
35 FROM (SELECT rm.bl_id, rm.fl_id, rm.rm_id, rm.sex, rm.rm_cat
36 FROM rmpct, rm
37 WHERE rm.bl_id = rmpct.bl_id (+)
38 AND rm.fl_id = rmpct.fl_id (+)
39 AND rm.rm_id = rmpct.rm_id (+)
40 AND rm.bl_id = NVL (p_bl_id, rm.bl_id)
41 AND rm.fl_id = NVL (p_fl_id, rm.fl_id)
42 AND rm.rm_id = NVL (p_rm_id, rm.rm_id)
43 AND (rm.sex = p_sex OR rm.sex = 0)
44 AND rmpct.date_start (+) <= TO_DATE (p_date_end, 'DD-MM-YYYY')
45 AND rmpct.date_end (+) >= TO_DATE (p_date_start, 'DD-MM-YYYY')
46 GROUP BY rm.bl_id, rm.fl_id, rm.rm_id, rm.sex, rm.rm_cat, rm.rm_std
47 HAVING SUM (NVL2 (rmpct.rm_id (+), 1, 0))
48 < DECODE (rm_std, 'S', 1, 'D', 2, 'T', 3)
49 ORDER BY DBMS_RANDOM.RANDOM)
50 WHERE ROWNUM = 1;
51 -- reserve room:
52 INSERT INTO rmpct (bl_id, fl_id, rm_id, em_id, cod_stud, date_start, date_end)
53 VALUES (v_bl_id, v_fl_id, v_rm_id, p_em_id, p_cod_stud,
54 TO_DATE (p_date_start, 'DD-MM-YYYY'),
55 TO_DATE (p_date_end, 'DD-MM-YYYY'));
56 -- update students:
57 UPDATE em
58 SET bl_id = v_bl_id, fl_id = v_fl_id, rm_id = v_rm_id
59 WHERE em_id = p_em_id
60 AND cod_stud = p_cod_stud;
61 -- update sex of room or apartment floor:
62 IF v_sex = 0 THEN
63 IF v_rm_cat = 'ROOM' THEN
64 UPDATE rm
65 SET sex = p_sex
66 WHERE bl_id = v_bl_id
67 AND fl_id = v_fl_id
68 AND rm_id = v_rm_id;
69 ELSIF v_rm_cat = 'APARTMENT' THEN
70 UPDATE rm
71 SET sex = p_sex
72 WHERE bl_id = v_bl_id
73 AND fl_id = v_fl_id;
74 END IF;
75 END IF;
76 EXCEPTION
77 -- if no room is available:
78 WHEN NO_DATA_FOUND THEN
79 RAISE_APPLICATION_ERROR (-20001, 'Sorry, there is no such room available.');
80 END;
81 END reserve_rooms;
82 /
Procedure created.
scott@ORA92> SHOW ERRORS
No errors.
-- rejects unavailable room of wrong sex:
scott@ORA92> EXECUTE reserve_rooms ('BARBARA', 654321, 'BL1', 1, 101, 2, '04-02-2005', '10-02-2005')
BEGIN reserve_rooms ('BARBARA', 654321, 'BL1', 1, 101, 2, '04-02-2005', '10-02-2005'); END;
ERROR at line 1:
ORA-20001: Sorry, there is no such room available.
ORA-06512: at "SCOTT.RESERVE_ROOMS", line 79
ORA-06512: at line 1
-- accepts available room of same sex:
scott@ORA92> EXECUTE reserve_rooms ('BARBARA', 654321, 'BL1', 1, 103, 2, '04-02-2005', '10-02-2005')
PL/SQL procedure successfully completed.
-- assigns random available room of same or no sex:
scott@ORA92> EXECUTE reserve_rooms ('BARBARA', 654321, NULL, NULL, NULL, 2, '11-02-2005', '23-02-2005')
PL/SQL procedure successfully completed.
-- results:
scott@ORA92> -- one and only one row added to em table:
scott@ORA92> SELECT * FROM em WHERE em_id = 'BARBARA'
2 /
EM_ID BL_I FL_ID RM_ID COD_STUD
BARBARA BL1 1 102 654321
scott@ORA92> -- rooms reserved and other people who have reserved same room
scott@ORA92> -- (there are 3 who reserved a double room, but only 2 at a time):
scott@ORA92> SELECT *
2 FROM rmpct
3 WHERE (bl_id, fl_id, rm_id) IN
4 (SELECT bl_id, fl_id, rm_id
5 FROM rmpct
6 where em_id = 'BARBARA')
7 /
EM_ID BL_ FL_ID RM_ID DATE_STAR DATE_END COD_STUD
BARBARA BL1 1 102 11-FEB-05 23-FEB-05 654321
SERAFINO BL1 1 102 12-FEB-04 19-FEB-04 589920
VIDAL BL1 1 102 16-FEB-04 01-MAR-04 602877
SERAFINO BL1 1 103 01-FEB-04 15-FEB-04 589920
TAKEM BL1 1 103 04-FEB-05 10-FEB-05 569673
BARBARA BL1 1 103 04-FEB-05 10-FEB-05 654321
6 rows selected.
scott@ORA92> -- rooms reserved are all correct sex
scott@ORA92> -- (note that room 102 was updated from 0 to 2):
scott@ORA92> SELECT *
2 FROM rm
3 WHERE (bl_id, fl_id, rm_id) IN
4 (SELECT bl_id, fl_id, rm_id
5 FROM rmpct
6 where em_id = 'BARBARA')
7 /
BL_ FL_ID RM_ID SEX R RM_CAT
BL1 1 102 2 D ROOM
BL1 1 103 2 T ROOM
scott@ORA92> -
Error in Executing Procedure through DBLink
Hi,
I am facing some problems in executing a procedure through DBLink.
I have two schema A and B in two different database.
In schema A I am having one procedure X in package Y and my requirement is that I want to execute this procedure in schema B. So in schema B i have created one DBLink ABC and trying to execute procedure X using this DB link.
begin
A.Y.X@ABC;
end;
But I am getting below error:
ORA-06550: line 2, column 1:
PLS-00201: identifier 'A.Y.X@ABC' must be declared
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
Any help would be greatly appreciated!
Thanks In Advance..
Regards,
Sachin BansalHi,
Yes, I am connecting to user A of DB1 and in this user I am having procedure X in Package Y. My DBLink in Schema B of DB2 is pointing to user A of DB1.
I have created DBLINK using below script:
create public database link abc
connect to A
identified by A
using '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX)(PORT=1521)))(CONNECT_DATA=(service_name=XXX)))';
Above DBLInk is working fine..I am able to access all the table of schema A in schema B using this DBLink. But when I trying to execute any procedre of schema A in schema B then i am getting error.
Regards,
Sachin -
Apex 4 error ORA-04042 procedure, function, package body does not exist
Hi all,
I was instaling Oracle Application Expres 10g on Linux ubuntu and I was download and unzip apex 4
on /usr/lib/oracle/xe/
then connect as SYS as sysdba with pass and
start
@/usr/lib/oracle/xe/apex/apexins SYSAUX SYSAUX TEMP /i/
installation starting
... after 5 minutes theres end of log file>
I. O R A C L E S Y S I N S T A L L P R O C E S S
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/dev_grants.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/core_grants.sql"
...CONNECT as the Oracle user who will own the APEX engine
Session altered.
III. I N S T A L L A P E X P A C K A G E S P E C S
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_plsql_editor.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_model_api.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_f4000_util.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_plugin_f4000.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_image_generator.sql"
Installing Team Development objects
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/team_tab.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_team.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_team_api.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_team_gen_api.sql"
Installing Application Migration Workshop objects
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_create_ddl.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_create_ddl.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_exporter_ins.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/mig_views.sql"
...installing Application Migration Workshop package spec
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_acc_load.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_load_xml.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_olb_load_xml.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_update_apx_app.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_utilities.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frmmenu_load_xml.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_rpt_load_xml.sql"
...install Application Migration Workshop package body
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_acc_load.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_load_xml.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_olb_load_xml.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_update_apx_app.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frm_utilities.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_frmmenu_load_xml.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_mig_rpt_load_xml.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_item_comps.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_translation_utilities.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copy.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copy_lov.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copy_item.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copy_button.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_translation_utilities.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/seed.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/sync.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/layout.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_lov_used_on_pages.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_query_builder.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_sw_object_feed.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_load_data.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_load_excel_data.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copy_metadata.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copyu.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_tab_mgr.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/generate_ddl.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/table_drill.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_download.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_copy_page.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/generate_table_api.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_gen_hint.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_xliff.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_create_model_app.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/apex_admin.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_help.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_data_quick_flow.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_theme_files.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_session_mon.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_sw_page_calls.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_wiz_confirm.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_page_map.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_drag_layout.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_dataload_xml.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/apex_ui_default_update.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/apex_mig_projects_update.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_install_wizard.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_dictionary.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_advisor.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_search.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_f4000_plugins.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_4000_ui.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_4050_ui.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_workspace_reports.sql"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_f4000_p4150.sql"
timing for: Development Package Specs
Elapsed: 00:00:00.02
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_plsql_editor.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_model_api.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_f4000_util.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_plugin_f4000.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_image_generator.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/layout.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_query_builder.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_sw_object_feed.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_load_data.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_load_excel_data.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copy_metadata.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/copyu.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_tab_mgr.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/generate_ddl.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/table_drill.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_download.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_copy_page.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/generate_table_api.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_gen_hint.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_translation_utilities.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_xliff.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_create_model_app.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_help.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_data_quick_flow.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_theme_files.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_session_mon.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_sw_page_calls.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_wiz_confirm.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_page_map.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_drag_layout.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_dataload_xml.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/apex_ui_default_update.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/apex_mig_projects_update.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_install_wizard.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_dictionary.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_advisor.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_search.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_f4000_plugins.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_4000_ui.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_4050_ui.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_translation_utilities.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_team.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_team_api.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_team_gen_api.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_workspace_reports.plb"
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_flow_f4000_p4150.plb"
...install demonstration Oracle APEX application package specs
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/collections_showcase.sql"
...install demonstration Oracle APEX application package bodies
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/collections_showcase.plb"
...install demonstration tables
SP2-0310: unable to open file "/usr/lib/oracle/xe/apex/coreinscore/wwv_demo_tab.sql"
timing for: Development Package Bodies
Elapsed: 00:00:00.03
grant execute on wwv_mig_acc_load to public
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
is there any solution?
regards
GordanInstall 4.0 pass ok!
1. I was changing apexins.sql
as PREFIX='@/usr/lib/oracle/xe/apex/'
and add path to coreins.sql as @/usr/lib/oracle/xe/apex/coreins.sql
2. create two folders coreinscore and coreinsbuild and copy all files from folder core and folder build
3. copy and rename endins.sql as coreinsendins.sql
after 10 min instalation pass ok!
Gordan
Edited by: useruseruser on Jun 29, 2010 2:12 PM -
Calling of stored procedure in package
Hi,
I have one stored procedure A. And one package of name P1.
I have execute previlage of package but not having any previlge of stored procedure.
and In package P1 stored procedure A is called. then this packege is work or it will genrate an Error?Oracle users - userA, userB
Stored procedure - procedure1
Package - package1
Who is owner of procedure1 and package1?
Which privileges of userA/userB on procedure1 and package1? -
How can I compile all functions, procedures and packages with a script?
I need to compile all functions, procedures and packages of 5 schemas (users) with a script.
How can I do it?
Thanks!you can create a script to select all invalid objects in those schemas Since Oracle 8 introduced NDS this approach has struck me as a trifle old fashioned. It's much simpler to loop round the query in PL/SQL and use EXECUTE IMMEDIATE to fire off the DDL statements. No scripts, no muss, no fuss.
Having said that, the problem with this approach and also with using DBMS_UTILITY.COMPILE_SCHEMA is that they do not compile all the invalid objects in dependency order. This may result in programs being invalidated by the subsequent compilation of dependencies. This is due to the introduction of Java into the database.
The UTLRP script is much better, because it (usually) avoids cyclic references. But you still may need to run it more than once.
In general it is better to avoid sledgehammer recompilations (like DBMS_UTILITY.COMPILE_SCHEMA, which starts by invalidating all the objects). If we have twenty invalid objects, nineteen of which are dependencies of the twentieth, we actually only need to recompile the master object, as recompiling it will trigger the recompilation of all the others.
Cheers, APC -
Hi,
Needed your inputs on approach to implement a job using dbms_scheduler.
We have around 2000 schemas. Each schema has a package with 2 procedures.
The requirement is to create a single job in SYS that would loop through each schema and run the procedures at a specific time ( once a day) and send email notification on success or failure.
Job script:
BEGIN
dbms_scheduler.create_job( job_name=> 'LOAD_EACH_SCHEMA_AUDIT_DATA',
job_type=>'PLSQL_BLOCK',
job_action=>'BEGIN sys.p_loadaudit;
END;',
start_date=>systimestamp,
repeat_interval=>'FREQ=MINUTELY;INTERVAL=1',
number_of_arguments=>0,
enabled=> true,
comments=>'Job repeat interval is every 5 mins' );
END;
Note: for testing purpose i have set repeat interval to minutely.
Procedure job will be executing:
Procedure sys.p_loadaudit:
CREATE OR REPLACE
PROCEDURE p_loadaudit
AS
v_count NUMBER:= 0;
lv_error_message VARCHAR2(4000);
vstmt VARCHAR2(4000);
BEGIN
FOR i IN
( SELECT username FROM dba_users WHERE username LIKE 'ABCFIRM%'
LOOP
vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_coa; end;';
EXECUTE immediate vstmt;
vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_am; end;';
EXECUTE immediate vstmt;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
lv_error_message := 'Error in procedure p_loadaudit: ' || SQLCODE || ' -ERROR- ' || SUBSTR(
sqlerrm,1,300) || '*' || dbms_utility.format_error_backtrace;
raise_application_error(-20002,lv_error_message);
END p_loadaudit;
Example of one schema: SCHEMA_01
create or replace
PACKAGE pkg_audit_info
AS
type cursortype
IS
ref
CURSOR;
PROCEDURE p_load_COA;
PROCEDURE p_load_AM;
END pkg_audit_info;
create or replace
PACKAGE body pkg_audit_info
AS
PROCEDURE p_load_COA
AS
BEGIN
INSERT INTO TABLE1();
EXCEPTION
WHEN OTHERS THEN
lv_error_message := 'Error in procedure pkg_audit_info.p_load_COA: ' || SQLCODE
|| ' -ERROR- ' || SUBSTR(SQLERRM,1,300) || '*' || dbms_utility.format_error_backtrace;
RAISE_application_error(-20002,lv_error_message);
END p_load_COA;
PROCEDURE p_load_AM
AS
BEGIN
INSERT INTO TABLE2();
EXCEPTION
WHEN OTHERS THEN
lv_error_message := 'Error in procedure pkg_audit_info.p_load_AM: ' || SQLCODE ||
' -ERROR- ' || SUBSTR(SQLERRM,1,300) || '*' || dbms_utility.format_error_backtrace;
RAISE_application_error(-20002,lv_error_message);
END p_load_AM;
END pkg_audit_info;
Table1 and table1 exist in schema_01.
All 2000 schemas have same package.procedures.
Due to security reasons i have removed the actual code.
I was able to execute the job successfully. However, when a schema procedure (SCHEMA_01.pkg_audit_info.p_load_COA) throws an exception, the job fails and all transaction is rolled back.
Is there a way to loop through each schema and execute the related procedures. Even if exception happens, it should rollback only for that schema and continue the other schemas in the loop?
Please let me know if there is a better way to achieve this. Is the way i am handling exceptions in the job/procedure correct?
ThanksHi,
RAISE_APPLICATION_ERROR will cause the program to exit back to the caller, even if you place it in a block within the loop, so the RAISE or RAISE_APPLICATION_ERROR instruction should be placed in your "pkg_audit_info.p_load_AM" and "pkg_audit_info.p_load_coa" procedures. This way, you can use a block inside the loop and log the error.
FOR i IN
( SELECT username FROM dba_users WHERE username LIKE 'ABCFIRM%'
LOOP
BEGIN
vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_coa; end;';
EXECUTE immediate vstmt;
vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_am; end;';
EXECUTE immediate vstmt;
EXCEPTION
WHEN OTHERS THEN
--> Log the error in a custom log table otherwise you will not know what happened for that schema: don't forget the username
END;
END LOOP; -
ORA-04042: procedure, function, package, or package body does not exist
getting following error
I have logged on as sys
GRANT EXECUTE ON CTXSYS.CTX_DDL TO public
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
does it need Oracle text installed
comp_name
Oracle Database Catalog Views
Oracle Database Packages and Types
Oracle Workspace Manager
JServer JAVA Virtual Machine
Oracle XDK
Oracle Database Java Packages
Oracle Expression Filter
Oracle XML Database
Oracle Rules Manager
Oracle Multimedia
Oracle Real Application Clusters912919 wrote:
getting following error
I have logged on as sys
GRANT EXECUTE ON CTXSYS.CTX_DDL TO public
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
does it need Oracle text installed
comp_name
Oracle Database Catalog Views
Oracle Database Packages and Types
Oracle Workspace Manager
JServer JAVA Virtual Machine
Oracle XDK
Oracle Database Java Packages
Oracle Expression Filter
Oracle XML Database
Oracle Rules Manager
Oracle Multimedia
Oracle Real Application Clustersit worked for me.
09:10:19 SQL> GRANT EXECUTE ON CTXSYS.CTX_DDL TO public;
Grant succeeded.
09:10:23 SQL>
Maybe you are looking for
-
Itunes won't start-says it has to shut down
i started having problems with itunes and downlaoded the new itunes. won't start. in the error report it sayd its a compatability issue. when i send the report to ms though, they claim it to be an itunes problem. i could use a lot of help.
-
Table or Function Module to get Condition Values of Quotation
Hi MM Gurus I created RFQ. Then I maintained Quotation for few Vendors. In the Quotation, I used tax code relevant to taxes in India (TAXINN procedure). I am asked to develop a Z report with the help of ABAPer to compare the quotations with Gross pri
-
Import Standard Purchase Orders return error
Dear All , when i ran the Import Standard Purchase Orders concurent program , it completed with the following errors DECLARE ERROR at line 1: ORA-06510: PL/SQL: unhandled user-defined exception ORA-06512: at line 133 So please can anyone have a solut
-
Dear All, I made several photos many times ago... After I put them in several maps, Each photo received there own name, I replaced them from those that the camera gives...So now I want too put each photo on my IPad but when I'm looking too the name h
-
Hi, I have 5th field in my data file which contains new line character and client want to preserve this character. My data file is CSV which means that record will be terminated by /n. But since new line character is coming in one of the field, it is