java - copy data using scriptella based on if a foreign key exists -
i trying copy data table , before doing , need check whether selected codearticle exists keys in table.so copy them if exists , , won't copy them , if not existing log them here did test if selected codearticle exists or not .
here did
<?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 iptech.tmp_artcab ; <query connection-id="out"> select id 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 public.cabarticle (id , is_enabled,cab_article,article_id) values (1, true,cast(?cab bigint),cast(?codeart bigint)); </script> </query> </query> </query> </etl> any appreciated, lot
<?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 public.articles <query connection-id="in"> select codeart,cab iptech.tmp_artcab <query connection-id="janino"> set("result",get("id").equals(get("codeart"))); next(); <script connection-id="out" if="result"> insert public.cabarticle (is_enabled,cab_article,article_id) values (true,cast(?id bigint),?id) </script> <script connection-id="log" if="!result"> $codeart,$cab n'ont pas été copiés </script> </query> </query> </query> </etl>
Comments
Post a Comment