My question may be a duplicate or too easy. But I tried all the solutions I googled. Didn't help.
I have two databases. Data entry and editing are performed in the first database.
The second database only prints data. All the tables in the second database are created by materialized view. I need to refresh the materialized views to ensure that the changes in the primary database are reflected in the secondary database. Now I have a user with grant access (username sys, type SYSDBA). When I log in with the main sys user and enter refresh, the following error appears:
Error starting at line : 78 in command -
BEGIN dbms_mview.refresh ('VIEW_NAME'); END;
Error report -
ORA-01031: insufficient privileges
ORA-06512: on "SYS.DBMS_SNAPSHOT_KKXRCA", line 2957
ORA-06512: on "SYS.DBMS_ISNAPSHOT", line 213
ORA-01403: data not found
ORA-06512: on "SYS.DBMS_ISNAPSHOT", line 193
ORA-06512: on "SYS.DBMS_SNAPSHOT_KKXRCA", line 2791
ORA-06512: on "SYS.DBMS_SNAPSHOT_KKXRCA", line 3197
ORA-06512: on "SYS.DBMS_SNAPSHOT_KKXRCA", line 3228
ORA-06512: on "SYS.DBMS_SNAPSHOT", line 15
ORA-06512: on line 1
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
I have also created several other grant access users. But all users are getting this error.
My script as follow:
set timing on;
spool d:\irs_mv.log;
set timing on;
exec dbms_mview.refresh ('VIEW_1');
exec dbms_mview.refresh ('VIEW_2');
exec dbms_mview.refresh ('VIEW_...');
spool off;
Also i tried as follow:
BEGIN
exec dbms_mview.refresh ('VIEW_1');
END;
But all the solutions I googled are returning one error.
How can I solve this error?
Now my server:
Windows Server 2008 R2
Oracle 18c, OAS
Thanks!
There is a variety of potential reasons for this error, depending on how the mview is setup (fast/complete, local/remote etc etc).
MOS note 1231613.1 covers each of these scenarios with workarounds/solutions for each.
Related
SQL Server Admin is not my forte. So please bear with while I explain this
A SQL Server 2012 cluster is involved in a Change data capture ( CDC ) effort using a 3rd party CDC utility. for it to work replication needs to be turned on, without replication CDC will not work. The CDC taps some 2000+ odd tables from SQL Server in a database Db1. Out of these we found out that some 200+ tables undergo truncate and load as against increments. So we removed those from our CDC lists but since replication is turned on at DB Level we also need to remove these from publication database so that truncates happening to this exception list wont need replication switched off DB level ( aka truncates to these tables and replication can co-exist. As its known, for truncates to happen we need to switch off replication. The code is in prod so replacing truncate by delete is not an option now besides the fact that for billion row tables deletes are going to be expensive & time consuming )
The above is the requirement. So based on that if a better solution can be conceived do let me know
What I tried :
EXEC sys.sp_droparticle #publication = 'pub', #article = 'art', #force_invalidate_snapshot = 1
Error I get
Msg 14013, Level 16, State 1, Procedure sp_MSrepl_droparticle, Line 104 [Batch Start Line 2]
This database is not enabled for publication.
Another SP
DECLARE #subscriber AS sysname;
EXEC sp_dropsubscription #publication = 'AR_PUBLICATION_00010', #article = 'BPA_BRGR_RUL_GRP_R' ,#subscriber=#subscriber
Msg 14013, Level 16, State 1, Procedure sp_MSrepl_dropsubscription, Line 55 [Batch Start Line 1]
This database is not enabled for publication.
But using GUI I am able to uncheck the tables I dont want in that publication. ( right click publication --> properties --> articles --> check /uncheck whatever you want excluded ) . I dont have any subscription just there is a publication.
Whatever code I ran through GUI above I can def. run through T-SQL But I dont know what code was it that was run ? How do I get this done using a scripting approach. I have 200+ tables to deal with and unchecking em 1 by 1 ain't helping
Nearly four years late, but in case it helps anyone... I think you want sp_dropmergearticle not sp_droparticle.
EXEC sys.sp_dropmergearticle #publication = 'pub', #article = 'art', #force_invalidate_snapshot = 1
I was getting an identical error message using sp_droparticle, but sp_dropmergearticle removed the table from the publication and allowed me to delete it.
Whatever code I ran through GUI above I can def. run through T-SQL But I dont know what code was it that was run ? How do I get this done using a scripting approach.
SSMS does not have a special API. Everything it does, it does through TSQL. So use SQL Profiler to watch what SSMS does, and capture the script.
I am currently using RazorSQL to test queries with IBM DB2. Right now, I am stuck on an issue with creating procedures
I have the following procedure. I create this procedure as an admin user called db2inst1:
CREATE OR REPLACE PROCEDURE CANCEL_ACTIVITY (IN application_handle INTEGER)
LANGUAGE SQL
BEGIN
DECLARE UOW_ID INTEGER;
DECLARE ACTIVITY_ID INTEGER;
FOR v AS cur1 CURSOR FOR
SELECT UOW_ID, ACTIVITY_ID FROM TABLE(SYSPROC.MON_GET_ACTIVITY(application_handle, -1))
DO
CALL WLM_CANCEL_ACTIVITY(application_handle, v.uow_id, v.activity_id);
END FOR ;
END
Now, I log onto my regular user called applicationtest which is NOT an admin. If I run the following:
CALL CANCEL_ACTIVITY(12345)
I get the following error:
DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=CANCEL_ACTIVITY;PROCEDURE, DRIVER=4.16.53
According to IBM, it's caused by:
NO AUTHORIZED routine-type BY THE NAME routine-name HAVING COMPATIBLE ARGUMENTS WAS FOUND
Looking at this question, I ran this debug code to check if the users are the same, and it does not appear to be the same, because the results are:
| ROUTINESCHEMA
1 | db2inst1
2 | DB2INST1
Logically, ROUTINESCHEMA should have my regular user applicationtest in it, right?
I even ran the following:
GRANT EXECUTE ON PROCEDURE CANCEL_ACTIVITY TO PUBLIC;
To see if it would help, but still, same error.
I also tried to create the procedure using applicationtest, but as expected, I don't have the privileges required to do so.
EDIT:
I just specified DB2INST1.CANCEL_PROCEDURE(12345), and now I am getting the following error:
2016-11-18 11:27:34.983 -0800 [ERROR|01c56|] :: Java::ComIbmDb2JccAm::SqlSyntaxErrorException : DB2 SQL Error: SQLCODE=-551, SQLSTATE=42501, SQLERRMC=APPLICATIONTEST;EXECUTE;DB2INST1.CANCEL_ACTIVITY, DRIVER=4.16.53
I guess that user applicationtest doesn’t have permission to execute that procedure?
I have two questions:
Is it possible to not have to call DB2INST1 before calling the procedure? So I can just call it like this CALL CANCEL_PROCEDURE(..) instead of CALL DB2INST1.CANCEL_ACTIVITY. I feel like this would remove a lot of the ambiguity..
How do I grant applicationtest the necessary privilege to call the procedure?
You have two issues here:
The schema of the stored procedure is the implicit schema of the user that created the procedure. In this case the schema name is 'db2inst1'. When you connect with the other user, 'applicationtest' the implicit schema is the same name of the user. Then you have the following possibilities:
Set the schema to db2inst1: https://www.ibm.com/support/knowledgecenter/es/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0001016.html
Call the stored procedure with schema.name: db2inst1.cancel_activity
Set the path, including db2inst1 on it: https://www.ibm.com/support/knowledgecenter/es/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0001014.html
Between, the previous three options, I personally recommend the second one schema.name.
The other problem is the execution permission. When you create a procedure, you have to grant execution to other users / groups. In this case, db2inst1 user created the procedure, but just this user (or someone with DBADM authority) can execute it.
Because you are connecting with the other user you have to grant the execution (https://www.ibm.com/support/knowledgecenter/es/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0007699.html):
db2 grant execution on procedure db2inst1.cancel_activity to user applicationtest
I am having problems setting up change data capture on a SQL Server 2012 instance. Whenever I attempt to enable CDC on a table I get the following error:
Msg 22832, Level 16, State 1, Procedure sp_cdc_enable_table_internal,
Line 623
Could not update the metadata that indicates table
[dbo].[TableName] is enabled for Change Data Capture.
The failure
occurred when executing the command '[sys].[sp_cdc_add_job] #job_type
= N'capture''.
The error returned was 22836: 'Could not update the metadata for database [database name] to indicate that a Change Data Capture
job has been added. The failure occurred when executing the command
'sp_add_jobstep_internal'.
The error returned was 14234: 'The
specified '#server' is invalid (valid values are returned by
sp_helpserver).'. Use the action and error to determine the cause of
the failure and resubmit the request.'. Use the action and error to
determine the cause of the failure and resubmit the request.
The name of the server has not changed, I tried the sp_dropserver / sp_addserver solution and receive the following error:
Msg 15015, Level 16, State 1, Procedure sp_dropserver, Line 42
The server 'ServerName' does not exist. Use sp_helpserver to show
available servers.
Msg 15028, Level 16, State 1, Procedure sp_addserver, Line 74
The server 'ServerName' already exists.
As I've stated, I'm trying to set up CDC and not replication. The version of SQL Server is: 11.0.5058.0 (SQL Server 2012 SP2)
I've looked at Error while enabling CDC on table level and tried that solution.
I've also tried:
exec sys.sp_cdc_add_job #job_type = N'capture'
I receive the following error:
Msg 22836, Level 16, State 1, Procedure sp_cdc_add_job_internal, Line 282
Could not update the metadata for database [DatabaseName] to indicate
that a Change Data Capture job has been added. The failure occurred
when executing the command 'sp_add_jobstep_internal'.
The error returned was 14234: 'The specified '#server' is invalid (valid values are returned by sp_helpserver).'. Use the action and error to
determine the cause of the failure and resubmit the request.
Any help would be greatly appreciated.
As listed here, check the names match
SELECT srvname AS OldName FROM master.dbo.sysservers
SELECT SERVERPROPERTY('ServerName') AS NewName
If not, fix with:
sp_dropserver '<oldname>';
GO
sp_addserver '<newname>', local;
GO
The error is caused due to mismatch in value between SERVERPROPERTY(‘ServerName’)) and master.dbo.sysservers
Check these SQLs:
SELECT * FROM master.dbo.sysservers
SELECT SERVERPROPERTY('ServerName')
If your SERVERPROPERTY('ServerName') is not any of the sysservers, then the fix is to change your computer name to match one of those.
Adding the server fixes the issue:
DECLARE #ServerName NVARCHAR(128) = CONVERT(sysname, SERVERPROPERTY('servername'));
EXEC sp_addserver #ServerName, 'local';
GO
I had a similar situation, where I have restored a bak file which I got from another windows machine,which retained windows user account with the old PC name. I had delete the backup, create an empty data base and restore into that. This solved my issue
I'm trying to copy a view from one database to another. I'm exporting the view using 'Quick DDL > save to worksheet' to generate the script. At the top of the script i get the message:
"-- Unable to render VIEW DDL for object <view name> with DBMS_METADATA attempting internal generator."
Both the databases are identical, the view I'm trying to copy existed in both databases but was dropped in error in one of them.
When I try to run the script on my second database i get the error
Error report:
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-00001: unique constraint (SYS.I_COL1) violated
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.
Has anyone any idea what I might be doing wrong?
The message
-- Unable to render VIEW DDL for object with DBMS_METADATA attempting internal
gives the SQL Developer.
This is due to the fact that he can not use dbms_metadata.get_ddl.
If everything is fine with the privileges, most likely due to the type of error (on execute dbms_metadata.get_ddl):
ORA-06502: PL/SQL: numeric or value error
LPX-00210: expected '<' instead of 'n'
ORA-06512: at "SYS.UTL_XML", line 0
ORA-06512: at "SYS.DBMS_METADATA_INT", line 3296
ORA-06512: at "SYS.DBMS_METADATA_INT", line 4148
ORA-06512: at "SYS.DBMS_METADATA", line 458
ORA-06512: at "SYS.DBMS_METADATA", line 615
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1
Try to reload the XML API:
1. enable restricted database session
2. run:
(from $ORACLE_HOME/rdbms/admin):
catnomet.sql
rmxml.sql
to remove the xml subsystem and after that: catxml
utlcxml.sql
prvtcxml.plb
catmet.sql
to reload it.
In my case, the problem was because in the view there were two columns with the same name or alias, and since the COL $ table has a unique index with the object number, and the name of the column, two columns are not allowed with the same name
I'm trying to rename a table using the following syntax
sp_rename [oldname],[newname]
but any time I run this, I get the following [using Aqua Datastudio]:
Command was executed successfully
Warnings: --->
W (1): The SQL Server is terminating this process.
<---
[Executed: 16/08/10 11:11:10 AM] [Execution: 359ms]
Then the connection is dropped (can't do anything else in the current query analyser (unique spid for each window))
Do I need to be using master when I run these commands, or am I doing something else wrong?
You shouldn't be getting the behaviour you're seeing.
It should either raise an error (e.g. If you don't have permission) or work successfully.
I suspect something is going wrong under the covers.
Have you checked the errorlog for the ASE server? Typically these sorts of problems (connections being forcibly closed) will be accompanied by an entry in the errorlog with a little bit more information.
The error log will be on the host that runs the ASE server, and will probably be in the same location that ASE is installed into. Something like
/opt/sybase/ASE-12_5/install/errorlog_MYSERVER
try to avoid using "sp_rename". Because some references in system tables remain like old name. Someday this may cause some faulties if you forget this change.
I suggest;
select * into table_backup from [tableRecent]
go
select * into [tableNew] from table_backup
go
drop table [tableRecent] -- in case of backup you may not drop that table
go
drop table table_backup -- in case of backup you may not drop that table
go
to achieve that; your database has an option "select into/bulkcopy/pllsort"
if your ata is huge, check your free space on that database.
and enjoy :)