![]() |
PL/SQL - get DB name
Hey,
I want to get the database name in a PL/SQL trigger. At the SQLPlus prompt, these are some examples I've tried: :
fsdevl75@fsdev> select sys_context('userenv', 'db_name') from dual;I want what _CONNECT_IDENTIFIER returns (fsdev in this case), but I can't figure out any way to do this in a trigger. Can anybody help with this? |
Quote:
I would probably see if i could do a SELECT INTO into a var, then return the var (or do what ever you want with the results). here's a example on SELECT INTO: http://www.postgresql.org/docs/8.1/i...QL-SELECT-INTO |
Quote:
:
select '&_CONNECT_IDENTIFIER' into myVar from dual;On a side note, I can also do this: :
fsdevl75@fsdev> select * from PS.PSDBOWNER where ownerid = user; |
give this a try:
:
SELECT GLOBAL_NAME FROM GLOBAL_NAME;i have seen that on a few pages i have been reading about your subject. Here's the link to the page: http://www.bijoos.com/oracle/ora_qa.htm I have never used SQLPlus, so i am kinda in the dark on what works on your system. |
:
SET SERVEROUT ON SIZE 10000This is the basic code to get the db name - it displays it. For a trigger you would not want a display. |
Quote:
Yes, that would make life much easier, but unfortunately, I don't have access to v$database. From what I've heard when similar problems to this cropped up in the past, they're not going to grant access to it either. Beuacracy is fun! |
Well, thank you all for your help - I'm just going to do a workaround. I made a new table that mapped the server names to the database names, then wrote a function that selects global_name from global_name (which gives me the server name), strips the .world from the end of it, and then uses that to find the database name.
|
Quote:
|
| All times are GMT -5. The time now is 7:51 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC