2013-10-11 69 views
1

我試圖從informatica XML創建一個設計文檔作爲輸入。 這裏我已使用轉換的列表中,並讓他們在一個單獨的文件(LOTO.txt) 和主XML文件(testingfull.txt) 我從第一列取第一個值,並檢查什麼樣的轉變它是並繼續執行代碼。我的問題是LKP的它是返回所有LKP的相同的SELECT查詢。我的代碼如下:unix sed和while循環

#!/bin/bash 
while read T 
do 
{ 
    TYPE=`echo $T |cut -c-4|cut -c2-` 
    ##echo "$TYPE" 
    ##TT=`echo \'$T\'` 
    ##echo "$TT" 
    if [ "$TYPE" = "SQ_" ]; then 
     SQL=`cat testingfull.txt|sed -n '/$T/,/VALUE ="Never"/p'|grep "Sql Query" | sed -n '/SELECT/,/"/p' | sed 's/
//g'| sed 's/'Y'//g' | cut -d'"' -f4` 
     echo "$T  : $SQL"$'\n'>>singletesting.txt 

    elif [ "$TYPE" = "GET" ]; then 
     SQL='GET_MAX_VALUE    :   Reusable transformation to get the max key value from the target Table' 
     echo "$SQL"$'\n'>>singletesting.txt 
    elif [ "$TYPE" = "Lkp" ]; then 
     SQL=`cat testingfull.txt|sed -n '/$T/,/VALUE ="Null Is Highest Value"/p'|grep "Lookup Sql Override" | sed -n '/SELECT/,/"/p' | sed 's/
//g'| sed 's/'Y'//g' | cut -d'"' -f4` 
     echo "$T  : $SQL"$'\n'>>singletesting.txt 
    else 
     echo "$T   : under construnction"$'\n'$'\n'>>singletesting.txt 
    fi 
} 
done <LOTO.txt 

LOTO.txt:

"Lkp_CDL_BOOKINGS_F_Delta_AMT" 
"Lkp_CIL_ORIG_PRICING_SCENARIO" 
"Lkp_EQIP_MAINT_PCT" 
"SQ_CDL_PURCHASE_ORDER_F" 

下面是主要的XML文件:

