Is there a means of querying a database environment to retrieve all Oracle APEX application IDs, together with the workspace name they belong to?
I basically want to create an LOV within an Oracle APEX app that can see all APEX application IDs and Workspaces.
I tried the APEX_APPLICATIONS view but that only displays info within the workspace you are in. I want to see all workspaces and application ids.
Is granting the apex_administrator_role to the parsing schema plausible? Your query would probably still want to exclude internal workspaces such as INTERNAL, COM.ORACLE.CUST.REPOSITORY and COM.ORACLE.APEX.REPOSITORY
SQL> conn hr/hr#XE1
Connected.
SQL>
SQL>
SQL> select count(1)
2 from apex_applications;
COUNT(1)
----------
0
SQL> disconnect
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> connect sys/oracle#XE1 as sysdba
Connected.
SQL> grant apex_administrator_role to hr;
Grant succeeded.
SQL> commit;
Commit complete.
SQL> conn hr/hr#XE1
Connected.
SQL> select count(1)
2 from apex_applications
3 ;
COUNT(1)
----------
60
note: This will also give your schema access to the APEX_INSTANCE_ADMIN API.
Related
This question already has answers here:
Why my Oracle 10g does not have the scott account?
(2 answers)
Closed last month.
recently download oracle 11g, tried login using scott, turns out scott doesnt exist . I logged in using sys as sysdba and ran 'show pdbs' but it showed 'unknown show option pdbs'.
I looked up online and found that i need to run the scott.sql. But then i couldnt find the scott.sql file in the expected location. pls help
11g is rather old, there's no PDB there.
As you're logged as SYS, run the following command and say what status you got (in my database, it is OPEN):
SQL> select account_status from dba_users where username = 'SCOTT';
ACCOUNT_STATUS
--------------------------------
OPEN
SQL>
If it is LOCKED (which might be), then run
SQL> alter user scott account unlock;
User altered.
SQL> alter user scott identified by tiger;
User altered.
SQL>
and - finally - connect:
SQL> connect scott/tiger
Connected.
SQL>
If you really don't have that schema, create it. See this for more info.
I am using Oracle and SQL Developer. I have a table called T_TEST owned by SYSTEM (I know, that I shouldn't do it, but it's not a commercial project). I created another user and gave him this privileges:
GRANT CONNECT TO admin1;
GRANT CREATE SESSION TO admin1;
GRANT SELECT ON T_TEST TO admin1;
When I run this query I get the expected result:
SELECT SUM(value) FROM SYSTEM.T_TEST;
However, when I try to wrap this query in a transaction like this:
CREATE PROCEDURE reader
AS
BEGIN
SET TRANSACTION READ ONLY;
SELECT SUM(value) FROM SYSTEM.T_TEST;
COMMIT;
END;
I get this error:
ORA-01031: insufficient privileges
So which privilege am I missing here?
You are missing grants to create a procedure. You can do that by following the below command -
GRANT CREATE PROCEDURE TO [domain\user]
This link has a whole list of permissions that you can grant to the users. Enjoy your project.
I have download the oracle sql developer version 21.2.1 and I want to create a new connection. But I do not have any schema created. Can somebody help me or any links would be helpful.
Note: I have searched on youtube and google. All the tutorials that I have seen seems to have already a schema.
Well, SQL Developer you downloaded is just a tool you'd use to access an Oracle database. What you need next is the database itself. Once you download & install it, create user (schema). This is 11g database version example:
Connect as a privileged user (SYS if you don't have any other; and you probably don't) using SQL*Plus (command-line tool):
SQL> connect sys/password_goes_here#xe as sysdba
Connected.
SQL> select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USER_DATA
Create user:
SQL> create user will identified by ashoti
2 default tablespace user_data
3 temporary tablespace temp
4 quota unlimited on user_data;
User created.
Grant privileges which will allow that user to actually do something:
SQL> grant create session to will;
Grant succeeded.
SQL> grant create table to will;
Grant succeeded.
That's it; connect as newly created user:
SQL> connect will/ashoti#xe
Connected.
SQL> create table test as select sysdate as datum from dual;
Table created.
SQL> select * from test;
DATUM
----------
06.10.2021
SQL>
It works; moreover, it means that you should now be able to establish connection via SQL Developer as well.
I am not very experienced with Oracle and BFILEs, so I apologize if the answer to my question is very obvious.
I am using Oracle SQL Developer and Oracle Database 12c Enterprise Edition.
I try to save images externally via BFILE. For this I created a directory and a table and inserted the BFILEs:
DROP DIRECTORY PICTURE;
CREATE OR REPLACE DIRECTORY PICTURE AS 'C:\PICTURE';
DROP TABLE TEST1;
CREATE TABLE TEST1( NR INTEGER, IMAGE BFILE );
INSERT INTO TEST1 VALUES( 1, BFILENAME('PICTURE','IMG.png') );
The code runs without errors. Now I want to check that I have pasted the code correctly. To do this, I use the following function.
SELECT DBMS_LOB.GETLENGTH(IMAGE) FROM TEST1;
After executing the function, I get the following error message.
ORA-22288: file or LOB Operation GETLENGTH failed
The system could not find the specified path.
ORA-06512: in "SYS.DBMS_LOB", line 850
What can be the reason? Could it be that I am not allowed to specify the path like this? The path points to a folder on my PC. Can the program access it? If that's not the problem, what could be causing the error message?
UPDATE:
When I run the Grand command to assign me the rights, I get the following error message
SQL > GRANT READ, WRITE ON DIRECTORY PICTURE TO XYZ;
ORA-01749: you may not GRANT/REVOKE privileges to/from yourself
I assumed that means I already have the rights.
Connect as XYZ works:
SQL> show user
USER is "XYZ"
SQL> select * from all_directories where directory_name = 'EXT_DIR';
OWNER DIRECTORY_NAME DIRECTORY_PATH
------------------------------ ------------------------------ --------------------
SYS PICTURE c:\PICTURE
SQL>
For the rest of the code, my output coincides with the output from Littlefoot's answer. Only with the .getlength () function do I get the error message described above.
It could be that the problem is that my PC is not a database server. I use a PC with Windows 10. I have downloaded the following Version:
https://www.oracle.com/de/tools/downloads/sqldev-v192-downloads.html
And I run the application every time using the following icon from the Explorer:
SQL Developer Icon
In the SQL Developer I then connected to a database instance. In the database instance a scheme is available to me with which I can set up and manage files. The PICTURE folder with the pictures is, as I said, on my PC in drive C: . I am trying to create a directory which then accesses this folder. Can I do that without having specially configured my PC?
Directory is an Oracle object which points to a filesystem directory which is (usually; let's pretend "always") located on a database server. If your PC isn't one, then it won't work.
As directory points to c:\picture on the database server,
that directory must really exist there
image must be in it
make sure that you didn't miss the actual file name
you, as user, have to have (at least) read privilege to access it.
that's what is missing in code you posted. User (SYS, I presume), who created the directory, should have ran e.g.
grant read, write on directory picture to sql_user;
(or whichever user you really use).
Here's an example. I'm running Oracle 11gXE on my laptop (so it is a database server). File is located in c:\temp directory which is set to be Oracle EXT_DIR directory.
c:\Temp>dir robco.jpg
Volume in drive C is OSDisk
Volume Serial Number is 7635-F892
Directory of c:\Temp
25.09.2017. 20:27 6.427 robco.jpg
1 File(s) 6.427 bytes
0 Dir(s) 234.166.730.752 bytes free
c:\Temp>
Let's see the Oracle side: first, grant access to user scott (who will load the file):
SQL> show user
USER is "SYS"
SQL> grant read, write on directory ext_dir to scott;
Grant succeeded.
SQL>
Connect as scott:
SQL> show user
USER is "SCOTT"
SQL> select * from all_directories where directory_name = 'EXT_DIR';
OWNER DIRECTORY_NAME DIRECTORY_PATH
------------------------------ ------------------------------ --------------------
SYS EXT_DIR c:\temp
SQL>
Create a table, insert a row, check the contents:
SQL> CREATE TABLE TEST1( NR INTEGER, IMAGE BFILE );
Table created.
SQL> INSERT INTO TEST1 VALUES( 1, BFILENAME('EXT_DIR','robco.jpg') );
1 row created.
SQL> SELECT * FROM test1;
NR IMAGE
---------- --------------------------------------------------
1 bfilename('EXT_DIR', 'robco.jpg')
SQL> SELECT DBMS_LOB.GETLENGTH(IMAGE) FROM TEST1;
DBMS_LOB.GETLENGTH(IMAGE)
-------------------------
6427
SQL>
So, if everything is done properly, it works.
Simply querying running jobs using something like
select * from dba_jobs_running;
works fine when executed in my sqldevelopers SQL console.
However, it does not work, when having exactly the same statement within a procedure.
Compilation fails with
PL/SQL: ORA-00942: table or view does not exist
Any ideas? Is there something like a scope to be considered?
Any suggestions are highly appreciated, thanks in advance :)
You probably need to do a direct GRANT of DBA_JOBS_RUNNING to the user that owns the procedure. Doing a GRANT via a role won't work.... the grant needs to be explicit.
EDIT:
Doing a SELECT from within a procedure requires subtly different permissions to doing a SELECT from outside a procedure (e.g. in SQL-Developer). The user that owns a procedure must have been explicitly granted rights to the table or view... if running a query from outside a view this is not the case (you can be granted the permission through a role for example)
You need to connect as SYS and go:
GRANT SELECT ON SYS.DBA_JOBS_RUNNING TO <user-that-owns-proc>;
Procedures are executed without roles. One way to see if you can run a command in a procedure is to execute:
SQL> set role none;
Role set
You will have the same set of rights as your procedures:
SQL> SELECT * FROM dba_jobs_running;
SELECT * FROM dba_jobs_running
ORA-00942: table or view does not exist
You have to grant select on the view directly to the user:
SQL> -- with dba account
SQL> grant select on dba_jobs_running to a;
Grant succeeded
You will then be able to compile the procedure:
SQL> -- with application schema
SQL> CREATE OR REPLACE PROCEDURE test_dba AS
2 BEGIN
3 FOR cc IN (SELECT * FROM dba_jobs_running) LOOP
4 NULL;
5 END LOOP;
6 END test_dba;
7 /
Procedure created
Is procedure owned by another user? If so have a look at:
Definer and Invoker Rights for stored routines in PL/SQL manual.
Rob