Create editionable view on Oracle - oracle

I am trying to create an ORACLE EDITIONABLE VIEW but I am getting the error:
SQL Error: ORA-00922: missing or invalid option
00922. 00000 - "missing or invalid option"
CREATE OR REPLACE FORCE EDITIONABLE VIEW "SCHEMA"."TABLE" ....
In https://docs.oracle.com/database/121/SQLRF/statements_8004.htm#SQLRF01504 is mentioned how u can create this kind of view.
If I remove EDITIONABLE the view is created without a problem.
Some advice will be welcomed :-)

Wrong syntax prbly
CREATE EDITIONING VIEW
You need oracle 11gR2 or higher
Also you need to enable Editions for user: (from here)
Enabling editions for a user is done using the ALTER USER command. This is not reversible. The result of this command can be seen by querying the EDITIONS_ENABLED column of the DBA_USERS view.
CONN / AS SYSDBA
ALTER USER edition_test ENABLE EDITIONS;

Related

Unable to alter a view: ORA-00942: table or view does not exist

I want to change FND_LOOKUPS by adding a new column and the SQL statement is :
alter table FND_LOOKUPS add Tag VARCHAR2(150 CHAR);
But the error :
" ORA-00942: table or view does not exist"
always shows.
While FND_LOOKUPS does exist.
I checked the duplicate issues and grant the access by:
GRANT ALL ON FND_LOOKUPS TO public;
And it prompts grant successfully, but the issue still exists.
What's the possible reason for this issue?
Any suggestions would be appreciated, thanks in advance!
Sorry for misleading you guys. I use the following statement to check the "table" and found the object type is a VIEW:
SELECT * FROM all_objects WHERE object_type IN ('TABLE','VIEW') AND object_name = 'FND_LOOKUPS'
So the issue should be how to alter a view by adding one column to it.
I use the following syntax to achieve this:
CREATE OR REPLACE <optional: FORCE EDITIONABLE> VIEW "user_name"."view_name" (all coloumns) AS
<select statement>
FROM
<basic table>
WHERE
<whereclause>
It works fine at last.
Thanks very much to you.

Running query cannot connect to vendort's database, even dblink exists

I have a simple query, which I run on sqldeveloper on put database, but it select data from different vendor database. We have db_link created. but I run, as in my Pro C program:
select some_files from mytable trd, vendordbname.vendortable
where(condition)
and I get an error:
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 25 Column:
What kind of solution I have to find, to make it run? Use dblink name? or something else? I will appreciate any possible help
Thanks
ok, when it runs with Pro C, everything sets up on UNIX and sqlplus.
When I run it from sqldeveloper I have to add the vendor host name
select some_files from mytable trd, vendordbname.vendortable#vendorhost
where(condition)

ORA-00980 synonym translation no longer valid in PLSQL

