473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,398 developers and data experts.

The function return amount of data at a time (Oracle)

Hi all,

Normally, the stored function return one values per time.In oracle9i pipelined functions return the amount of data at a time,

the first step create a type object.
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE package My_Types is
  2.   type lookup_row is record ( idx number, text varchar2(20) );
  3.   type lookups_tab is table of lookup_row;
  4. end My_Types;
  5.  
the second step create a function
Expand|Select|Wrap|Line Numbers
  1. create or replace function Lookups_Fn
  2.  
  3. (p_id in employees.department_id%type)
  4. return emp_Types.lookups_tab
  5.   pipelined
  6. is
  7.   cursor emp_cur is
  8.   select employee_id,last_name
  9.   from employees
  10.   where department_id=p_id;
  11.   v_row emp_Types.lookup_row;
  12. begin
  13.   open emp_cur;
  14.   loop
  15.   fetch emp_cur
  16.   into
  17.   v_row.employee_id,v_row.last_name;
  18.   exit when emp_cur%notfound;
  19.   pipe row ( v_row );
  20.   end loop;
  21.   return;
  22. end Lookups_Fn;
  23.  
Please use it in the future
Jul 20 '07 #1
1 3411
rk2006
1
Hi I tried to use the above .but some how this functions fails to return the set of values when used directly..say Lookups_fn('6') .pls advice
Aug 2 '07 #2

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
0
by: Bryan Jackson | last post by:
Greetings, (I am an Oracle newbie -- been working with SQLServer for quite some time, however. I'm using Oracle9i and Oracle9i JDeveloper v9.0.3.1 (build 1107) for my programming environment)....
2
by: spawncamper | last post by:
Hi - I posted here a few weeks back and people were kind enough to help. In lieu of my PL/SQL class I take in a few weeks, I was hoping to get some more advice. Here's my scenario: I need a...
2
by: Konstantin Zakharenko | last post by:
Hello, Our QA team have running a lot of test scripts (for automated regression testing), they run them on the different databases (Oracle/MS SQL). Several of those tests are dependent on the...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
21
by: Hallvard B Furuseth | last post by:
Is the code below valid? Generally a value must be accessed through the same type it was stored as, but there is an exception for data stored through a character type. I'm not sure if that...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
3
by: Aaron | last post by:
I have been searching the boards trying to find an answer to this question and no luck. I am using a query similar to this: Select count(col1) from table1 I was having a hard time accessing...
10
by: colin | last post by:
Hi, I profile my code and find its spending a lot of time doing implicit conversions from similar structures. the conversions are mainly things like this class Point { implicit conversion...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.