Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please help me in what do you mean by PL/SQL Record & PL/SQL Table !!

kishore_peddikishore_peddi Member Posts: 176

Hi,

Can you please help me what do you mean by PL/SQL Record and PL/SQL Table in ORACLE. Please give me simple exaples on each of them.

Advance ThanX for your time & patience.

Bye...
Cheers
Kishore

Comments

  • infidelinfidel Member Posts: 2,900
    :
    : Hi,
    :
    : Can you please help me what do you mean by PL/SQL Record and PL/SQL Table in ORACLE. Please give me simple exaples on each of them.
    :
    : Advance ThanX for your time & patience.
    :
    : Bye...
    : Cheers
    : Kishore

    A PL/SQL record is like a struct in C

    [code]
    TYPE RECORD_TYPE_0 IS RECORD (
    CUSTOMER_ID VARCHAR2(32),
    CUSTOMER_NAME CHAR(128),
    );
    [/code]

    If you define a record type then you can declare variables of that type:

    [code]
    r_record_variable record_type_0;
    [/code]

    You can also declare record variables to match the row of a table or view:

    [code]
    r_customer customers%rowtype;
    [/code]

    PL/SQL tables are sort of like arrays:

    [code]
    type t_month_array is table of date indexed by binary_integer;
    [/code]

    Then you can declare variables and use them like arrays:

    [code]
    declare
    a_months t_month_array;
    begin
    a_months(1) = sysdate;
    a_months(10) = sysdate + 1;
    end;
    [/code]

    You don't have to use indexes in order or contiguously and you don't have to say how big the pl/sql table is ahead of time. Just beware that if you try to get a value from an index that was never set to anything Oracle will throw an exception.



    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • kishore_peddikishore_peddi Member Posts: 176
    Hi Infidel,

    Good day. ThanX for your reply once again. Please let me know the below statement meaning...

    type t_month_array is table of date indexed by binary_integer;

    What do you mean by "indexed by binary_integer" in the declaration.

    Advance ThanX for your time & Patience.

    Bye...
    Cheers
    Kishore
  • infidelinfidel Member Posts: 2,900
    : Hi Infidel,
    :
    : Good day. ThanX for your reply once again. Please let me know the below statement meaning...
    :
    : type t_month_array is table of date indexed by binary_integer;
    :
    : What do you mean by "indexed by binary_integer" in the declaration.

    That just means you refer to elements in the "table" with integers

    v_months t_month_array;
    v_months(1) := sysdate
    v_months(10) := sysdate + 100

    both of the indexes (1 and 10) are binary integers. Technically you can probably leave that part off since binary integers are currently the only type you can use as a pl/sql table index.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • kishore_peddikishore_peddi Member Posts: 176
    Hi Infidel,

    Good day. ThanX for your reply once again.

    Bye...
    Cheers
    Kishore

Sign In or Register to comment.