Java 基于是否存在外键,使用scriptella复制数据

Java 基于是否存在外键,使用scriptella复制数据,java,scriptella,janino,Java,Scriptella,Janino,我正在尝试将数据从一个表复制到另一个表,但在执行此操作之前,我需要检查所选的codearticle是否已作为键存在于另一个表中。因此,如果存在,我将复制它们,而不会复制它们,如果不存在,则记录它们 在这里,我做了一些有助于测试所选代码项目是否存在的工作 这就是我所做的 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&g

我正在尝试将数据从一个表复制到另一个表,但在执行此操作之前,我需要检查所选的codearticle是否已作为键存在于另一个表中。因此,如果存在,我将复制它们,而不会复制它们,如果不存在,则记录它们 在这里,我做了一些有助于测试所选代码项目是否存在的工作

这就是我所做的

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <description>
        test script Pour table ARTCAB
    </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" />
    <query connection-id="in">
        select CODEART,CAB from IPTECH.TMP_ARTCAB ;
        <query connection-id="out">
            select id from public.articles ;

            <query connection-id="janino">
                import java.io.*;
                import java.lang.*;
                Boolean result= false ;
                Object objGold =get("CODEART");
                Object objLocal =get("id");
                if(objGold.equals(objLocal))
                {

                System.out.println("equals);

                result=true ;}
                else{
                System.out.println("not equal");

                result=false ;
                }
                set("result", result);
                next();


                <script connection-id="out" if="result">

                    INSERT INTO public.cabarticle
                    (id ,
                    is_enabled,cab_article,article_id) values (1, TRUE,cast(?CAB
                    as
                    bigint),cast(?CODEART as bigint));


                </script>

            </query>
        </query>
    </query>
</etl>

测试脚本浇注表ARTCAB
从IPTECH.TMP_ARTCAB中选择CODEART,CAB;
从public.articles中选择id;
导入java.io.*;
导入java.lang.*;
布尔结果=假;
objectobjgold=get(“CODEART”);
对象objLocal=get(“id”);
if(objGold.equals(objLocal))
{
System.out.println(“等于”);
结果=真;}
否则{
System.out.println(“不相等”);
结果=假;
}
设置(“结果”,结果);
next();
插入到public.com中
(id),
是否启用,cab\U项目,项目id)值(1,TRUE,强制转换(?cab
作为
bigint),铸造(?CODEART作为bigint));
非常感谢您的帮助


<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <description>
        test script Pour table ARTCAB
    </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" url="./logging.log" />
    <connection id="janino" driver="janino" />
        <query connection-id="out">
        select id from public.articles
        <query connection-id="in">
            select CODEART,CAB from IPTECH.TMP_ARTCAB
            <query connection-id="janino">
                set("result",get("id").equals(get("CODEART")));
                next();
                <script connection-id="out" if="result">
                    INSERT INTO public.cabarticle
                    (is_enabled,cab_article,article_id)
                    values
                    (TRUE,cast(?id as bigint),?id)
                </script>
                <script connection-id="log" if="!result">
                    $CODEART,$CAB n'ont pas été copiés
                </script>
            </query>
        </query>
    </query>

</etl>
测试脚本浇注表ARTCAB 从public.articles中选择id 从IPTECH.TMP_ARTCAB中选择CODEART,CAB set(“result”,get(“id”).equals(get(“CODEART”)); next(); 插入到public.com中 (是否已启用,cab\U项目,项目id) 价值观 (正确,强制转换(?id为bigint),?id) $CODEART,$CAB n'ont pasétécopiés