select ... into ...
示例:
select t.SLIP_ID, t.CASE_ID,t.BARCODE, t.SHP_WT1, t.SHP_WT2, t.PK_DATE, t.REG_DATE, t.UPDATE into logizard.T06_CASE_DTL_TRN from logizard.T04_CASE_DTL_WK as t where t.SLIP_ID='111'
缺陷:被插入数据的表,必须不存在,否则报错!
insert into ... select ...
SQL Server 写法( 关键字 UPDATE ,用中括号括起来):
INSERT INTO SLIP_TRN(SLIP_ID,BARCODE,COMP_CD1,COMP_NM1,COMP_NM2,COMP_NM3,SHP_DATE1,SLIP_NUM1,SLIP_DTL_NUM1,PROD_CD1,PROD_NM1,LOT1,SHP_VOL1,FUNC_ID,USR_ID,USR_GRP,WK_REG_DATE,REG_DATE,[UPDATE]) SELECT SLIP_ID,BARCODE,COMP_CD1,COMP_NM1,COMP_NM2,COMP_NM3,SHP_DATE1,SLIP_NUM1,SLIP_DTL_NUM1,PROD_CD1,PROD_NM1,LOT1,SHP_VOL1,FUNC_ID,USR_ID,USR_GRP,REG_DATE,REG_DATE,[UPDATE] FROM SLIP_WK WHERE SLIP_ID = @SLIP_ID
PostgreSQL 写法:
logizard 为模式名,如果用特殊的用户,该用户只在特殊的模式下。则该用户进入,不必写模式名。
关键字 UPDATE,不用特殊处理。处理反而出错。
INSERT INTO logizard.T05_SLIP_TRN(SLIP_ID,BARCODE,COMP_CD1,COMP_NM1,COMP_NM2,COMP_NM3,SHP_DATE1,SLIP_NUM1,SLIP_DTL_NUM1,PROD_CD1,PROD_NM1,LOT1,SHP_VOL1,FUNC_ID,USR_ID,USR_GRP,WK_REG_DATE,REG_DATE,UPDATE) SELECT SLIP_ID,BARCODE,COMP_CD1,COMP_NM1,COMP_NM2,COMP_NM3,SHP_DATE1,SLIP_NUM1,SLIP_DTL_NUM1,PROD_CD1,PROD_NM1,LOT1,SHP_VOL1,FUNC_ID,USR_ID,USR_GRP,REG_DATE,REG_DATE,UPDATE FROM logizard.T03_SLIP_WK WHERE SLIP_ID = '111'