-- Expose the "unplanned sub-select" error message

create table parts (
    partnum	varchar(18) primary key,
    cost	float8
);

create table shipped (
    ttype	char(2),
    ordnum	int4,
    partnum	varchar(18) references parts,
    value	float8,

    primary key (ttype, ordnum)
);

create view shipped_view as
    select * from shipped where ttype = 'wt';

create rule shipped_view_insert as on insert to shipped_view
    do instead insert into shipped
        (ttype, ordnum, partnum, value) 
    values
        ('wt', new.ordnum, new.partnum, new.value);
    
insert into parts (partnum, cost) values (1, 1234.56);

insert into shipped_view 
	(ordnum, partnum, value)
    values
        (100,1,(select cost from parts where partnum = 1));