on 01-30-2012 1:22 PM
Hi
I'm building a soap=>PI=JDBC synchronous interdace.
The JDBC select is getting rows from a VIEW on a MSSQL database
Due to the design of the View, my request is returning 4 rows, instead of 1.
Is there a way in mapping to remove the duplicate rows?
thank you
PS
I've tried useing DISTINCT but this only works if there is an ORDER BY in the sql, and there doesn't seem to be a way of putting this into XML SQL
Thanks for all the replies
Being new to PI I'm unsure which node to attach the UDF too
My message structure is
<row> 1...Unbounded
<UPRN> 1
<Postcode> 1
do I attach the UDF to the <row> or the <UPRN>.
I've looked at changing my SQL call to include group by
but I cannot see where I could put this in the XML SQL message format
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
source filed >sort>UDF-->Target field
in ur case, define which fuled shuld be repeated like UPRN> 1,<Postcode> 1
uprn->sort->UDF->target fild
execution type of UDF is Allvalues of a context.
public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
ArrayList aList = new ArrayList();
aList.add(var1(0));
result.addValue(var1(0));
for(int i=1; i<var1.length; i++){
if(aList.contains(var1(i)))
continue;
else{
aList.add(var1(i));
result.addValue(var1(i));
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Better practice is to handle this issue using sql query itself. The problem is at the data side. can you please refer the below link?
http://www.simple-talk.com/sql/t-sql-programming/removing-duplicates-from-a-table-in-sql-server/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can also try using GROUP BY instead of ORDER BY in your query.
Hope this helps,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
>>>Is there a way in mapping to remove the duplicate rows?
yes of course - just put all of them into a hashmap with one key and and get it back from there as unique values
(so a simple UDF)
>>>I've tried useing DISTINCT but this only works if there is an ORDER BY in the sql, and there doesn't seem to be a way of putting this into XML SQL
you can use native SQL where you can put any SQL statement - have you tried that ?
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.