<TRANSFORMATION DESCRIPTION ="" NAME ="Lkp_CDL_BOOKINGS_F_Delta_AMT" OBJECTVERSION ="1" REUSABLE ="NO" TYPE ="Lookup Procedure" VERSIONNUMBER ="4"> 
    <TRANSFORMFIELD DATATYPE ="decimal" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="BOOKINGS_FACT_KEY" PICTURETEXT ="" PORTTYPE ="LOOKUP/OUTPUT" PRECISION ="38" SCALE ="0"/> 
    <TRANSFORMFIELD DATATYPE ="decimal" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="PURCHASE_ORDER_KEY" PICTURETEXT ="" PORTTYPE ="LOOKUP" PRECISION ="38" SCALE ="0"/> 
    <TRANSFORMFIELD DATATYPE ="decimal" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="BOOK_DATE_KEY" PICTURETEXT ="" PORTTYPE ="LOOKUP/OUTPUT" PRECISION ="38" SCALE ="0"/> 
    <TRANSFORMFIELD DATATYPE ="decimal" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="HARDWARE_CISCO_LC_AMT" PICTURETEXT ="" PORTTYPE ="LOOKUP/OUTPUT" PRECISION ="26" SCALE ="7"/> 
    <!-- ="0"/> --> 
    <TABLEATTRIBUTE NAME ="Lookup Sql Override" VALUE ="SELECT &#xD;&#xA;CDL_BOOKINGS_F.BOOKINGS_FACT_KEY as BOOKINGS_FACT_KEY,&#xD;&#xA;CDL_BOOKINGS_F.PURCHASE_ORDER_KEY as PURCHASE_ORDER_KEY,&#xD;&#xA;CDL_BOOKINGS_F.BOOK_DATE_KEY as BOOK_DATE_KEY,&#xD;&#xA;CDL_BOOKINGS_F.HARDWARE_CISCO_LC_AMT as HARDWARE_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_CISCO_USD_AMT as HARDWARE_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_NON_CISCO_LC_AMT as HARDWARE_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_NON_CISCO_USD_AMT as HARDWARE_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_ESSNTL_CISCO_LC_AMT as SOFTWARE_ESSNTL_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_ESSNTL_CISCO_USD_AMT as SOFTWARE_ESSNTL_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_CISCO_LC_AMT as FREIGHT_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_CISCO_USD_AMT as FREIGHT_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_NON_CISCO_LC_AMT as FREIGHT_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_NON_CISCO_USD_AMT as FREIGHT_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALLATION_CISCO_LC_AMT as INSTALLATION_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALLATION_CISCO_USD_AMT as INSTALLATION_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALLATION_NON_CISCO_LC_AMT as INSTALLATION_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALLATION_NON_CISCO_USD_AMT as INSTALLATION_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULTING_CISCO_LC_AMT as CONSULTING_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULTING_CISCO_USD_AMT as CONSULTING_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_TAX_CISCO_LC_AMT as FINANCED_TAX_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_TAX_CISCO_USD_AMT as FINANCED_TAX_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_TAX_CISCO_LC_AMT as TRAINING_TAX_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_TAX_CISCO_USD_AMT as TRAINING_TAX_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.WEBEX_SERVICES_CISCO_LC_AMT as WEBEX_SERVICES_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.WEBEX_SERVICES_CISCO_USD_AMT as WEBEX_SERVICES_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SERVICES_CISCO_LC_AMT as PROF_SERVICES_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SERVICES_CISCO_USD_AMT as PROF_SERVICES_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_CISCO_LC_AMT as SERVICES_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_CISCO_USD_AMT as SERVICES_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULTING_NON_CISCO_LC_AMT as CONSULTING_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULTING_NON_CISCO_USD_AMT as CONSULTING_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_TAX_NON_CISCO_LC_AMT as FINANCED_TAX_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_TAX_NON_CISCO_USD_AMT as FINANCED_TAX_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_NON_CISCO_LC_AMT as TRAINING_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_NON_CISCO_USD_AMT as TRAINING_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SERVICE_NON_CISCO_LC_AMT as PROF_SERVICE_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SERVICE_NON_CISCO_USD_AMT as PROF_SERVICE_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_NON_CISCO_LC_AMT as SERVICES_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_NON_CISCO_USD_AMT as SERVICES_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_CISCO_LC_AMT as SOFTWARE_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_CISCO_USD_AMT as SOFTWARE_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_NON_CISCO_LC_AMT as SOFTWARE_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_NON_CISCO_USD_AMT as SOFTWARE_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINTENANCE_NON_CISCO_LC_AMT as MAINTENANCE_NON_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINTENANCE_NON_CISCO_USD_AMT as MAINTENANCE_NON_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_HARDWARE_CISCO_LC_AMT as MAINT_HARDWARE_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_HARDWARE_CISCO_USD_AMT as MAINT_HARDWARE_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SOFTWARE_CISCO_LC_AMT as MAINT_SOFTWARE_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SOFTWARE_CISCO_USD_AMT as MAINT_SOFTWARE_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SMARTNET_CISCO_LC_AMT as MAINT_SMARTNET_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SMARTNET_CISCO_USD_AMT as MAINT_SMARTNET_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_PHONE_SUP_CISCO_LC_AMT as MAINT_PHONE_SUP_CISCO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_PHONE_SUP_CISCO_USD_AMT as MAINT_PHONE_SUP_CISCO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_FEE_LC_AMT as FINANCED_FEE_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_FEE_USD_AMT as FINANCED_FEE_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BOOK_LC_AMT as BOOK_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BOOK_USD_AMT as BOOK_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.GROSS_PO_LC_AMT as GROSS_PO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.GROSS_PO_USD_AMT as GROSS_PO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.NET_PO_LC_AMT as NET_PO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.NET_PO_USD_AMT as NET_PO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BLIND_DISCOUNT_LC_AMT as BLIND_DISCOUNT_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BLIND_DISCOUNT_USD_AMT as BLIND_DISCOUNT_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_CISCO_DELTA_LC_AMT as HARDWARE_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_CISCO_DELTA_USD_AMT as HARDWARE_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_NONCISCO_DELTA_LC_AMT as HARDWARE_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.HARDWARE_NONCSCO_DELTA_USD_AMT as HARDWARE_NONCSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SW_ESSNTL_CISCO_DELTA_LC_AMT as SW_ESSNTL_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SW_ESSNTL_CISCO_DELTA_USD_AMT as SW_ESSNTL_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_CISCO_DELTA_LC_AMT as FREIGHT_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_CISCO_DELTA_USD_AMT as FREIGHT_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_NONCISCO_DELTA_LC_AMT as FREIGHT_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FREIGHT_NONCISCO_DELTA_USD_AMT as FREIGHT_NONCISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALL_CISCO_DELTA_LC_AMT as INSTALL_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALL_CISCO_DELTA_USD_AMT as INSTALL_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALL_NON_CISCO_DELTA_LC_AMT as INSTALL_NON_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.INSTALL_NON_CSCO_DELTA_USD_AMT as INSTALL_NON_CSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULTING_CISCO_DELTA_LC_AMT as CONSULTING_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULTING_CISCO_DELTA_USD_AMT as CONSULTING_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCE_TAX_CSCO_DELTA_LC_AMT as FINANCE_TAX_CSCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCE_TAX_CSCO_DELTA_USD_AMT as FINANCE_TAX_CSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_TAX_CSCO_DELTA_LC_AMT as TRAINING_TAX_CSCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_TAX_CSCO_DLTA_USD_AMT as TRAINING_TAX_CSCO_DLTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.WEBEX_SVC_CISCO_DELTA_LC_AMT as WEBEX_SVC_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.WEBEX_SVC_CISCO_DELTA_USD_AMT as WEBEX_SVC_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SVC_CISCO_DELTA_LC_AMT as PROF_SVC_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SVC_CISCO_DELTA_USD_AMT as PROF_SVC_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_CISCO_DELTA_LC_AMT as SERVICES_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_CISCO_DELTA_USD_AMT as SERVICES_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULT_NONCISCO_DELTA_LC_AMT as CONSULT_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.CONSULT_NONCISCO_DELTA_USD_AMT as CONSULT_NONCISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FIN_TAX_NONCISCO_DELTA_LC_AMT as FIN_TAX_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FIN_TAX_NONCISCO_DELTA_USD_AMT as FIN_TAX_NONCISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_NONCISCO_DELTA_LC_AMT as TRAINING_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.TRAINING_NONCSCO_DELTA_USD_AMT as TRAINING_NONCSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SVC_NONCISCO_DELTA_LC_AMT as PROF_SVC_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.PROF_SVC_NONCSCO_DELTA_USD_AMT as PROF_SVC_NONCSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_NONCISCO_DELTA_LC_AMT as SERVICES_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SERVICES_NONCSCO_DELTA_USD_AMT as SERVICES_NONCSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_CISCO_DELTA_LC_AMT as SOFTWARE_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_CISCO_DELTA_USD_AMT as SOFTWARE_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_NONCISCO_DELTA_LC_AMT as SOFTWARE_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.SOFTWARE_NONCSCO_DELTA_USD_AMT as SOFTWARE_NONCSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_NONCISCO_DELTA_LC_AMT as MAINT_NONCISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_NONCISCO_DELTA_USD_AMT as MAINT_NONCISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_HW_CISCO_DELTA_LC_AMT as MAINT_HW_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_HW_CISCO_DELTA_USD_AMT as MAINT_HW_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SW_CISCO_DELTA_LC_AMT as MAINT_SW_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SW_CISCO_DELTA_USD_AMT as MAINT_SW_CISCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SMNET_CISCO_DELTA_LC_AMT as MAINT_SMNET_CISCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_SMNET_CSCO_DELTA_USD_AMT as MAINT_SMNET_CSCO_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_PH_SUP_CSCO_DELTA_LC_AMT as MAINT_PH_SUP_CSCO_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.MAINT_PH_SUP_CSCO_DLTA_USD_AMT as MAINT_PH_SUP_CSCO_DLTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_FEE_DELTA_LC_AMT as FINANCED_FEE_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.FINANCED_FEE_DELTA_USD_AMT as FINANCED_FEE_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BOOK_DELTA_LC_AMT as BOOK_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BOOK_DELTA_USD_AMT as BOOK_DELTA_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.GROSS_DELTA_PO_LC_AMT as GROSS_DELTA_PO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.GROSS_DELTA_PO_USD_AMT as GROSS_DELTA_PO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.NET_DELTA_PO_LC_AMT as NET_DELTA_PO_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.NET_DELTA_PO_USD_AMT as NET_DELTA_PO_USD_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BLIND_DISCOUNT_DELTA_LC_AMT as BLIND_DISCOUNT_DELTA_LC_AMT,&#xD;&#xA; CDL_BOOKINGS_F.BLIND_DISCOUNT_DELTA_USD_AMT as BLIND_DISCOUNT_DELTA_USD_AMT,&#xD;&#xA; MAX_VALUE.ORDER_CNT as ORDER_CNT,&#xD;&#xA; MAX_VALUE.PURCHASE_ORDER_NUM AS PURCHASE_ORDER_NUM&#xD;&#xA; FROM CDL_BOOKINGS_F,&#xD;&#xA; (SELECT MAX(BOOKINGS_FACT_KEY) BOOKINGS_FACT_KEY ,count(*) ORDER_CNT,PURCHASE_ORDER_NUM &#xD;&#xA;FROM CDL_BOOKINGS_F ,CDL_PURCHASE_ORDER_D&#xD;&#xA;WHERE CDL_BOOKINGS_F.PURCHASE_ORDER_KEY = CDL_PURCHASE_ORDER_D.PURCHASE_ORDER_KEY&#xD;&#xA;GROUP BY PURCHASE_ORDER_NUM) MAX_VALUE&#xD;&#xA; WHERE &#xD;&#xA;CDL_BOOKINGS_F.BOOKINGS_FACT_KEY = MAX_VALUE.BOOKINGS_FACT_KEY"/> 
    <TABLEATTRIBUTE NAME ="Lookup table name" VALUE ="CDL_BOOKINGS_F"/> 
    <TABLEATTRIBUTE NAME ="Lookup Source Filter" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Lookup caching enabled" VALUE ="YES"/> 
    <TABLEATTRIBUTE NAME ="Lookup policy on multiple match" VALUE ="Use Any Value"/> 
    <TABLEATTRIBUTE NAME ="Lookup condition" VALUE ="PURCHASE_ORDER_NUM = I_PURCHASE_ORDER_NUM"/> 
    <TABLEATTRIBUTE NAME ="Connection Information" VALUE ="$Target"/> 
    <TABLEATTRIBUTE NAME ="Source Type" VALUE ="Database"/> 
    <TABLEATTRIBUTE NAME ="Recache if Stale" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Tracing Level" VALUE ="Normal"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache directory name" VALUE ="$PMCacheDir"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache initialize" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache persistent" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup Data Cache Size" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Lookup Index Cache Size" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Dynamic Lookup Cache" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Synchronize Dynamic Cache" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Output Old Value On Update" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Update Dynamic Cache Condition" VALUE ="TRUE"/> 
    <TABLEATTRIBUTE NAME ="Cache File Name Prefix" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Re-cache from lookup source" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Insert Else Update" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Update Else Insert" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Datetime Format" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Thousand Separator" VALUE ="None"/> 
    <TABLEATTRIBUTE NAME ="Decimal Separator" VALUE ="."/> 
    <TABLEATTRIBUTE NAME ="Case Sensitive String Comparison" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Null ordering" VALUE ="Null Is Highest Value"/> 
    <TABLEATTRIBUTE NAME ="Sorted Input" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup source is static" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Pre-build lookup cache" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Subsecond Precision" VALUE ="6"/> 
