Use a package function inside a select of the same package

Hi.
How can i use a function defined inside a package, with a select used inside that same package ?
Example
... package example
CREATE OR REPLACE PACKAGE BODY pkg_example
AS
     FUNCTION sum_two_values(p_val1 NUMBER,p_val2 NUMBER) RETURN NUMBER
     IS
     BEGIN
     RETURN p_val1 + p_val2;
     END sum_two_values;
     FUNCTION use_another_function_example RETURN VARCHAR2
     IS
     v_value NUMBER;
     BEGIN
     SELECT sum_two_values(2,2) INTO v_value FROM dual;
     RETURN 'waaaazzzzupppppp'
     END use_another_function_example;
END pkg_example;
This will not work
-- SELECT sum_two_values(2,2) INTO v_value FROM dual;
How can i call a function inside a select statement, a function of the same package where the query is being called.
(i have Oracle 9.2x)
Cheers.

are you sure? you are not using package1, you are using pack1
SQL> CREATE OR REPLACE PACKAGE package1
  2  IS
  3     FUNCTION f1
  4        RETURN NUMBER;
  5 
  6     FUNCTION f2
  7        RETURN NUMBER;
  8  END;
  9  /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY package1
  2  IS
  3     a   NUMBER;
  4 
  5     FUNCTION f1
  6        RETURN NUMBER
  7     IS
  8     BEGIN
  9        RETURN 1;
10     END;
11 
12     FUNCTION f2
13        RETURN NUMBER
14     IS
15     BEGIN
16        SELECT package1.f1
17          INTO a
18          FROM DUAL;
19 
20        RETURN a;
21     END;
22  END;
23  /
Package body created.
Why not just this
SQL> ed
Wrote file afiedt.buf
  1  CREATE OR REPLACE PACKAGE BODY package1
  2  IS
  3     a   NUMBER;
  4     FUNCTION f1
  5        RETURN NUMBER
  6     IS
  7     BEGIN
  8        RETURN 1;
  9     END;
10     FUNCTION f2
11        RETURN NUMBER
12     IS
13     BEGIN
14        a:= f1;
15 RETURN a;
16     END;
17* END;
SQL> /
Package body created.formatted
Message was edited by:
devmiral

