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

Home -> Community -> Usenet -> c.d.o.server -> Re: Silly questions , pl. help me !

Re: Silly questions , pl. help me !

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1998/03/26
Message-ID: <35205b1a.68701557@192.86.155.100>#1/1

A copy of this was sent to sambavan_at_mail.utexas.edu (if that email address didn't require changing) On Wed, 25 Mar 1998 21:41:31 -0600, you wrote:

>Hi
>I'm new to this field, and have few of silly questions
>
>Question 1
>
>If we were to create an index on a table using a perticular column and later
>if we were to query the table using that
>index column, will I be able to retrive the data in a sorted order?
>

whether the data is indexed or not will have no bearing on whether or not you can retrieve the data in sorted order. In order to retrieve data sorted, you must specify the ORDER BY clause. It is possible that the existence of an index will allow the ORDER BY to be processed faster, it is not needed to get the sorted data.

For example: select * from EMP order by ENAME; will always sort the data in the emp table by ename regardless of the existence of indexes on ename.

>Question 2.
>
> Is it possible to pass the PL/SQL table as an argument? If so, what will be
>the argument type?
>

Yes it is. The argument type is the pl/sql table type. For example:

create or replace package types
as

    type array is table of number index by binary_integer; end;
/

create or replace function sumOfTable( p_numbers in types.array ) return number is

    l_result number default 0;
begin

    for i in 1 .. 100000 loop
    begin

        l_result := l_result + p_numbers(i);     exception

        when no_data_found then exit;
    end;
    end loop;
    return l_result;
end;
/

And then to use it:

declare

    l_my_data types.array;
begin

    for i in 1 .. 10 loop

        l_my_data(i) := i;
    end loop;
    dbms_output.put_line( sumOfTable( l_my_data ) ); end;
/

55
PL/SQL procedure successfully completed.

>Please help me
>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Mar 26 1998 - 00:00:00 CST

Original text of this message

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