Home » SQL & PL/SQL » SQL & PL/SQL » Can I use a PL/SQL function in a SQL SELECT statement
Can I use a PL/SQL function in a SQL SELECT statement [message #2684] Tue, 06 August 2002 09:03 Go to next message
Anne E
Messages: 2
Registered: August 2002
Junior Member
I'm new to Oracle and PL/SQL and have the following question:

If I have a web application in either Java using JDBC or Cold Fusion and I code a SQL SELECT statement, can I use a PL/SQL function that I have stored on that server and granted access to. If for instance I create a hash function so that social security numbers won't be stored in clear text, can I code
SELECT * FROM EMPLOYEES WHERE SSN=hash(ssn);

An online tutorial said that I can't issue that sort of SELECT statement from the SQLPlus prompt -- is that kind of select statement invalid from any place SQL might be used?
Re: Can I use a PL/SQL function in a SQL SELECT statement [message #2687 is a reply to message #2684] Tue, 06 August 2002 09:41 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Yes, you can use a PL/SQL function (either built-in or custom) in a SQL statement. It can appear in the column list or in the WHERE clause as in your example.
Re: Can I use a PL/SQL function in a SQL SELECT statement [message #2708 is a reply to message #2684] Wed, 07 August 2002 10:43 Go to previous messageGo to next message
Anne E
Messages: 2
Registered: August 2002
Junior Member
Do you happen to know, was the tutorial I saw that said you can't use a PL/SQL function in a SQL statement issued from the SQLPlus prompt, accurate? If it is accurate, I was wondering why a PL/SQL function being used in a SQL statement would be valid in some environments, but not from the SQLPlus prompt.
Re: Can I use a PL/SQL function in a SQL SELECT statement [message #2711 is a reply to message #2684] Wed, 07 August 2002 11:29 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
No, it was not accurate. As I mentioned, any PL/SQL function (native or custom) can be included in a SQL statement - in any environment.

sql>select upper('Anne') from dual;
 
UPPE
----
ANNE
Previous Topic: how to execute a string in PL/SQL
Next Topic: DECODE explanation
Goto Forum:
  


Current Time: Wed Apr 24 16:59:04 CDT 2024