Re: Cursor Not Populating Table

From: Joseph Strano <stranoj.dulcian_at_postoffice.worldnet.att.net>
Date: 1997/02/14
Message-ID: <3304AB29.1F03_at_postoffice.worldnet.att.net>#1/1


David E. Daniel wrote:
>
> I am trying to create a new table by the following commandS:
>
> drop table temptab3;
>
> create table temptab3
> (test_sys varchar2(2), test_comp varchar2(2));
>
> DECLARE
> sys_test temptab3.test_sys%TYPE;
> com_test temptab3.test_comp%TYPE;
>
> cursor c1 is
> select system,component from temptab2
> order by system,component;
>
>
> BEGIN
> open c1;
>
> loop
>
> fetch c1 into sys_test, com_test;
> exit when c1%notfound;
>
> end loop;
> END;
> /
>
> When performing a 'select * from temptab3;' , I get no rows selected.
> 'temptab2' does have system and component, both of varcar2(2).
> When I perform the cursor against sqlplus, I get the two columns from
> temptab2.
> What might I be doing incorrectly?
>
> One clue may be when this script is run, the following is displayed:
>
> Table dropped.
>
> Table created.
>
> Input truncated to 1 characters.
>
> PL/SQL procedure successfully completed.
>
> Any help or advice appreciated.
>
> -David
>
> --
> David E. Daniel
> Oracle Database Administrator
> Western Michigan University
> david.daniel_at_wmich.edu

The %TYPE will inherit the datatype of the column, but it does NOT directly link the variables to the database. In order to accomplish your task, you would need to add the following line of code after the fetch:
insert into temptab3 values(sys_test,com_test);

After the end loop, commit the changes.

Joe Strano
Dulcian Inc. Received on Fri Feb 14 1997 - 00:00:00 CET

Original text of this message