What does "Rownum=1" Do in this function [message #1518] |
Wed, 08 May 2002 10:09 |
Alex
Messages: 190 Registered: August 1999
|
Senior Member |
|
|
Hi All,
Stupid question here. Below is code from a working function, I understand all the pl/sql syntax except
for what "rownum=1" does to help the select statement?
Can someone please explain??
FUNCTION is_validitem (iItemid in number)
return char is
character 'Y' for valid items
sField1 mtl_categories.segment1%type;
BEGIN
SELECT mtl_categories.segment1
INTO sField1
FROM mtl_category_sets, mtl_categories,
mtl_item_categories
WHERE mtl_item_categories.inventory_item_id =
iItemid
AND mtl_item_categories.organization_id =
ifrun.iParm1 /* XES Master*/
AND mtl_category_sets.category_set_name
= 'Inventory'
AND mtl_categories.structure_id =
mtl_category_sets.structure_id
AND mtl_item_categories.category_set_id =
mtl_category_sets.category_set_id
AND mtl_item_categories.category_id =
mtl_categories.category_id
AND rownum =1;
IF sField1 = 'Equipment' or sField1 = 'Supplies' or sField1 = 'Service' Then
RETURN ('Y');
Else
RETURN ('N');
End If;
EXCEPTION
WHEN NO_DATA_FOUND then
RETURN ('N');
END;
|
|
|
Re: What does "Rownum=1" Do in this function [message #1519 is a reply to message #1518] |
Wed, 08 May 2002 10:22 |
migel
Messages: 4 Registered: February 2002
|
Junior Member |
|
|
The structure is doing a "select into" and setting the
variable Sfield1.
Your select can only return one row, so the rownum=1
is limiting the returned rows to just one.
There may be multiple rows returned.
Be careful using this logic!
|
|
|