</TRANSFORMATION> 
<TRANSFORMATION DESCRIPTION ="" NAME ="Lkp_CIL_ORIG_PRICING_SCENARIO" OBJECTVERSION ="1" REUSABLE ="NO" TYPE ="Lookup Procedure" VERSIONNUMBER ="4"> 
    <TRANSFORMFIELD DATATYPE ="decimal" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="ORIG_PO_HEADER_KEY" PICTURETEXT ="" PORTTYPE ="LOOKUP/OUTPUT" PRECISION ="38" SCALE ="0"/> 
    <!-- ="0"/> --> 
    <TABLEATTRIBUTE NAME ="Lookup Sql Override" VALUE ="SELECT &#xD;&#xA;CIL_ORIG_PO_HEADER.ORIG_PO_HEADER_KEY AS ORIG_PO_HEADER_KEY,&#xD;&#xA;DECODE (SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT),0, 0,&#xD;&#xA;SUM(CIL_ORIG_PRICING_SCENARIO.CSC_YIELD_PCT * CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)/ SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT))&#xD;&#xA;AS CAPITAL_INTEREST_RT,&#xD;&#xA;DECODE (SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT),0, 0,&#xD;&#xA;SUM(CIL_ORIG_PRICING_SCENARIO.CUST_YIELD_PCT * CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)/ SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)) AS CUSTOMER_INTREST_RT,&#xD;&#xA;DECODE (SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT),0, 0,&#xD;&#xA;SUM(CIL_ORIG_PRICING_SCENARIO.CSC_NPV_PCT* CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)/ SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)) AS NPV_PCT,&#xD;&#xA;DECODE (SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT),0, 0&#xD;&#xA;,SUM(CIL_ORIG_PRICING_SCENARIO.RV_PCT * CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)/ SUM(CIL_ORIG_PRICING_SCENARIO.CUST_FINANCED_LC_AMT)) AS RESIDUAL_VALUE_PCT&#xD;&#xA;FROM CILNL.CIL_ORIG_PRICING_SCENARIO,CILNL.CIL_ORIG_PO_HEADER,CILNL.CIL_ORIG_PO_LINE,CILNL.CIL_ORIG_QUOTE_LINE&#xD;&#xA;WHERE &#xD;&#xA;CIL_ORIG_PO_HEADER.ORIG_PO_HEADER_KEY=CIL_ORIG_PO_LINE .ORIG_PO_HEADER_KEY &#xD;&#xA;AND CIL_ORIG_PO_LINE.ORIG_QUOTE_LINE_KEY =CIL_ORIG_QUOTE_LINE.ORIG_QUOTE_LINE_KEY&#xD;&#xA;AND CIL_ORIG_QUOTE_LINE.ORIG_BOM_HEADER_KEY = CIL_ORIG_PRICING_SCENARIO.ORIG_BOM_HEADER_KEY&#xD;&#xA;GROUP BY CIL_ORIG_PO_HEADER.ORIG_PO_HEADER_KEY"/> 
    <TABLEATTRIBUTE NAME ="Lookup table name" VALUE ="CIL_ORIG_PRICING_SCENARIO"/> 
    <TABLEATTRIBUTE NAME ="Lookup Source Filter" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Lookup caching enabled" VALUE ="YES"/> 
    <TABLEATTRIBUTE NAME ="Lookup policy on multiple match" VALUE ="Use Any Value"/> 
    <TABLEATTRIBUTE NAME ="Lookup condition" VALUE ="ORIG_PO_HEADER_KEY = CIL_PURCHASE_ORDER_KEY"/> 
    <TABLEATTRIBUTE NAME ="Connection Information" VALUE ="$Target"/> 
    <TABLEATTRIBUTE NAME ="Source Type" VALUE ="Database"/> 
    <TABLEATTRIBUTE NAME ="Recache if Stale" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Tracing Level" VALUE ="Normal"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache directory name" VALUE ="$PMCacheDir"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache initialize" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache persistent" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup Data Cache Size" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Lookup Index Cache Size" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Dynamic Lookup Cache" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Synchronize Dynamic Cache" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Output Old Value On Update" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Update Dynamic Cache Condition" VALUE ="TRUE"/> 
    <TABLEATTRIBUTE NAME ="Cache File Name Prefix" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Re-cache from lookup source" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Insert Else Update" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Update Else Insert" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Datetime Format" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Thousand Separator" VALUE ="None"/> 
    <TABLEATTRIBUTE NAME ="Decimal Separator" VALUE ="."/> 
    <TABLEATTRIBUTE NAME ="Case Sensitive String Comparison" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Null ordering" VALUE ="Null Is Highest Value"/> 
    <TABLEATTRIBUTE NAME ="Sorted Input" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup source is static" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Pre-build lookup cache" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Subsecond Precision" VALUE ="6"/> 
