Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re:Function

Re:Function

From: <dgoulet_at_vicr.com>
Date: Mon, 04 Feb 2002 09:59:23 -0800
Message-ID: <F001.0040517A.20020204095136@fatcity.com>

Hamid,

    Your problem is in the first select statement's where clause. By enclosing :table_name in single quotes it becomes the table name vs. the passed in parameter. In a function this should be:

"WHERE TABLE_NAME = table_name AND COLUMN_ID = 2;"

Now your only problem is that Oracle and PL/SQL will probably mix up TABLE_NAME and table_name. Could get a little messy. BTDT. Recommended solution is to rename the local variable to user_table_name or something like that.

Dick Goulet

____________________Reply Separator____________________
Author: Hamid Alavi <hamid.alavi_at_quovadx.com>
Date:       2/4/2002 9:07 AM

Hi list,

I have this function it's compile ok but doesn't return any value:

CREATE OR REPLACE function f_get_desc2

     (table_name in varchar2,
      code_column_name in varchar2,
      code_id in varchar2)
      return varchar2
   is
      return_desc varchar2 (100) ;
          DESC_VAL VARCHAR2(100);

   begin
   SELECT COLUMN_NAME INTO DESC_VAL FROM USER_TAB_COLUMNS ?????    WHERE TABLE_NAME =':table_name' AND COLUMN_ID = 2 ; ????
-- here I want to get the description column name from
user)tab_columns.....then get the value based on the ID

      execute immediate 'select ' || DESC_VAL ||
         ' from ' || table_name || ' where ' || code_column_name ||
         ' = :id' into return_desc using code_id ;
      return return_desc ;

   end ;
/

I pass column_name ,code & value of the code to function then get the name of description Column from table_name and finally get the description based on table_name,descripton column & value, BUT doesn't return any value I am not sure but the ?mark lines doesn't return any value.

Thanks for your help.

Hamid Alavi
Office 818 737-0526
Cell 818 402-1987

The information contained in this message and any attachments is intended only for the use of the individual or entity to which it is addressed, and may contain information that is PRIVILEGED, CONFIDENTIAL and exempt from disclosure under applicable law. If you have received this message in error, you are prohibited from copying, distributing, or using the information. Please contact the sender immediately by return e-mail and delete the original message from your system.
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Hamid Alavi
  INET: hamid.alavi_at_quovadx.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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: dgoulet_at_vicr.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 Mon Feb 04 2002 - 11:59:23 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US