使用xsl将值插入表

时间:2019-09-16 08:28:02

标签: xml xslt plsql

我想通过xsl文件将值插入表中。

<xsl:for-each select="/zero:Zero/zero:MTOOwner/zero:DocumentNo/zero:BiProduct/zero:Part">
<xsl:sort select="zero:PosNo" />
INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) 
VALUES (
'<xsl:value-of select="../../../../pdms:PDMSProject/pdms:ProjectNumber/@text" />', 
'<xsl:value-of select="zero:MtoOwnerNo" />', 
'<xsl:value-of select="zero:PosNo" />',
'<xsl:value-of select="zero:StockNo" />', 
'<xsl:value-of select="zero:Description" />', 
<xsl:choose>
  <xsl:when test="zero:Quantity/@unit = 'mm2'"><xsl:value-of select="format-number(zero:Quantity/@number div 1000000, '#0.000')"/><xsl:text>, 'M2'</xsl:text></xsl:when>
  <xsl:when test="zero:Quantity/@unit = 'mm'"><xsl:value-of select="format-number(zero:Quantity/@number div 1000, '#0.000')"/><xsl:text>, 'M'</xsl:text></xsl:when>
  <xsl:when test="zero:Quantity/@unit = 'pcs'"><xsl:value-of select="format-number(zero:Quantity/@number, '#0')"/><xsl:text>, 'EA'</xsl:text></xsl:when>
  <xsl:otherwise><xsl:value-of select="format-number(zero:Quantity/@number, '#0.000')"/><xsl:text>, ''</xsl:text></xsl:otherwise>
</xsl:choose>, 
<xsl:value-of select="format-number(zero:TotalLength/@number div 1000, '#0.000')" />, 
<xsl:value-of select="zero:TotalWeight/@number" />, 
'<xsl:value-of select="zero:DocumentNo" />', 
'<xsl:value-of select="zero:Grade" />', 
<xsl:choose>
  <xsl:when test="zero:Traceable/@boolean = 'false'"><xsl:text>'N'</xsl:text></xsl:when>
  <xsl:otherwise><xsl:text>'Y'</xsl:text></xsl:otherwise>
  </xsl:choose>, 
  '<xsl:value-of select="zero:BiProduct" />', 
  <xsl:value-of select="format-number(zero:Surface/@number div 1000000, '#0.000')" />, 
  '<xsl:value-of select="zero:Calc" />', 
  '<xsl:value-of select="zero:Discipline" />', 
  '<xsl:value-of select="zero:Designer" />', 
  '<xsl:value-of select="zero:Name" />', 
  <xsl:value-of select="../../../zero:PlantSeq/@number" />, 
  '<xsl:value-of select="../../../zero:ObjectSeq/@number" />', 
  '<xsl:value-of select="../../../zero:ObjectRev" />');
  </xsl:for-each
这将导致以下SQL查询:

INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES 
('6111', '26-0008-R552-MOD-01-M', '1','PIP03D1160', 'PIPE sch.160 ASTM A790 UNS S31', 2.000, 'M', 2.000, 42.700, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A790 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.559, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');

INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES 
('6111', '26-0008-R552-MOD-01-M', '1','PIP03D1160', 'PIPE sch.160 ASTM A790 UNS S31', 0.660, 'M', 0.660, 14.093, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A790 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.184, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');

INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES 
('6111', '26-0008-R552-MOD-01-M', '10','E9003D1160', '90DEG LR ELBOW BW sch.160 ASTM', 1, 'EA', 0.179, 4.000, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A815 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.050, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');

INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES 
('6111', '26-0008-R552-MOD-01-M', '11','E9003D1160', '90DEG LR ELBOW BW sch.160 ASTM', 1, 'EA', 0.176, 4.000, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A815 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.049, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');

对于每个posno,我想总结每个PosNo的值。 对于Posno 1,应该是

INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES 
('6111', '26-0008-R552-MOD-01-M', '1','PIP03D1160', 'PIPE sch.160 ASTM A790 UNS S31', 2.66, 'M', 2.66, 56.793, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A790 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.559, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');

这可能吗?

0 个答案:

没有答案