Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

oracle procedure/package help

Status
Not open for further replies.

bubu2006

MIS
May 2, 2006
157
0
0
US
hi,

I have one script which is running fine out side oracle package/procedure.


example
delete table;
commit;

insert into table1(a,b,c)
select
a,
b,
a||b||e||f||d|| as c
from table2);
commit;

the concatenation is not working properly when I am putting this script inside a procedure which is a part of package. I am using Oracle 10g.
 
BuBu,

Within any PL/SQL block, independent SELECT statements (i.e., outside of some form of CURSOR), you must provide INTO receiving targets for each of your SELECT expressions:
Code:
DECLARE
    v_a <data type>;
    v_b <data type>;
    v_c <data type>;
BEGIN
    delete <table>;
    commit;
    insert into table1 [B][I]values[/I][/B] (a,b,c);
    select a, b, a||b||e||f||d
      [B][I]INTO v_a, v_b, v_c[/I][/B]
      from table2);
    commit;
    ...
END;
/
Notice that I also removed the extraneous, error-generating final concatenation operator ("||") from just before the "FROM...".

Let us know if this works for you.


[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
It should also work in pl/sql as a 'insert into table as select...'.

declare
--whatever you need
begin
insert into table1
as
select
a,
b,
a||b||e||f||d as c
from table2;
commit;
...
end;
/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top