0

I'm trying to insert some values into a table from a select statement and some hardcoded values, but I'm not sure what the syntax would be. When I try I get an error saying there are not enough values so I know it's not reading my select statement correctly. Any help is appreciated.

insert into INSERT_STG
values(
  (select code,
          acct,  
          to_char(sysdate, 'mmddyy'),
          amt      
  from schema.table),
  'Partners',
  'city',
  'st',
  'Y',
  null,

);

2 Answers 2

7
insert into INSERT_STG
  (select code,
          acct,  
          to_char(sysdate, 'mmddyy'),
          amt ,
  'Partners',
  'city',
  'st',
  'Y',
  null
  from schema.table);

Problems:

  • You had extra comma after null
  • You can't combine hardcoded values and the select like you did. The hard coded values have to be generated as part of the select.

This should work assuming: INSERT_STG has 9 columns of the datatypes in schema.table in the order of the select and string and support null on last column.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that was it! I just wasn't sure how all of that worked in pl/sql.
1

Get rid of the "values" line and ensure you're inserting the same count of values as the table INSERT_STG has. Otherwise, explicitly specify columns of target table to insert.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.