oracle - PL/SQL Using aliases and functions in the subquery of an insert statement -
i'm pretty new pl/sql, wondering if there way achieve following :
insert atable ( select fn_to_value(b.field1, b.field2, b.field3) alias1, fn_to_value(b.field1, b.field2, b.field3) alias2, fn_to_value(b.field1, b.field2, b.field3) alias3, c.field1, c.field2 btable b, ctable c b.alias1= c.field3 );
given fn_to_value function returns corresponding datatype in atable.
i following error statements :
pl/sql : sql statement ignored (that's located @ insert line) pl/sql : ora-00904: "b"."alias1" invalid identifier
errata :
- i had modify clause where b.alias1= c.field1 where b.alias1= c.field3 because 1 of solution provided @bob jarvis wouldn't take consideration other fields might required link table btable , ctable.
solution :
i have opted following solution :
insert atable ( select b.alias1, b.alias2, b.alias3, c.field1, c.field2 ctable c, ( select fn_to_value (field1, field2, field3) alias1, fn_to_value (field1, field2, field3) alias2, fn_to_value (field1, field2, field3) alias3 btable ) b b.alias1 = c.field3 );
insert atable ( select inner.alias1, inner.alias2, inner.alias3, inner.field1, inner.field2 (select fn_to_value (b.field1, b.field2, b.field3) alias1, fn_to_value (b.field1, b.field2, b.field3) alias2, fn_to_value (b.field1, b.field2, b.field3) alias3, c.field1, c.field2 btable b, ctable c ) inner inner.alias1 = inner.field1 )
or
insert atable ( select fn_to_value (b.field1, b.field2, b.field3) alias1, fn_to_value (b.field1, b.field2, b.field3) alias2, fn_to_value (b.field1, b.field2, b.field3) alias3, c.field1, c.field2 btable b, ctable c fn_to_value (b.field1, b.field2, b.field3) = c.field1 );
Comments
Post a Comment