Oracle Insert via Select from multiple tables where one table may not have a row

前端 未结 6 1694
野性不改
野性不改 2020-12-25 08:56

I have a number of code value tables that contain a code and a description with a Long id.

I now want to create an entry for an Account Type that references a number

6条回答
  •  半阙折子戏
    2020-12-25 09:33

    A slightly simplified version of Oglester's solution (the sequence doesn't require a select from DUAL:

    INSERT INTO account_type_standard   
      (account_type_Standard_id, tax_status_id, recipient_id) 
    VALUES(   
      account_type_standard_seq.nextval,
      (SELECT tax_status_id FROM tax_status WHERE tax_status_code = ?),
      (SELECT recipient_id FROM recipient WHERE recipient_code = ?)
    )
    

提交回复
热议问题