0

我想在数据库 Oracle 中插入一个新行。

INSERT INTO xx_vms.es_supplier_process_steps (process_step_id, supplier_process_id, supplier_step_id,
mapped_item_type, mapped_subinventory_code, mapped_subinventory_type, mapped_operation_code, mapping_notes)
VALUES (xx_vms.seq_es_supplier_proc_step_id.NEXTVAL, xx_vms.seq_es_supplier_proc_id.CURRVAL,
xx_vms.seq_es_supplier_step_id.CURRVAL, 'ASY', null, 'IN', null, null);

xx_vms.seq_es_supplier_proc_id.CURRVAL 列是以下查询的结果。示例:122:

select supplier_process_id from xx_vms.es_supplier_processes where supplier_code='TEST'and name='FINAL TEST';

但我不知道该怎么做。请帮我!谢谢。

4

1 回答 1

0

您将要使用子查询进行插入

 INSERT INTO xx_vms.es_supplier_process_steps 
      (process_step_id, 
      supplier_process_id, 
      supplier_step_id,
      mapped_item_type, 
      mapped_subinventory_code, 
      mapped_subinventory_type, 
      mapped_operation_code, 
      mapping_notes)
 SELECT x_vms.seq_es_supplier_proc_step_id.NEXTVAL, 
       (select supplier_process_id 
         from xx_vms.es_supplier_processes 
         where supplier_code='TEST'and 
               name='FINAL TEST'),
        xx_vms.seq_es_supplier_step_id.CURRVAL, 
        'ASY', 
        null, 
        'IN', 
        null, 
        null
 FROM DUAL);
于 2013-05-07T03:56:34.687 回答