Hello,
I am making a script to link data to a database. My script runs very well but I think it could be better and faster.
This is the complex part:
tell application "Adobe InDesign CS5"
tell EasyCatalog object
tell DataSource DataBron
set s to 1
set theSqlStatement to SqlQuery
repeat until s > number of theQuerynums
if s = 1 then
set theSqlStatement to theSqlStatement & " WHERE"
end if
if s > 1 then
set theSqlStatement to theSqlStatement & " OR"
end if
set theQueryCode to item s of theQuerynums
set Prodcode to get (characters 1 thru 4 of theQueryCode)
set whereStatement to " sap_code like '" & Prodcode & "" & "%' "
set theSqlStatement to theSqlStatement & whereStatement
set s to s + 1
end repeat
odbc connection statement theSqlStatement
synchronize with data source
end tell
try
tell DataSource DataBron
purge deleted
end tell
end try
end tell
The problem is that “theQueryCode” can be the same, so the final statement could be
… where sap_code like ‘SENW.%’ or sap_code like ‘SENW.%’ or sap_code like ‘SENW.%’ or sap_code like ‘SENW.%’ or sap_code like ‘SENW.%’
My question is: Is it possible to write some lines to detect if there are same “theQueryCode” so the whereStatement doesn’t has to repeat the same “theQueryCode”?
I hope my question is clear :rolleyes:
thanks in advanced