QUOTER in a dynamic query

Posted by Doug MacMillan on 19-Oct-2016 18:22

given this static query

def var vDelimiter as char initial ",".
find first foo no-lock where entry(2,foo.fld1,vDelimiter) eq "blah" no-error.

how can I translate into dynamic query?

e.g.

h_foo = buffer foo:handle.

h_foo:find-first(" where entry(2,foo.fld1,vDelimiter EQ 'blah' ",no-lock) no-error. /* this does not work */

/* update */

figured it out - this seems to work

h_ediDetail:FIND-FIRST(

"WHERE icControlNum EQ 7156158 AND txSeqNum EQ 1 " + "AND entry(2,segment," + QUOTER(vDelim) + ") EQ '834' ",NO-LOCK)

NO-ERROR.

All Replies

Posted by marian.edu on 19-Oct-2016 23:50


h_foo:find-first(substitute("where entry(2, foo.fld1, &1) EQ &2“, quoter(vDelimiter), quoter(‘blah’)), no-lock) no-error. 


Marian Edu

Acorn IT 
+40 740 036 212

Posted by Doug MacMillan on 20-Oct-2016 06:20

Excellent.  Thanks.  Forgot about the substitute command...  

Posted by Peter Judge on 20-Oct-2016 07:44

You should never forget about the SUBSTITUTE() statement. It’s one of your best friends (especially if you may have unknown values)

This thread is closed