</TRANSFORMATION> 
<TRANSFORMATION DESCRIPTION ="" NAME ="Lkp_EQIP_MAINT_PCT" OBJECTVERSION ="1" REUSABLE ="NO" TYPE ="Lookup Procedure" VERSIONNUMBER ="3"> 
    <TRANSFORMFIELD DATATYPE ="decimal" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="SUMM" PICTURETEXT ="" PORTTYPE ="LOOKUP/RETURN/OUTPUT" PRECISION ="26" SCALE ="7"/> 
    <!-- SCALE ="0"/> --> 
    <TABLEATTRIBUTE NAME ="Lookup Sql Override" VALUE ="SELECT &#xD;&#xA;DECODE(sum(CIL_ORIG_PRICING_SCENARIO.CSC_FINANCED_LC_AMT),0,0, sum(CIL_ORIG_PRICING_SCENARIO.CSC_YIELD_PCT * CIL_ORIG_PRICING_SCENARIO.CSC_FINANCED_LC_AMT)/sum(CIL_ORIG_PRICING_SCENARIO.CSC_FINANCED_LC_AMT)) AS SUMM,&#xD;&#xA;CIL_ORIG_PO_LINE.ORIG_PO_HEADER_KEY AS ORIG_PO_HEADER_KEY,&#xD;&#xA;CIL_ORIG_PRCNG_SCENARIO_GROUP.AK_PRICING_GROUP_TYPE_CD AS AK_PRICING_GROUP_TYPE_CD&#xD;&#xA;FROM &#xD;&#xA;CILNL.CIL_ORIG_PO_LINE,CILNL.CIL_ORIG_QUOTE_LINE,CILNL.CIL_ORIG_PRICING_SCENARIO,CILNL.CIL_ORIG_PRCNG_SCENARIO_GROUP,&#xD;&#xA;CILNL.CIL_ORIG_PO_HEADER&#xD;&#xA;WHERE &#xD;&#xA;CIL_ORIG_PO_HEADER .ORIG_PO_HEADER_KEY=CIL_ORIG_PO_LINE .ORIG_PO_HEADER_KEY&#xD;&#xA;AND CIL_ORIG_PO_LINE.ORIG_QUOTE_LINE_KEY =CIL_ORIG_QUOTE_LINE.ORIG_QUOTE_LINE_KEY&#xD;&#xA;AND CIL_ORIG_QUOTE_LINE.ORIG_BOM_HEADER_KEY = CIL_ORIG_PRICING_SCENARIO.ORIG_BOM_HEADER_KEY&#xD;&#xA;AND CIL_ORIG_PRICING_SCENARIO.ORIG_PRICING_SCENARIO_KEY=CIL_ORIG_PRCNG_SCENARIO_GROUP.AK_ORIG_PRICING_SCENARIO_KEY&#xD;&#xA;GROUP BY CIL_ORIG_PO_LINE .ORIG_PO_HEADER_KEY,CIL_ORIG_PRCNG_SCENARIO_GROUP.AK_PRICING_GROUP_TYPE_CD"/> 
    <TABLEATTRIBUTE NAME ="Lookup table name" VALUE ="CIL_ORIG_PRICING_SCENARIO"/> 
    <TABLEATTRIBUTE NAME ="Lookup Source Filter" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Lookup caching enabled" VALUE ="YES"/> 
    <TABLEATTRIBUTE NAME ="Lookup policy on multiple match" VALUE ="Use Any Value"/> 
    <TABLEATTRIBUTE NAME ="Lookup condition" VALUE ="ORIG_PO_HEADER_KEY = IN_CIL_PURCHASE_ORDER_KEY AND AK_PRICING_GROUP_TYPE_CD = IN_AK_PRICING_GROUP_TYPE_CD"/> 
    <TABLEATTRIBUTE NAME ="Connection Information" VALUE ="$Target"/> 
    <TABLEATTRIBUTE NAME ="Source Type" VALUE ="Database"/> 
    <TABLEATTRIBUTE NAME ="Recache if Stale" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Tracing Level" VALUE ="Normal"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache directory name" VALUE ="$PMCacheDir"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache initialize" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup cache persistent" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup Data Cache Size" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Lookup Index Cache Size" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Dynamic Lookup Cache" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Synchronize Dynamic Cache" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Output Old Value On Update" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Update Dynamic Cache Condition" VALUE ="TRUE"/> 
    <TABLEATTRIBUTE NAME ="Cache File Name Prefix" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Re-cache from lookup source" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Insert Else Update" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Update Else Insert" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Datetime Format" VALUE =""/> 
    <TABLEATTRIBUTE NAME ="Thousand Separator" VALUE ="None"/> 
    <TABLEATTRIBUTE NAME ="Decimal Separator" VALUE ="."/> 
    <TABLEATTRIBUTE NAME ="Case Sensitive String Comparison" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Null ordering" VALUE ="Null Is Highest Value"/> 
    <TABLEATTRIBUTE NAME ="Sorted Input" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Lookup source is static" VALUE ="NO"/> 
    <TABLEATTRIBUTE NAME ="Pre-build lookup cache" VALUE ="Auto"/> 
    <TABLEATTRIBUTE NAME ="Subsecond Precision" VALUE ="6"/> 

