Resolved 7325

Hi everyone,

While doing some dynamic query I get the following error message while performing the query-prepare at runtime :

'QUERY-PREPARE' need to have one 'FOR EACH/PRESELECT' for each buffer memory of the query

This is my code:
Code:
dispQuery:SET-BUFFERS(BUFFER FGSERV:HANDLE,BUFFER SACDPE:HANDLE,BUFFER SDTFOE:HANDLE,BUFFER VAFDAI:HANDLE,BUFFER VFGDAI:HANDLE) .
    dispQuery:QUERY-PREPARE("FOR EACH FGSERV WHERE FGSERV.fgsign = 'user' NO-LOCK," +
                                "EACH SACDPE WHERE SACDPE.stecod = '" + c-stecod + "' " +
                                "            AND   SACDPE.dpeutidem MATCHES '" + fiUtidem + "' " +
                     (IF fiDatdeb <> ? THEN "AND   SACDPE.dpedatdem >= " + STRING(fiDatdeb) + " " ELSE "") +
                     (IF fiDatfin <> ? THEN "AND   SACDPE.dpedatdem <= " + STRING(fiDatfin) + " " ELSE "") +
                                "            AND   SACDPE.foucod    MATCHES '" + fiFoucod + "' NO-LOCK," +
                                "EACH SDTFOE WHERE SDTFOE.foucod = SACDPE.foucod NO-LOCK," +
                                "EACH VAFDAI OUTER-JOIN WHERE VAFDAI.danum = SACDPE.acddemnum NO-LOCK" ) .
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
You set BUFFER VFGDAI:HANDLE as a buffer for your query but it is not a part of the FOR statement in your QUERY-PREPARE.
 
Thank you Rob. I was totally blind......
 
One more questio @Rob Fitzpatrick if you can.

Because I use OUTER-JOIN, sometimes I know that I will have "?" value when display the VAFDAI.
I would like to be able to prompt a blank like "" if possible.

I add the column like this:
Code:
DEFINE VARIABLE myCol AS HANDLE      NO-UNDO.

ASSIGN
    myBr = BROWSE-5:HANDLE IN FRAME F-Main
    myBr:QUERY = dispQuery
    myCol = myBr:ADD-LIKE-COLUMN("FGSERV.fgserv":U)
    myCol:LABEL = "Section"
    myCol:WIDTH-PIXELS = func-WidthColumn(myCol) + 30
    myCol = myBr:ADD-LIKE-COLUMN("SACDPE.acddemnum":U)
    myCol:LABEL = "Num DA"
    myCol:WIDTH-PIXELS = func-WidthColumn(myCol) + 30
    myCol = myBr:ADD-LIKE-COLUMN("SACDPE.dpedatdem")
    myCol:LABEL = "Date DA":U
    myCol:WIDTH-PIXELS = func-WidthColumn(myCol) + 30
    myCol = myBr:ADD-LIKE-COLUMN("SACDPE.dpeutidem")
    myCol:LABEL = "Demandeur":U
    myCol:WIDTH-PIXELS = func-WidthColumn(myCol) + 30
    myCol = myBr:ADD-LIKE-COLUMN("VAFDAI.dainum")   
    myCol:LABEL = "DAI"
    myCol:WIDTH-PIXELS = func-WidthColumn(myCol) + 30
    myCol = myBr:ADD-LIKE-COLUMN("VFGDAI.dailib1")
    myCol:LABEL = "Lib. DAI"
    myCol:WIDTH-PIXELS = func-WidthColumn(myCol) + 30 .

Also I will maybe want to add some column calculate from a function .
Is there a way to do it ?

Or will I be obliged to used static query & browse ?

Best Regards,

- Vivien -
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
One more questio @Rob Fitzpatrick if you can.
Sorry Vivien, I don't have experience with dynamic browses or outer-join queries. I'll defer to someone else with relevant experience.
 
Ok I will create another thread to that. It will be more accurate .
 
Top