473,394 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

the name of a table inside a function

Hello :)
I have this query :
Expand|Select|Wrap|Line Numbers
  1. select MyFunction(MyColumnName)
  2. from MyTableName
How can I get the name of the table MyTableName inside the function MyFunction ?
Also, is this correct under Oracle 7 ?
Expand|Select|Wrap|Line Numbers
  1. create or replace function MyFunction(N out number)return number
  2. is
  3.  buffer varchar2(512);
  4. Begin
  5.  buffer := 'select count(*) from Client_Table';
  6.  execute immediate buffer into N; --Especially this
  7.  return N;
  8. End;
  9. /
  10.  
Thank you for answering :)
May 2 '07 #1
2 1086
Dave44
153 100+
Hello :)
I have this query :
Expand|Select|Wrap|Line Numbers
  1. select MyFunction(MyColumnName)
  2. from MyTableName
How can I get the name of the table MyTableName inside the function MyFunction ?
Also, is this correct under Oracle 7 ?
Expand|Select|Wrap|Line Numbers
  1. create or replace function MyFunction(N out number)return number
  2. is
  3.  buffer varchar2(512);
  4. Begin
  5.  buffer := 'select count(*) from Client_Table';
  6.  execute immediate buffer into N; --Especially this
  7.  return N;
  8. End;
  9. /
  10.  
Expand|Select|Wrap|Line Numbers
  1. If you know what MyTableName is why not just code it into the function.  or do you not know it until run time.  If that is the case then you need some dynamic sql.
  2.  
  3. for the second part of your question in 10G it is:
  4.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • [152]dave@ORADB> DECLARE
  •   2       var      VARCHAR2(2000) := 'select count(*) from dual';
  •   3       var2     VARCHAR2(4000);
  •   4  BEGIN
  •   5       EXECUTE IMMEDIATE var
  •   6       INTO              var2;
  •   7  
  •   8       DBMS_OUTPUT.put_line(var2);
  •   9  END;
  •  10  /
  • 1
  •  
  • PL/SQL procedure successfully completed.
  •  
  • Elapsed: 00:00:00.00
  • [152]dave@ORADB> 
  •  
  •  
  •     
  •  
  •  
  • May 3 '07 #2
    thank you for answering,
    what i want is a pointer like "this" in C++.
    May 3 '07 #3

    Sign in to post your reply or Sign up for a free account.

    Similar topics

    1
    by: Marek Prerovsky | last post by:
    Hello, I implemented some Python functions in my C/C++ code. I need to know the Python source file name and line number of just executed Python command which calls my function. How can I get...
    17
    by: warteschlange | last post by:
    is there a way to find out the object/function name from inside object/function. function coffee(){ alert(this.someHowGetMyNameFuncOrVar); => should give me 'coffee' } var milk = new...
    6
    by: dharmadam | last post by:
    Is it possible to pass a column name or the order of the column name in the DB2 table table function. For example, I want to update the address of a person by passing one of the address column name...
    3
    by: divya | last post by:
    Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
    5
    by: Eliseu Rodrigues | last post by:
    Hi I would like to have a static method on a base class that executes some action (for example retrieves the row count) on a table whose name is the same of the inherited class name. For...
    2
    by: mrjoka | last post by:
    hi experts, i'm developing a page in ASP but i'm doing also some javascript insode the page. i'm creating a frame and i want to loop this frame with a duplicateloop function so the form will be...
    6
    by: Maguila007 | last post by:
    Hi Is there any way to obtain the name of the function, inside the function which was called. Ex: function something() { alert( "The name of the function you invoke is " ......should
    5
    by: Rahul B | last post by:
    Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT...
    3
    by: heyi | last post by:
    Hi Guys I need some expert advice on Ajax. I have some difficulties updating a <div> tag inside a table with Ajax. My html looks like this: ------------------------
    0
    by: Charles Arthur | last post by:
    How do i turn on java script on a villaon, callus and itel keypad mobile phone
    0
    by: ryjfgjl | last post by:
    If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
    0
    by: emmanuelkatto | last post by:
    Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
    1
    by: nemocccc | last post by:
    hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
    1
    by: Sonnysonu | last post by:
    This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
    0
    marktang
    by: marktang | last post by:
    ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
    0
    by: Hystou | last post by:
    Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
    0
    jinu1996
    by: jinu1996 | last post by:
    In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
    0
    by: Hystou | last post by:
    Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.