I've got a synonym on a remote Oracle database that I can access in SQL over a database link, eg,
insert into my_table select * from my_synonym#my_database_link;
If I put the above statement into a PLSQL block, it won't compile, giving the error message "ORA-00980: synonym translation is no longer valid". The standard explanation is the table that the synonym points to has been dropped, etc, but this is not the case because the statement works in SQL.
If something works in SQL but not in PL/SQL then in most cases this is a problem with privileges.
Any privilege that a user received through a role is not active when you enter a PL/SQL block. So most probably the SELECT privilege on the underlying table was granted through a role and thus is not "active" in the PL/SQL block.
The usual cure for this is to grant the privileges directly to the user, not through a role.
Thank you to everyone who tried to help. This turned out to be an Oracle limitation:
https://support.oracle.com/rs?type=doc&id=453754.1
APPLIES TO:
PL/SQL - Version 9.2.0.8 and later Information in this document
applies to any platform.
Checked for relevance on 01-Apr-2015
SYMPTOMS
A PL/SQL block fails with error: ORA-00980: synonym translation is no
longer valid, when selecting data from a remote database. The
following code demonstrates this issue:
On DB3 (create the table)
CONNECT u3/u3 DROP TABLE tab; CREATE TABLE tab(c1 number); INSERT
INTO tab VALUES (1); COMMIT;
On DB2 (create a synonym to the table on DB3)
CONNECT u2/u2 DROP DATABASE LINK dblink2; CREATE DATABASE LINK
dblink2 CONNECT TO u3 IDENTIFIED BY u3 USING 'EMT102U6'; SELECT *
FROM global_name#dblink2; DROP SYNONYM syn2; CREATE SYNONYM syn2
FOR tab#dblink2; SELECT * FROM syn2;
On DB1 (create a synonym to the synonym on DB2)
CONNECT u1/u1 DROP DATABASE LINK dblink1; CREATE DATABASE LINK
dblink1 CONNECT TO u2 IDENTIFIED BY u2 USING 'EMT102W6'; SELECT *
FROM global_name#dblink1; DROP SYNONYM syn1; CREATE SYNONYM syn1
FOR syn2#dblink1; SELECT c1 from syn1;
This works in SQL but fails when called from PL/SQL
DECLARE num NUMBER; BEGIN SELECT c1 INTO num FROM syn1; END;
/
ERROR at line 4: ORA-06550: line 4, column 3: PL/SQL: ORA-00980:
synonym translation is no longer valid ORA-06550: line 4, column 3:
PL/SQL: SQL Statement ignored
CAUSE
This issue was reported in Bug 2829591 QUERING FROM A PL/SQL
PROCEDURE IN 9I -> 8I-> 7.3.4, GETTING ORA-980. This bug was closed
as 'NOT A BUG' for the following reasons
PL/SQL cannot instruct middle database (DB2) to follow the database
link during the compilation phase. Therefore in order for this PL/SQL
block to compile and run, both database links dblink1 and dblink2
should be defined on the front end database - DB1. During runtime
database link dblink2 will be looked up in DB2 as expected.
SOLUTION
To implement the solution, please execute the following steps:
Create a database link dblink2 on DB1 pointing to DB3
SQL> create database link dblink2 connect to u3 identified by u3 using
'EMT102U6';
Create and compile the PL/SQL block on DB1.
CREATE DATABASE LINK dblink2 CONNECT TO u3 IDENTIFIED BY u3 USING
'EMT102U6';
SELECT * FROM global_name#dblink2; DECLARE num NUMBER; BEGIN
SELECT c1 INTO num FROM syn1; END; / PL/SQL procedure successfully
completed.
TIP: Another option is to use dyanmic SQL in the PL/SQL block as a
work around. When using dynamic SQL the database link is not resolved
at compile time but at runtime.
Workaround solution is to use an Oracle view instead.
CREATE VIEW v_my_synomym as (select * from my_synonym#my_database_link);
Then reference the view in your package or procedure i.e.:
insert into my_table select * from v_my_synonym;
Check in remote database grants for "my_synonym" must be almost "select" for the user you use in connect string, check also the object which this synonym points at (maybe someone deleted the table).
I found this issue when owner of the table/view/procedure are not match with owner mentioned in SYNONYM.
Example : If owner of table TABLE_BRACH is ownerA and in Synonym mentioned table owner is something else (Not ownerA).
Solution:
1. Drop the SYNONYM
2. Create that with same name with correct owner.
CREATE PUBLIC SYNONYM BRANCH FOR ownerA.TABLE_BRACH ;

How to recreate public synonym "DUAL"?

Using SQLDeveloper 4.0.1.14 to create an export script (separate files & "drops" checked), it generated me those 4 lines among others in DROP.sql:
DROP SYNONYM "PUBLIC"."DUAL";
DROP SYNONYM "PUBLIC"."DBMS_SQL";
DROP SYNONYM "PUBLIC"."DBMS_LOCK";
DROP SYNONYM "PUBLIC"."DBMS_OUTPUT";
Now that I have accidentally passed the whole script using SYSTEM user, I can no longer do modification (create or drop tables) to the database, I have that error popping:
An error was encountered performing the requested operation:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
Vendor code 604
The problem is that I'm getting that error event when I try this:
CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";
I precise that the SYS.DUAL table still exists as SELECT 1 FROM SYS.DUAL works but SELECT 1 FROM DUAL fails with ORA-00942: table or view does not exist.
I tried to recreate the synonym as SYSTEM and SYSDBA with the same failure.
Can I recreate those synonyms with another way?
Try it as SYS but without the doauble quotes, i.e.:
CREATE OR REPLACE PUBLIC SYNONYM DUAL FOR SYS.DUAL;
not
CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";
As I understand it the double quotes make the object name case sensitive.
Update - If you have access to metalink then you will find the answer in note 973260.1, something aboput a trigger firing :
ALTER SYSTEM SET "_SYSTEM_TRIG_ENABLED"=FALSE SCOPE=MEMORY;
CREATE OR REPLACE PUBLIC SYNONYM DUAL FOR SYS.DUAL;
ALTER SYSTEM SET "_SYSTEM_TRIG_ENABLED"=true SCOPE=MEMORY;
The note suggest that if this doesnt work, query DBA_TRIGGERS to find a BEFORE CREATE trigger enabled, and if found disable it and then re-issue create synonym statement, then re-enable the trigger.

Unable to use synonym of functions, procedures or seq in Oracle

I have created synonyms for functions/proc/seq in userid YYY from user id XXX.
create SYNONYM my_seq FOR XXX.my_seq
When I try to use the seq in user YYY, I am getting following error :
ORA-00942: table or view does not exist
and with functions : ORA-00904: : invalid identifier
Please let me know where I am doing wrong.
I am going to demonstrate with a simple example. I have two schemas on one server. Schema1 and Schema2.
I logon to Schema1 and run the script below.
-- Create sequence
create sequence originalSeq
minvalue 1
maxvalue 999999999999999999999999
start with 1
increment by 10
cache 20;
GRANT SELECT ON originalSeq TO SCHEMA2;
Then I logon to Schema2 and run the following script.
create or replace synonym pointertooriginalsreq
for SCHEMA1.originalSeq;
select pointertooriginalsreq.nextval from dual
this should work in all versions of Oracle 8.1.7 upwards. Please let me know if you're still facing a problem.
You have to provide grants from XXX user:
GRANT SELECT ON my_seq TO YYY;

Resources