-
Can anyboby tell me why the SQL below works in SQLPLUS. but when you put it in a procedure and try to compile it, it gives an error.
Thanks,
Ed
--SQL
insert into stationlstatistics
(select e.* from stationestatistics e
where (select l.tottripno
from stationlstatistics l
where l.stncarr = e.stncarr
and l.stncity = e.stncity
and l.stnst = e.stnst
and l.totacthrs = e.totacthrs
and l.trainchgfl = e.trainchgfl) is null and
(select sum(l2.tottripno) from stationlstatistics l2
where l2.stncarr = e.stncarr
and l2.stncity = e.stncity
and l2.stnst = e.stnst
and l2.trainchgfl = e.trainchgfl ) < 41
);
--PL/SQL
create or replace procedure test_proc as
Begin
insert into stationlstatistics
(select e.* from stationestatistics e
where (select l.tottripno
from stationlstatistics l
where l.stncarr = e.stncarr
and l.stncity = e.stncity
and l.stnst = e.stnst
and l.totacthrs = e.totacthrs
and l.trainchgfl = e.trainchgfl) is null and
(select sum(l2.tottripno) from stationlstatistics l2
where l2.stncarr = e.stncarr
and l2.stncity = e.stncity
and l2.stnst = e.stnst
and l2.trainchgfl = e.trainchgfl ) < 41
);
COMMIT;
end;
/
-
-
It's not allowing me to compile the PROC. I am getting this error. Is it not enough the Query works on SQLPLUS?
5/9
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + mod not null others
avg
count current exists max min prior sql stddev sum variance
execute cast trim forall
11/37
PLS-00103: Encountered the symbol "NULL" when expecting one of the following:
set
-
Try using cursors & variables and select data into the variables for select statements nested in the main query.
-
Use Cursors & Variables...
Its not necessary that ur query working in SQL needs to work when put in a PROC...Sometimes it may need some minor changes to get it going...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|