|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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';
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
|
#3
|
||||
|
||||
|
|
|
#4
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Can define HOSTNAME in package spec? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|