Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 18th, 2005, 05:06 AM
Ach Ach is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 46 Ach User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 36 m 29 sec
Reputation Power: 4
Can define HOSTNAME in package spec?

Hi,
I faced with a problem in T-SQL to PL/SQL in a project.
scenario:
There is a function called hostname() in T-SQL which returns an obviouse thing! I implemented this with:

Code:
select userenv('Terminal') from dual;
but they have used many many times from this in T-SQL so I want to ask Isn't better to create a package and declare a type in that to point to this select statement?Is it possible?
-Any help is so appreciated.

Reply With Quote
  #2  
Old July 18th, 2005, 05:40 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,815 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 14 m 37 sec
Reputation Power: 278
I don't know how you are using this "select userenv('Terminal') from dual;" but it might affect performance and it should be avoided, look at this example:
...
select (sysdate) into :t_1 from dual;
select 'Today' into t_2 from dual;

can be rewritten to:
...
:t_1 := (sysdate);
:t_2 := 'Today';

Reply With Quote
  #3  
Old July 18th, 2005, 05:49 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,815 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 14 m 37 sec
Reputation Power: 278
You can also get the hostname with:

SELECT sys_context ('USERENV', 'HOST') FROM DUAL;

sys_context

Reply With Quote
  #4  
Old July 22nd, 2005, 07:08 PM
michaeljshannon michaeljshannon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 26 michaeljshannon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 38 m 15 sec
Reputation Power: 0
While the select statement from dual may not be optimal, the idea of creating a package that defines commonly used variables is definitely a good idea. I believe this is the intent of your question.

These package variables need only to be defined once and can be reused. A good example would be current_fiscal_year. Instead of the application executing the function to return the current fiscal year, it refers instead to the package variable.
While the time savings may be minimal, if the practice of recalculating relatively static variables is widespread, this degradation would be noticeable.

The use of package variables can be expanded to include cursor variables used by programmers. These are basically reuseable, pre-packaged select statements that can be referenced from any stored procedure or function.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Can define HOSTNAME in package spec?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway