根据是否存在外键使用 scriptella 复制数据
copy data using scriptella based on if a foreign key exists
我正在尝试将数据从一个 table 复制到另一个,但在这样做之前,我需要检查所选的代码文章是否已经作为键存在于另一个 table.So 我会复制它们,如果存在,我不会复制它们,如果不存在,我会记录它们
在这里我做了任何帮助来测试是否存在选定的代码文章。
这是我所做的
<?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>
任何帮助将不胜感激,非常感谢
<?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>
我正在尝试将数据从一个 table 复制到另一个,但在这样做之前,我需要检查所选的代码文章是否已经作为键存在于另一个 table.So 我会复制它们,如果存在,我不会复制它们,如果不存在,我会记录它们 在这里我做了任何帮助来测试是否存在选定的代码文章。
这是我所做的
<?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>
任何帮助将不胜感激,非常感谢
<?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>