Skip to main content

How to make a join with scripting - Criteria problem

Hi!!
While I was studying, i tried to make a join between 2 databases that I already have both IMD files.
I have a criteria inside IDEA, but I can't use the same criteria using IdeaScripting..
Would you mind helping me to fix it? Please!
 
Set db = Client.OpenDatabase("SR3_STEP1.IMD")
Set task = db.JoinDatabase
task.FileToJoin "SR3_STEP2.IMD"
task.IncludeAllPFields
task.AddSFieldToInc "ID_SR"
task.AddMatchKey "USUÁRIO", "USUÁRIO", "A"
task.Criteria = "(@Ctod(VALIDO_ATÉ;(""YYYYMMDD""))  >= @Ctod(DATAEXTRACAO;(""YYYYMMDD""))  .OR. @Ctod(VALIDO_ATÉ;(""YYYYMMDD"")) = ""00000000"") .AND. BLOQ =""""  .AND. (TIPO=""A""  .OR. TIPO=""S"")"
task.CreateVirtualDatabase = False
dbName = "Join Databases.IMD"
task.PerformTask dbName, "", WI_JOIN_MATCH_ONLY
Set task = Nothing
Set db = Nothing
Client.OpenDatabase (dbName)
 
My Problem is my task.Criteria.
I tried something like: 
task.Criteria = "(@Ctod(VALIDO_ATÉ;("&"YYYYMMDD" &"))  >= @Ctod(DATAEXTRACAO;("&"YYYYMMDD"&"))  .OR. @Ctod(VALIDO_ATÉ;("&"YYYYMMDD"&")) = "&"00000000"&") .AND. BLOQ ="&"  .AND. (TIPO="&"A"&"  .OR. TIPO="&"S"&")"
But i get an error - A valid equation is required for this field.
If i do it by my self inside IDEA, it works.. but I want to make it by scripting.
Thank you!!
 

marconb10 Wed, 05/20/2020 - 13:47

Already fixed it. I think my brain really hates when IDEA doesent change the color of the text when using quotation marks.

Brian Element Wed, 05/20/2020 - 16:43

Yes the editor can be a pain and gets mixed up.  What you had originally should work it just looks like there is a problem in the editor when there isn't.