Home » SQL & PL/SQL » SQL & PL/SQL » Invalid package and synonym (oracle 11.2.g OS windows, client oracle sql developer)
Invalid package and synonym [message #607301] Tue, 04 February 2014 15:28 Go to next message
anncao
Messages: 87
Registered: August 2013
Member
I have a package that only has one stored procedure, I compiled it without errors. And then second day when I login in again, I see there is a red X next to the package body, I know it means invalid, but what is invalid, I recompile it, it compiles fine and the red X disappear, I know it will show up some later time, but don't know why.
I am using oracle sql developer.

Then I checked the underlying table the stored procedure is using, that I created a couple of days ago. The table is fine, but when I query select * from dba_objects where object_name ='mytablename', I login as schema PS
I found something like below:
owner Object_name Object_type Status
PS mytablename TABLE VALID
MGMT mytablename SYNONYM INVALID

I wonder why the SYNONYM is Invalid, how can I fix it? I assume it is because of this my package showed red X.

Thanks

Re: Invalid package and synonym [message #607302 is a reply to message #607301] Tue, 04 February 2014 15:39 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
If you really created your table with lowercase (never a good idea) then does the MGMT user have select priviledges at a minimum on the table in the PS schema?
Re: Invalid package and synonym [message #607303 is a reply to message #607302] Tue, 04 February 2014 15:48 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
Thanks, I have my tables all uppercase. Sorry about the typing.
So after I create a table, Does the MGMT user automatically have a SYNONYM for MYTABLE, at least I see so by doing the query?
What should be the correct step I will do to let the synonyms to become valid, since I login using PS account, and I created the table, I just tried to grant select to public, it runs fine, but still by doing above query, the MGMT user still have SYNONYM invalid.
Re: Invalid package and synonym [message #607304 is a reply to message #607303] Tue, 04 February 2014 15:54 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
since public has select on the MYTABLE in MGMT simply type

CREATE SYNONYM MYTABLE FOR PS.MYTABLE;
Re: Invalid package and synonym [message #607305 is a reply to message #607304] Tue, 04 February 2014 15:55 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
So I have to login as MGMT to do this?
Re: Invalid package and synonym [message #607306 is a reply to message #607305] Tue, 04 February 2014 15:57 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
And why the synonym in MGMT become invalid?
Re: Invalid package and synonym [message #607307 is a reply to message #607305] Tue, 04 February 2014 15:57 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
YES OR IN AN ACCOUNT WITH THE CORRECT PRIVILEGE TYPE

CREATE PUBLIC SYNONYM MYTABLE FOR PS.MYTABLE;
Re: Invalid package and synonym [message #607308 is a reply to message #607306] Tue, 04 February 2014 15:59 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
I suspect it was made without the schema like create synonym mytable for mytable;
Re: Invalid package and synonym [message #607309 is a reply to message #607308] Tue, 04 February 2014 16:01 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
Thanks, I didn't actually create this synonym manually, I just created the table, I might dropped the table and recreated, but never created a synonym, I suppose it is automatically created , is it possible? thanks
Re: Invalid package and synonym [message #607310 is a reply to message #607309] Tue, 04 February 2014 16:03 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
not by sqlplus but maybe by a tool your using.
Re: Invalid package and synonym [message #607312 is a reply to message #607310] Tue, 04 February 2014 16:37 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
Thanks, I login as the other user, and deleted the synonym, and recreated the table, the synonym is not showing up this time. and I recomplie the package body.
I will see tomorrow when I login, if there is any red X next to the package body, and see if the synonyms are created by some mysterious process.

Thanks
Re: Invalid package and synonym [message #607313 is a reply to message #607312] Tue, 04 February 2014 17:50 Go to previous messageGo to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Just not synonym, get the list of all dependent objects used by the current package, and check their compilation date should be less than your package specification compilation date.

Manu
Re: Invalid package and synonym [message #607314 is a reply to message #607313] Tue, 04 February 2014 18:05 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
Thanks, is there an easy way to find out the dependent objects for the package, or I have to check manually in the package what objects it used?
Also, you are right, I found out there is another table used by the package, I guess there is no compilation date for a table, but after I select * from dba_objects where object_name='MYTABLE', I found out it the created timestamp is yesterday afternoon, it was after I compiled my package,
I guess that was it, the reason why my package has a red X.
Thanks much!
Re: Invalid package and synonym [message #607315 is a reply to message #607314] Tue, 04 February 2014 18:28 Go to previous messageGo to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

If you are are not coding using SQL*Plus, then this functionality is available in most of the tools

Try to use dbms_utility.get_dependency

Manu
Re: Invalid package and synonym [message #607316 is a reply to message #607315] Tue, 04 February 2014 18:41 Go to previous messageGo to next message
anncao
Messages: 87
Registered: August 2013
Member
Thanks, I am using oralce sql developer, when I run select * from dbms_utility.get_dependency; it says table or view does not exist.

Also a question about last_DDL_Time, the table I mentioned above that the package is depend on, I know it is populated every night through a job,
but when I check in our production environment, I see the job was created at weekends, but the Last_DDL_time is today's date. But we just populate the table, maybe Truncate table is considered as a ddl too, but how can I know the last compile time of a table? thanks

[Updated on: Tue, 04 February 2014 18:41]

Report message to a moderator

Re: Invalid package and synonym [message #607317 is a reply to message #607316] Tue, 04 February 2014 18:43 Go to previous messageGo to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Do some search, it's not a table, it's a procedure, and need few parameters.

Moreover, SQL Developer contains the dependency functionality (in case you ready to explore)

Manu
Re: Invalid package and synonym [message #607318 is a reply to message #607317] Tue, 04 February 2014 18:50 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.oracle.com/pls/db121/search?remark=quick_search&word=dbms_utility
Previous Topic: Oracle Parallel Hint Query
Next Topic: Query not using Index
Goto Forum:
  


Current Time: Thu Apr 18 18:52:25 CDT 2024