Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External functions

Status
Not open for further replies.

CIMTEET

Programmer
Jun 25, 2001
182
US
Is there a way to call external functions from another pl/sql script besides packages? Say I have a single plsql file that multiple scripts call to use its functions, or something of hte like. I KNOW that ideally packages would be the way BUT, does anybody know a work around?

Greg
 
Greg,

If you do not want to use an Oracle PACKAGE, and you wish to access a FUNCTION from multiple venues, you can use a user-define FUNCTION. Here is a contrived example:
Code:
SQL> CREATE or REPLACE FUNCTION tomorrow return date is
  2  begin
  3      return sysdate+1;
  4  end;
  5  /

Function created.

SQL> select tomorrow from dual;

TOMORROW
---------
12-JUL-07
Is this what you meant? (If I totally missed the point of your post, please re-state in simpler terms for dimwits like me.[smile])

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
I think thats it. So if program 'a' wants to call a function from program 'b' this is how you do it?
 
In Oracle, the closest thing we have to a program is a script. Scripts can contain:

* SQL statements
* anonymous blocks of PL/SQL code
* package definitions
* function definitions
* procedure definitions
* et cetera

So, in the Oracle World, if you have a function definition, then other scripts, procedures, packages and functions can call that function only if it appears in either a:

* package header and body, or
* user-defined function (as I have specified, above).

Let us know if this answers your question.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top