That's exactly what this function does. It finds all tariffs that prefix-match and sort them by their prefix length - then we pick the first row and this is the result. ----- Original Message ----- From: "Ganbold" <ganbold@xxxxxxxxxxxxx> Sent: Friday, November 03, 2006 5:40 AM Subject: match_tariff problem > Hi, > > I'm having trouble matching tariff using sqlbill in gnugk-2.2.5 updated > from cvs few days ago. > I checked match_tariff function and it checks first exact match and then > if no exact match it continues further. > And then the following query tries to find tariff destination. I put > real values in places and tried to run query: > > SELECT INTO dst.id, dst.active, trf.id D.id, D.active, T.id FROM > voiptariffdst D LEFT JOIN voiptariff T ON T.dstid = D.id LEFT JOIN > voiptariffgrp G ON T.grpid = G.id LEFT JOIN voiptariffsel S ON S.grpid = > G.id WHERE NOT D.exactmatch AND ('089881038983560' LIKE (D.prefix || > '%')) AND NOT T.terminating AND T.currencysym = 'USD' AND (T.grpid IS > NULL OR S.accountid = 1) ORDER BY length(D.prefix) DESC, > COALESCE(G.priority,-2147483648) DESC LIMIT 1; > > I don't understand here ('089881038983560' LIKE (D.prefix || '%')) part. > It doesn't match here. > In my opinion it should be something like: match longest possible prefix. > > Is it possible to do this? Can you help me in this regard? > > thanks a lot, > > Ganbold ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________________ Posting: mailto:Openh323gk-users@xxxxxxxxxxxxxxxxxxxxx Archive: http://sourceforge.net/mailarchive/forum.php?forum_id=8549 Unsubscribe: http://lists.sourceforge.net/lists/listinfo/openh323gk-users Homepage: http://www.gnugk.org/