能否請你幫我在這?

+0

你能列出一個示例輸入和輸出文件嗎? – jofel

+0

我可以在哪裏添加這些文件 –

+2

將它們縮小爲最小范例並直接將其添加到問題中。 – jofel

回答

2

我玩過這一點。我可以讓核心邏輯在命令行上工作,但不能在腳本的上下文中工作 - 我認爲shell的元字符解釋是其核心。我稍微調整了腳本以使其起作用 - 至少在Lkp的情況下。您需要驗證SQ_個案。修改後的腳本:

#!/bin/bash 
while read T 
do 
    { 
    TYPE=`echo $T | cut -c-4 | cut -c2-` 
    TARGET=`echo $T | sed 's/"//g'` 
    echo "Type = $TYPE" 
    if [ "$TYPE" = "SQ_" ]; then 
     cmd="cat testingfull.txt | sed -n '/$TARGET/,/VALUE =\"Never\"/p'| grep \"Sql Query\" | sed 's/&#xD;&#xA;//g'| sed 's/&apos;Y&apos;//g' | cut -d '\"' -f 4" 
     SQL=`eval $cmd` 
     echo "$T  : $SQL"$'\n' >> singletesting.txt 
    elif [ "$TYPE" = "GET" ]; then 
     SQL='GET_MAX_VALUE    :   Reusable transformation to get the max key value from the target Table' 
     echo "$SQL"$'\n' >> singletesting.txt 
    elif [ "$TYPE" = "Lkp" ]; then 
     cmd="cat testingfull.txt | sed -n '/$TARGET/,/VALUE =\"Null Is Highest Value\"/p' | grep 'Lookup Sql Override' | sed 's/&#xD;&#xA;//g'| sed 's/&apos;Y&apos;//g' | cut -d '\"' -f 4" 
     SQL=`eval $cmd` 
     echo "$T  : $SQL"$'\n' >> singletesting.txt 
    else 
     echo "$T   : under construction"$'\n'$'\n' >> singletesting.txt 
    fi 
    } 
done < LOTO.txt 
+0

您好jstevenco我的問題已解決在您的代碼cmd =「cat testingfull.txt | sed -n'/ $ TARGET/---這裏我們需要保持這個/'「$ TARGET」'/ –