测试列是否为数字scriptella

时间:2017-08-20 08:09:23

标签: java scriptella janino

我试图测试列是否是数字,通过scriptella从oracle数据库复制到postgresql数据库,这里是我为scriptella所做的。 ,请帮忙,我刚才这个

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <description>
        test script Pour table article
    </description>
    <connection id="in" driver="oracle"
        url="jdbc:oracle:thin:@localhost:1521:XE" user="IPTECH" password="IPTECH" />

    <connection id="out" driver="postgresql"
        url="jdbc:postgresql://localhost:5432/testMonoprix2" user="postgres"
        password="maher" />

    <connection id="log" driver="text" /> <!-- For printing debug information on the console -->
    <connection id="java" driver="janino" />



    <query connection-id="in">
        SELECT CODEARTICLE,STRUCTURE, DES,TYPEMARK,TYP,IMPLOC,MARQUE,GAMME,TAR
        FROM IPTECH.TMP_ARTICLE ;


        <script connection-id="java">
            import java.io.*;
            String ntteCode;
            Boolean result;
            Object o = get("CODEARTICLE");
            test =is_numeric(o)
        </script>
            <script connection-id="out" if="test">
                INSERT INTO public.articles
                (id,
                is_enabled,type_marketing,type_tarif,description,gamme,import_local,marque,reference,struct,family_id)
                values
                (cast(?CODEARTICLE
                as
                bigint),'TRUE',?TYPEMARK,?TAR,?DES,?GAMME,?IMPLOC,?MARQUE,?CODEARTICLE,?STRUCTURE,cast(?{STRUCTURE.substring(0,
                2)} as bigint));
            </script>
    </query>
</etl>

1 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <description>
        test script Pour table article
    </description>
    <connection id="in" driver="oracle"
        url="jdbc:oracle:thin:@localhost:1521:XE" user="IPTECH" password="IPTECH" />

    <connection id="out" driver="postgresql"
        url="jdbc:postgresql://localhost:5432/gemodb" user="postgres"
        password="maher" />

    <connection id="janino" driver="janino" />
    <connection id="log" driver="script"></connection>

    <query connection-id="in">
        SELECT CODEARTICLE,STRUCTURE,
        DES,TYPEMARK,TYP,IMPLOC,MARQUE,GAMME,TAR
        FROM IPTECH.TMP_ARTICLE ;

        <query connection-id="out">
        select id from public.article_families ;

            <query connection-id="janino">
                import java.io.*;
                import java.lang.*;
                import
                org.apache.commons.lang3.StringUtils;
                import
                org.apache.commons.lang3.*;

                Boolean result= false ;

                Object obj =get("CODEARTICLE");
                if (StringUtils.isNumeric(obj.toString())) {

                <!-- System.out.println("ok "); -->
                result=true ;}
                else{
                result=false ;}
                set("result", result);
                next();

<!--                <query connection-id="out" if="result and ?id=?CODEARTICLE "> -->
                <query connection-id="out" if="result">

                    INSERT INTO public.articles
                    (id,
                    is_enabled,type_marketing,type_tarif,description,gamme,import_local,marque,reference,struct,family_id)
                    values
                    (cast(?CODEARTICLE as bigint)
                    ,'TRUE',?TYPEMARK,?TAR,?DES,?GAMME,?IMPLOC,?MARQUE,?CODEARTICLE,?STRUCTURE,cast(?{STRUCTURE.substring(0,
                    2)} as bigint));

            <script connection-id="janino" >
            </script>
                </query>
            </query>
        </query>
    </query>
</etl>