Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
exec procedure as parsing schema, not APEX_PUBLIC_USER

Willeja
Hulshout - BelgiumMember Posts: 89
We have a package with a procedure:
CREATE OR REPLACE PACKAGE XGN4.xgn_generator$pck
AUTHID DEFINER AS
PROCEDURE cr_tab(tab_id IN NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY XGN4.xgn_generator$pck
PROCEDURE cr_tab(tab_id IN NUMBER)
IS
BEGIN
execute immediate('CREATE TABLE test(......)');
END;
END;
When I call this procedure from apex, it's always executed as 'APEX_PUBLIC_USER', but it should be as the parsing schema 'XGN4'.
I thought 'AUTHID DEFINER' should do the trick (it's standard when you're not using AUTHID), but it looks like it has no effect on APEX...
Anyone?
CREATE OR REPLACE PACKAGE XGN4.xgn_generator$pck
AUTHID DEFINER AS
PROCEDURE cr_tab(tab_id IN NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY XGN4.xgn_generator$pck
PROCEDURE cr_tab(tab_id IN NUMBER)
IS
BEGIN
execute immediate('CREATE TABLE test(......)');
END;
END;
When I call this procedure from apex, it's always executed as 'APEX_PUBLIC_USER', but it should be as the parsing schema 'XGN4'.
I thought 'AUTHID DEFINER' should do the trick (it's standard when you're not using AUTHID), but it looks like it has no effect on APEX...
Anyone?
Tagged:
Best Answer
-
Your application's parsing schema must be granted object and system privileges that it needs using "direct" grants, not grants through roles.
Scott
Answers
-
You don't say how you are running the procedure, from within an application or using the SQL Workshop. In the former case the package/procedure will be parsed as the "owner" or parsing schema of your application. In the latter, as the selected workspace schema. It will never, ever be parsed as APEX_PUBLIC_USER.
Scott -
In Apex the parsing schema is set to 'XGN4'.
We call the procedure in a process on the apex-page.
Is there a way to see which user is parsing the procedure? -
I used the following to check which user is parsing:
insert into test(test) values('Create Table As: '||USER);
The result (when calling from apex-page) would be 'APEX_PUBLIC_USER'.
Please correct me if I'm wrong... -
Ok Scott, you are right.
I used sys_context('USERENV','CURRENT_USER') to identify the user and it's the right parsing schema (XGN4).
But why won't my code execute right in apex when it does straight from SQL-DEVELOPER (or another tool)?
Eg:
In toad: EXEC packagename.procedure(parameter);
in Apex: begin; packagename.procedure(parameter); end;
the procedure contains an execute immediate('alter tabel ...') and will do his job in the first case, but returns an error insufficient privs from apex. -
Your application's parsing schema must be granted object and system privileges that it needs using "direct" grants, not grants through roles.
Scott -
That did it... Thank you.
Is there a reason why a role isn't good?
The only thing now that isn't working will be the 'ALTER ANY TABLE' privilege.
Edited by: Willeja on Oct 30, 2008 8:33 AM -
Is there a reason why a role isn't good?In Oracle, roles are not enabled during the execution of definer's rights stored procedures which is how you can consider an Application Express application.The only thing now that isn't working will be the 'ALTER ANY TABLE' privilege.That's a powerful privilege for your application's parsing schema to have.
Scott -
That's a powerful privilege for your application's parsing schema to have.
Yes it is, but there are only 2 persons who will use this schema and normally they know what they are doing.
I solved the problem. Alter any table wasn't sufficient because we did:
alter table X add ( column number default 1);
Because of the default we also needed the 'UPDATE ANY TABLE'.
Thank to all your answers...
This discussion has been closed.