Home » Other » Client Tools » Way to identify DB connection in SQL developer script? (SQL Developer 1.5.0.52, connecting to Oracle 10.2g)
Way to identify DB connection in SQL developer script? [message #389156] Fri, 27 February 2009 07:45 Go to next message
dpgrieves
Messages: 4
Registered: January 2007
Junior Member
I've written a simple script to clean out my test database so I can mess it up as much as I want and start out fresh every time.

Right now, the script is just a bunch of TRUNCATE TABLE commands. Here's my problem: I am deathly afraid that some day I'm going to pull the second-biggest bonehead move of my life and run the script on the production server by mistake.

At the moment, the only way I have to make sure I don't do this is manual--I triple check which connection I've chosen before I hit Ok on running the script.

Is there a way to put a failsafe in my script? Something that automatically checks the name of the server I'm connected to, and if it's not the test server, then ABORT ABORT ABORT.

Please help before I ruin my career!

Thanks,
Dan
Re: Way to identify DB connection in SQL developer script? [message #389158 is a reply to message #389156] Fri, 27 February 2009 07:53 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I don't know in SQL Developer but in SQL*Plus (which should be the tool to execute script), you can do something like:
whenever sqlerror exit;
select 1/decode(global_name,'mytestdb.mydomain',1,0) from global_name;
whenever sqlerror continue;
...

Regards
Michel

[Updated on: Fri, 27 February 2009 08:56]

Report message to a moderator

Re: Way to identify DB connection in SQL developer script? [message #389166 is a reply to message #389158] Fri, 27 February 2009 08:17 Go to previous message
dpgrieves
Messages: 4
Registered: January 2007
Junior Member
Thank you for the suggestion. It works in SQL Developer, too.

Dan
Previous Topic: SP2-0552 error
Next Topic: Oracle datatype to store ONLY DATE without time
Goto Forum:
  


Current Time: Thu Mar 28 04:00:05 CDT 2024