Home » SQL & PL/SQL » SQL & PL/SQL » DBMS scheduler Doesnt support the synonym table (DBLINK Used) (Oracle 11g 11.2.0.2.0, AIX)
DBMS scheduler Doesnt support the synonym table (DBLINK Used) [message #507175] |
Thu, 12 May 2011 21:23  |
 |
cyberjai
Messages: 12 Registered: March 2011 Location: Singapore
|
Junior Member |
|
|
Hi All,
we are facing an issue with the dbms scheduler jobs, which is not processing the synonym which is created via dblink from anthoer schema.
Let me explain the situation.
Table in Schema :APP_COMMON DB: APPL
-------------------------------------
CREATE TABLE TEST_LOG (A VARCHAR2(10));
INSERT TEST_LOG VALUES ('TESTED');
GRANT SELECT ON TEST_LOG to APP_GEN ;
Table in Schema :APP_GEN DB: APPL
-------------------------------------
CREATE SYNONYM TEST_LOG FOR APP_COMMON.TEST_LOG;
SELECT * from TEST_LOG;
-- it returns the value
Table in Schema :APP_GEN DB: REPORT
-------------------------------------
This is the different DB (we have 2 DB's, one for report db and one for application DB). here we create the DB link (connected DB menthod) . Since we have the password sync between the databases, we create the DBLINK without user id and password.
CREATE DATABASE LINK "APPL_LINK"
USING 'APPL' ;
CREATE SYNONYM TEST_LOG FOR TEST_LOG@APPL_LINK;
SELECT * from TEST_LOG;
--it returns the value.
Now in the same DB, we have a scheduler which will run for every min.
Now Scheduler is not selecting this table. Rather not processing the synonym(TEST_LOG). Not able to capture the exception also.
Request your help on this.
Thanks,
Jai
[mod-edit: code tags fixed by bb by replacing < and > with [ and ]]
[Updated on: Fri, 13 May 2011 01:02] by Moderator Report message to a moderator
|
|
|
|
|
Re: DBMS scheduler Doesnt support the synonym table (DBLINK Used) [message #507179 is a reply to message #507177] |
Thu, 12 May 2011 22:21   |
 |
cyberjai
Messages: 12 Registered: March 2011 Location: Singapore
|
Junior Member |
|
|
Sorry for that.
DBMS scheduler -- > Job action :
BEGIN
PACK_DT.PACK_Process('344');
END;
--PACK_DT.PACK_Process
---------------------
CREATE OR REPLACE PACKAGE BODY PACK_DT IS
PROCEDURE PACK_Process (
cde IN VARCHAR2
) IS
I_ A VARCHAR2(10);
BEGIN
DBMS_OUTPUT.put_line ('First process');
SELECT A INTO I_A from TEST_LOG;
DBMS_OUTPUT.put_line (I_A);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line ('Error process');
END;
END;
Here dbms_scheduler picks up the package, but dbms output shows only "first process".
It doesnt print the value for "I_A" or
"error process".
Thanks,
Jai
[mod-edit: code tags fixed by bb by replacing < with [ and > with ]]
[Updated on: Thu, 12 May 2011 22:44] by Moderator Report message to a moderator
|
|
|
Re: DBMS scheduler Doesnt support the synonym table (DBLINK Used) [message #507186 is a reply to message #507179] |
Fri, 13 May 2011 00:08   |
 |
Barbara Boehmer
Messages: 9105 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Please make sure you use [ and ] around your code tags instead of < and >. I fixed them in your posts.
In your package, you have a line that says:
I_ A VARCHAR2(10);
There should not be a space between _ and A.
Once you have fixed the error above, then executing the procedure directly should produce the output that you expect. However, when you schedule it, I believe it is run in such a manner that you will never see anything from dbms_output, so it is better to use something else for testing. In the example below, I have inserted into the test_log table to determine that the scheduled job has run.
SYS@orcl_11gR2> create user app_common_db identified by app_common_db
2 /
User created.
SYS@orcl_11gR2> create user app_gen_db identified by app_gen_db
2 /
User created.
SYS@orcl_11gR2> grant connect, resource to app_common_db, app_gen_db
2 /
Grant succeeded.
SYS@orcl_11gR2> grant create database link to app_gen_db
2 /
Grant succeeded.
SYS@orcl_11gR2> grant create synonym to app_gen_db
2 /
Grant succeeded.
SYS@orcl_11gR2> grant create job to app_gen_db
2 /
Grant succeeded.
SYS@orcl_11gR2> grant execute on dbms_lock to app_gen_db
2 /
Grant succeeded.
SYS@orcl_11gR2> connect app_common_db/app_common_db
Connected.
APP_COMMON_DB@orcl_11gR2> CREATE TABLE TEST_LOG (A VARCHAR2(10))
2 /
Table created.
APP_COMMON_DB@orcl_11gR2> INSERT INTO TEST_LOG VALUES ('TESTED')
2 /
1 row created.
APP_COMMON_DB@orcl_11gR2> GRANT SELECT ON TEST_LOG to APP_GEN_DB
2 /
Grant succeeded.
APP_COMMON_DB@orcl_11gR2> grant insert on test_log to app_gen_db
2 /
Grant succeeded.
APP_COMMON_DB@orcl_11gR2> connect app_gen_db/app_gen_db
Connected.
APP_GEN_DB@orcl_11gR2> CREATE DATABASE LINK orcl@loopback
2 connect to app_common_db
3 identified by app_common_db
4 USING 'orcl'
5 /
Database link created.
APP_GEN_DB@orcl_11gR2> CREATE SYNONYM TEST_LOG FOR TEST_LOG@orcl@loopback
2 /
Synonym created.
APP_GEN_DB@orcl_11gR2> SELECT * from TEST_LOG
2 /
A
----------
TESTED
1 row selected.
APP_GEN_DB@orcl_11gR2> CREATE OR REPLACE PACKAGE PACK_DT
2 IS
3 PROCEDURE PACK_Process
4 (cde IN VARCHAR2);
5 END PACK_DT;
6 /
Package created.
APP_GEN_DB@orcl_11gR2> CREATE OR REPLACE PACKAGE BODY PACK_DT
2 IS
3 PROCEDURE PACK_Process
4 (cde IN VARCHAR2)
5 IS
6 I_A VARCHAR2(10);
7 BEGIN
8 DBMS_OUTPUT.put_line ('First process');
9 SELECT A INTO I_A from TEST_LOG where rownum = 1;
10 DBMS_OUTPUT.put_line (I_A);
11 insert into test_log values (cde);
12 commit;
13 EXCEPTION
14 WHEN OTHERS THEN
15 DBMS_OUTPUT.put_line ('Error process');
16 END PACK_Process;
17 END PACK_DT;
18 /
Package body created.
APP_GEN_DB@orcl_11gR2> exec pack_dt.pack_process ('testing')
First process
TESTED
PL/SQL procedure successfully completed.
APP_GEN_DB@orcl_11gR2> begin
2 dbms_scheduler.create_job
3 (job_name => 'test_job',
4 job_type => 'PLSQL_BLOCK',
5 job_action => 'BEGIN PACK_DT.PACK_Process (''344''); END;',
6 enabled => TRUE);
7 end;
8 /
PL/SQL procedure successfully completed.
APP_GEN_DB@orcl_11gR2> exec dbms_lock.sleep (10)
PL/SQL procedure successfully completed.
APP_GEN_DB@orcl_11gR2> exec null
PL/SQL procedure successfully completed.
APP_GEN_DB@orcl_11gR2> select * from test_log
2 /
A
----------
TESTED
testing
344
3 rows selected.
APP_GEN_DB@orcl_11gR2>
|
|
|
|
|
|
Re: DBMS scheduler Doesnt support the synonym table (DBLINK Used) [message #507255 is a reply to message #507210] |
Fri, 13 May 2011 06:58   |
 |
Barbara Boehmer
Messages: 9105 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
cyberjai wrote on Fri, 13 May 2011 01:15hi barbara,
Thanks for your vaulable time.
we also tried to insert the data instead of dbms output as suggested by you.
the difference what i able to see between your code and mine is we are working between 2 different DB's and 2 different Schemas. you have created the DBlink between the schemas with userid and password.
we created the db link between the DB's without userid and password (Connected DBLINK method).
when we create the DBLINK with user id and password,we are able to achive what we need. But we should not create the DBLINK with user id and password.
if we select the table in the schema, we are able to see the records. But in the dbms_schduler it throws the error " ORA-01017: invalid username/password; logon denied "
Sorry, but I don't see a way to do it without the username and password as part of the database link, but others may have some ideas. I only have one database to test on, which is why I use the loopback database link which simulates two databases. I believe that dbms_scheduler runs the scheduled jobs as the sys user and, as you can see from the error message, it needs the username and password.
|
|
|
|
Goto Forum:
Current Time: Sat May 17 03:17:44 CDT 2025
|