Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL Function question
Sample from SQL:
SELECT DECODE(part_description,'Screw',Cost5,'Tack',Cost2) FROM parts_table
You can embed this in a function that accepts the 5 Cost plus the Item column and let it return the value.
-----Original Message-----
From: William Rogge [mailto:William_Rogge_at_voltek.com]
Sent: Thursday, January 04, 2001 1:11 PM
To: Multiple recipients of list ORACLE-L
Subject: SQL Function question
We have a table (designed after a spreadsheet) of financial data.
Through functions we can locate the correct row in the table very efficiently.
Now what they want to do is select any field from the table for the returned row.
My first impression was to pass the field_name as a function argument, but have been unsuccessful in the execution.
Anybody got some sample code doing this type of scenario?
Example
Item Cost1 Cost2 Cost3 Cost4 Cost5 Total Screw .05 .01 .02 .04 0 .12 Tack .01 .03 .01 0 .06 .11
Return Cost2 for Tack. Then return Cost5 for Screw.
We currently have a function to return Total (hard coded), but if I can
make the column totally flexible we wouldn't need the hard coded function.
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: William Rogge
INET: William_Rogge_at_voltek.com
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Jan 04 2001 - 15:25:41 CST
![]() |
![]() |