Similar Messages

  • Using an own function in a select how can i set that the function run once?

    Hi
    Using an own function in a select how can i set that the function run once, not in every row?
    Please help me
    Thanks
    Viktor

    Something like this ?
    SQL> select * from dept;
        DEPTNO DNAME                          LOC
            10 ACCOUNTING                     NEW YORK
            20 RESEARCH                       DALLAS
            30 SALES                          CHICAGO
            40 OPERATIONS                     BOSTON
    SQL> create or replace function ret_name (deptnum in number) return varchar2
      2  is
      3     name    varchar2(50);
      4  begin
      5     select dname into name
      6     from dept
      7     where deptno=deptnum;
      8     return name;
      9  exception
    10     when no_data_found then
    11             return('Not existent deptno');
    12* end;
    SQL> /
    Function created.
    SQL> select deptno, decode(rownum,1,ret_name(deptno),null) dname from dept;
        DEPTNO DNAME
            10 ACCOUNTING
            20
            30
            40
    SQL>

  • I cant use facetime. but my sister can. we share the same account for itunes.but when i go to face itme and click on create a new account a blank screen pops up. what do i do?when i go to make a new facetime account nothing comes up

    i cant use facetime. but my sister can. we share the same account for itunes.but when i go to facetime on my ipod touch and click on create a new account a blank screen pops up and the only thing it says is cancel and account.  what do i do?

    Please follow these directions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click the line below to select it:
    ~/Library/Containers/com.apple.mail
    Right-click or control-click the highlighted line and select
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
    Quit and relaunch Mail, and test. If the problem is resolved, you may have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard (command-C). In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.

  • Can I use more than one blue-tooth device at the same time on IPhone 4S? Like a wireless headsets and speed and cadence sensor for cycling computer, receive the data and listen music simultaneously

    Can I use more than one blue-tooth device at the same time on IPhone 4S? Like a wireless headsets and speed and cadence sensor for cycling computer, receive the data and listen music simultaneously

    As long as the profiles are different (ex. HID vs AD2P) you will not have any issues. But say if you try to use 2 keyboards at once, it won't work. Or 2 headsets at once. Your scenario seems fine.

  • HT1660 how can I use one single library for all users on the same laptop?

    how can I use one single library for all users on the same laptop?

    You are most of the way there. Each user having access to hard drive is the key. If users are limited in file privileges this is harder.
    Any files you add to your library and any files she adds to her library are available to the other. Just not automatically. Each user must add the files to their own library using the add file or add folder option from menu bar.
    What I have done is set library location to a location outside of My Documents\My Music. On my network storage I have a folder names s:\itunes. Both accounts iTunes are set to use this location for the library.

  • Can I use one GBIP-Interface with two programs at the same time?

    Hi, I have one PCI-GBIP-controller with multiple instruments installed. Now I want to use these instruments with two differents programs at the same time.
    E.g.: program 1 uses GPIB0::1 and GPIB0::3
    and program 2 uses GPIB0::4 and GPIB0::7
    Is this possible??
    When I have tried to do this, I always got timeout errors..
    Thanx in advance.
    Philipp

    Hi,
    You shouldn't have any problems accessing different devices from different programs using the same interface. I even used the two VIs to communicate with the same device. Although not the best approach, VISA didn't return any errors.
    DiegoF.

  • Can't i use xml schema and oledb data connection at the same time?

    Hello to all and thanks in advance.I use xml schema and oledb data connection at the same time and the problem is that when I try to export the xml, the outcome is not what i expect.Without the oledb connection everything is ok (just the schema) and the xml complies with the schema.
    Can't i have both schema and oledb and the exported xml be as i want it?

    You can use both at the same time, but not gor Internet access if that's what you're asking.
    Now there is a thing called Link Aggregation, which combines a number of interfaces for speed/redundancy, but it really only works locally, and then only with ALL special equipment in the route, and most likely OSX Server involved.
    Sorry.

  • I am writing a book and need to have the margins alternating left and right pages, so that there is sufficient margin for the binding. I have tried different inside and outside margins, the same inside and outside margins, facing pages, changing the maste

    I am writing a book and need to have the margins alternating left and right pages, so that there is sufficient margin for the binding. I have tried different inside and outside margins, the same inside and outside margins, facing pages, changing the master, and I cannot get the margins to alternate at print time. The larger margin is always on the left. Can anyone please help me on this, as I have spent hours and lots of ink.

    Set up as facing pages with a larger inside margin.

  • Can I use two apple TVs in different locations in the same house?

    Can I use two apple TVs in different locations in the same house?

    Welcome to the Apple Community.
    You can use 2 or more Apple Tv's in different locations in the same house. You can even use them at the same time and watch the same content on each or choose different content.

  • Why my iphone 4 connect to wifi, but when i open safari and search something it say i not connect.. but in the same house my sister using iphone4 too but she can online with the same router

    why my iphone 4 connect to wifi, but when i open safari and search something it say i not connect.. but in the same house my sister using iphone4 too but she can online with the same router. i go and check over the detail of the network i connected, over the ip address and subnet mask have the numbers, but over the DNS and router don't have any number...isit the problem???? i can online at any other place but just my home cant...y????

    Hey confuddled_chica!
    Try the steps in the article below to troubleshoot this issue:
    iOS: Troubleshooting Wi-Fi networks and connections
    http://support.apple.com/kb/ts1398
    Thanks for being a part of the Apple Support Communities!
    Regards,
    Braden

  • My iphone4s has echo at the other end, not using headset, updated 5.0.1, anyone has the same problem?

    My iphone4s has echo at the other end, not using headset, updated 5.0.1, anyone has the same problem?
    Do I need to bring it back to the apple store?

    In terms of the battery, if you are not already doing so you should go through at least one charge cycle per month i.e. charging to 100%, running it down so that powers off, and then charging back up to 100%, which should help keep the battery indicator accurate - it's recommended towards the bottom of this page http://www.apple.com/batteries/ipad.html
    I hadn't noticed any problems with the battery on my first gen iPad, but I've updated anyway.

  • Ok i need to unlock my ipod but i don't know my password i use itunes but i need to update at the same time this srcews up the itunes and i have to restart the computer i need to restore the ipod please help

    ok i need to unlock my ipod but i don't know my password i use itunes but i need to update at the same time this srcews up the itunes and i have to restart the computer i need to restore the ipod please help

    Connect the iOS device to your computer and restore via iTunes. Place the iPod in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    Maybe here:
    Trouble installing iTunes or QuickTime for Windows
    iOS: Device not recognized in iTunes for Windows
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP

  • Cannot use 2 optical drives (Apple Super drives) at the same time after downloading OS X 10.8.5.  Reported to Apple Care.  Anyone else have this problem?

    Cannot use 2 optical drives (Apple Super drives) at the same time on my iMac after downloading OS X 10.8.5.  Reported to Apple Care.  Anyone else have this problem?

    Cannot use 2 optical drives (Apple Super drives) at the same time on my iMac after downloading OS X 10.8.5.  Reported to Apple Care.  Anyone else have this problem?

  • Can i use my mac mini for some users at the same time?

    can i use my mac mini for some users at the same time? i mean with their own screen, mouse, and keyboard

    If you're asking whether more than one user can use the computer at the same time with multiple displays, the answer is no. Other users can log in over a network with Screen Sharing, but each one will need his own computer (not necessarily a Mac.)

  • Using facetime and ichat on different devices under the same apple account

    using facetime and ichat  on different devices under the same apple account

    Redeem it on any one; it'll be available to the others automatically.
    (119212)

Maybe you are looking for