leobia
leobia

Reputation: 58

Insert into nested table plsql

I'm a newbie with pl sql and I'm facing some problems with inserting into nested tables (I'm using these just to test a procedure). So my code is:

insert into t_prenotazioni
      (nro_cliente, data_disponibilita)
    values
      (righe.nro_cliente, v_data_disponibilita);

where t_prenotazioni is a table of a type defined by me, righe.nro_cliente is a value that I get from a cursor and v_data_disponibilita is a variable. The error that I get is:

PLS-00330 invalid use of type name or subtype

Upvotes: 2

Views: 2740

Answers (1)

Aleksej
Aleksej

Reputation: 22949

You are probably trying to do something like:

declare
    type type_prenotazioni is record(nro_cliente number, data_disponibilita date);
    type prenotazioni is table of type_prenotazioni;
    vPrenotazioni prenotazioni;
begin
    vPrenotazioni := new prenotazioni();
    vPrenotazioni.extend(1);
    vPrenotazioni(1).nro_cliente := 10;
    vPrenotazioni(1).data_disponibilita := sysdate;
    --
    for i in vPrenotazioni.first .. vPrenotazioni.last loop
        dbms_output.put_line(vPrenotazioni(i).nro_cliente || ' - ' ||
                                to_char(vPrenotazioni(i).data_disponibilita, 'dd/mm/yyyy')
                               );
    end loop;
end;

I would stronlgy recommend having a look at the Oracle documentation to improve your knowledge; this is only a simple, small example, but there are many many different things you may want to do.

Upvotes: 2

Related Questions