Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Stored procedure using insert select and parameter

tharpaJan 18 2012 — edited Feb 28 2012
I wish to create a stored procedure that performs a select insert , but uses the parameter as the value for one of the columns. This is one thing I've tried:
create or replace PROCEDURE           "CRT_FUEL_QRTRLY_ADTV_RCRDS" (fuel_id_new varchar2)
IS
  
  FUEL_ADDITIVE_record_count	number;
 BEGIN
  select count(1) into FUEL_ADDITIVE_record_count
  from FUEL_ADDITIVE
  where FUEL_ID = fuel_id_new;
  
  if FUEL_ADDITIVE_record_count = 0
  then
		insert into FUEL_QUARTERLY_ADDITIVE
		(FUEL_ID, ADDITIVE_ID,  YEAR, QUARTER)3077
		values(
			(select FUEL_ID, ADDITIVE_ID, YEAR, QUARTER
			from FUEL_ADDITIVE
			where FUEL_ID = fuel_id_new));
			
	end if;  
 END;
but when I compile it, I get the error "ORA-00947; not enough values."

What is the simplest way of doing this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2012
Added on Jan 18 2012
6 comments
28,385 views