Home » SQL & PL/SQL » SQL & PL/SQL » Can This Be Done
Can This Be Done [message #22897] Tue, 05 November 2002 12:31 Go to next message
Rizwan Qazi
Messages: 135
Registered: August 2002
Senior Member
Can I use a string returned by a function xyz in a SQL query

desc abc;
contract_no varchar2(30)
cust_name varchar2(50)

e.g xyz(x) returns contract_no

Can I use the return value within a sql query like

select xyz(x), cust_name from abc

If so how can this be done. If not, is there a way around this?

Rizwan
Re: Can This Be Done [message #22898 is a reply to message #22897] Tue, 05 November 2002 12:45 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Sure, you can use any function (built-in or custom) in the column list of a statement or the WHERE clause.
Re: Can This Be Done [message #22919 is a reply to message #22898] Wed, 06 November 2002 07:38 Go to previous messageGo to next message
Rizwan Qazi
Messages: 135
Registered: August 2002
Senior Member
FYI,

I discovered a way to get this done at SQLPLUS level. This is what needs to be done. Suppose the string returned, say contract_no, is in table abc we need to do the following at SQLPLUS

col x new_value y noprint

select my_function(123) x from dual;

select &y from abc;

This should return the intended output. I tried it out sucessfully

Rizwan
Re: Can This Be Done [message #22927 is a reply to message #22898] Wed, 06 November 2002 10:31 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You really need to specify your particular environment on a question like this. If someone had supplied this SQL*Plus example, 99.9% of people would have replied that the answer doesn't apply because they are working in PL/SQL or a development tool like Delphi, PB, VB, etc.
Previous Topic: How to get complete schema
Next Topic: util_file case sensitivity
Goto Forum:
  


Current Time: Wed May 08 02:59:27 CDT 2024