Dynamic Buffer, No-Error

bergerpeatmoss

New Member
Hi guy's,

I just found this forum and I have a question for you !

In one of my program I have a dynamic buffer on a table and I made a find first on it with a no-error statement.

My problem is that, most of the time, I receive a message which said to me that "Find first/last as fail ... " I tought that with the NO-ERROR statement I'm not suppose to have that message ?

If I click ok on the alert box, it's all goes OK and the rest of the code is apply and it's all goes right ... is there a way to hide those messages ?
 
Code:
         FOR EACH bf_invquotevend WHERE bf_invquotevend.no_quote = pool.invquote.no_quote NO-LOCK:
       
        ASSIGN v_err_query_quotevd = h_bf_arclientvd:FIND-FIRST("WHERE ":U  + h_bf_arclientvd:BUFFER-FIELD("no_client":U):NAME +
                                                 " = ":U +  QUOTER(v_cd_client) + "AND ":U + h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):NAME + " = ":U  
                                                 + QUOTER(bf_invquotevend.no_vendeur), EXCLUSIVE-LOCK) NO-ERROR.

        / *I'VE GOT THE ERROR HERE, WHEN I PRESS OK THE REST OF THE CODE IS EXECUTED WITHOUT ANY PROBLEM */

        IF v_err_query_quotevd THEN DO:   
            IF v_traitement = "ASSIGN":U THEN DO:
                 ASSIGN h_bf_arclientvd:BUFFER-FIELD("charge_cpt":U):BUFFER-VALUE = bf_invquotevend.charge_cpt.
                 IF bf_invquotevend.charge_cpt = TRUE THEN DO:
                    ASSIGN h_bf_arclient:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE  = bf_invquotevend.no_vendeur.
                END.
            END.
        END.
        ELSE DO:
             IF v_traitement = "VERIF":U THEN DO:
                ASSIGN v_modif = TRUE.
                RETURN.  
            END.
            ELSE IF v_traitement = "ASSIGN":U THEN DO:
                h_bf_arclientvd:BUFFER-CREATE().
                ASSIGN h_bf_arclientvd:BUFFER-FIELD("nr_arclientvd":U):BUFFER-VALUE = DYNAMIC-NEXT-VALUE("seq_arclientvd":U,h_bf_arclientvd:DBNAME)
                       h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE    = bf_invquotevend.no_vendeur
                       h_bf_arclientvd:BUFFER-FIELD("charge_cpt":U):BUFFER-VALUE    = bf_invquotevend.charge_cpt
                       h_bf_arclientvd:BUFFER-FIELD("no_client":U):BUFFER-VALUE     = v_cd_client.
                IF bf_invquotevend.charge_cpt = TRUE THEN DO:
                    ASSIGN h_bf_arclient:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE  = bf_invquotevend.no_vendeur.
                END.
            END.
        END.
    END.
 
My first thought is that the NO-ERROR is for the assign, not the find first. But I don't know if that's true.
 
hI, When you use a FIND EXCLUSIVE-LOCK, you must enclose within a transaction block.Try the following code attached to Sports2000, uncomment the block DO TRANSACTION.
Code:
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE lok  AS LOGICAL.


CREATE BUFFER hBuf FOR TABLE 'Customer'.


FOR EACH Order NO-LOCK.
    /*
    DO TRANSACTION:
    */
        lok = hbuf:FIND-FIRST('WHERE custNum = ' + 
                              STRING(order.custnum), EXCLUSIVE-LOCK) NO-ERROR.
    
        IF lok THEN
            MESSAGE 'Customer Encontrado' hBuf:BUFFER-FIELD('CustNum'):BUFFER-VALUE
                VIEW-AS ALERT-BOX.
        ELSE MESSAGE lok VIEW-AS ALERT-BOX.
    /*
    END.
    */
END.
Regards.
 
Code:
FOR EACH bf_invquotevend WHERE bf_invquotevend.no_quote = pool.invquote.no_quote NO-LOCK:
        DO TRANSACTION:
            ASSIGN v_err_query_quotevd = h_bf_arclientvd:FIND-FIRST("WHERE ":U  + h_bf_arclientvd:BUFFER-FIELD("no_client":U):NAME +
                                                     " = ":U +  QUOTER(v_cd_client) + "AND ":U + h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):NAME + " = ":U  
                                                     + QUOTER(bf_invquotevend.no_vendeur), EXCLUSIVE-LOCK) NO-ERROR.
            
            IF v_err_query_quotevd THEN DO:   
                IF v_traitement = "ASSIGN":U THEN DO:
                     ASSIGN h_bf_arclientvd:BUFFER-FIELD("charge_cpt":U):BUFFER-VALUE = bf_invquotevend.charge_cpt.
                     IF bf_invquotevend.charge_cpt = TRUE THEN DO:
                        ASSIGN h_bf_arclient:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE  = bf_invquotevend.no_vendeur.
                    END.
                END.
            END.
            ELSE DO:
                 IF v_traitement = "VERIF":U THEN DO:
                    ASSIGN v_modif = TRUE.
                    RETURN.  
                END.
                ELSE IF v_traitement = "ASSIGN":U THEN DO:
                    h_bf_arclientvd:BUFFER-CREATE().
                    ASSIGN h_bf_arclientvd:BUFFER-FIELD("nr_arclientvd":U):BUFFER-VALUE = DYNAMIC-NEXT-VALUE("seq_arclientvd":U,h_bf_arclientvd:DBNAME)
                           h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE    = bf_invquotevend.no_vendeur
                           h_bf_arclientvd:BUFFER-FIELD("charge_cpt":U):BUFFER-VALUE    = bf_invquotevend.charge_cpt
                           h_bf_arclientvd:BUFFER-FIELD("no_client":U):BUFFER-VALUE     = v_cd_client.
                    IF bf_invquotevend.charge_cpt = TRUE THEN DO:
                        ASSIGN h_bf_arclient:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE  = bf_invquotevend.no_vendeur.
                    END.
                END.
            END.
        END.
    END.
 
Try to check if the sintax is correct before FIND-FIRST and put a message after FIND-FIRST hBuf:AVAILABLE and hBuf:LOCKED.FIRST.

Code:
MESSAGE
"WHERE ":U + h_bf_arclientvd:BUFFER-FIELD("no_client":U):NAME  + " = ":U + 
             QUOTER(v_cd_client) + 
  "AND ":U + h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):NAME + " = ":U + 
             QUOTER(bf_invquotevend.no_vendeur)
    VIEW-AS ALERT-BOX.

Regards.
 
So, I put the message in place where you said to me ...

For the validation of the syntax, all the sentence seems to be OK ...

For the available I've got yes and no, it's depend if the record already exist or not.

For the lock I've got NO for all my record...
 
In the example I sent, the only way to reproduce the error that occurs is to remove the NO-ERROR to FIND FIRST statement.

Code:
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE lok  AS LOGICAL.
DEFINE VARIABLE iRec AS INTEGER.


CREATE BUFFER hBuf FOR TABLE 'Customer'.


DO TRANSACTION:


    FOR EACH Order NO-LOCK iRec = 1 TO 5.
        /*
        DO TRANSACTION:
        */
            lok = hbuf:FIND-FIRST("WHERE " + hbuf:BUFFER-FIELD('custNum'):NAME + " = " + IF iRec > 3
                                  THEN QUOTER(999999)
                                  ELSE QUOTER(STRING(order.custnum)), EXCLUSIVE-LOCK ) NO-ERROR.
        
            MESSAGE lok iRec  SKIP
                 'AVAILABLE' hbuf:AVAILABLE SKIP 
                 'LOCKED ' hbuf:LOCKED 
                 VIEW-AS ALERT-BOX.
    
            IF lok THEN
                MESSAGE 'Customer Encontrado' hBuf:BUFFER-FIELD('CustNum'):BUFFER-VALUE SKIP
                    VIEW-AS ALERT-BOX.
    
            hbuf:BUFFER-RELEASE.
        /*
        END.
        */
    END.
END.




I do not know what else to try.
Regards.
 
Yes it's exactly why I don't understand the problem ... it's seem that my program doesn't recognize the NO-ERROR statement and send my all the error in the find , which can be erase habitually with the NO-ERROR.
 
What version of Progress are you running? I can't seem to duplicate your problem. Also, I found your code hard to read, and consequently hard to debug. For what it's worth, here are a couple of suggestions that may (or may not) help you get to the bottom of your issue...

1. You appear to be missing a space before your AND in your query string - "AND ":U

2. You may want to use a local character variable for your query string, then you can message the variable to verify your query string is what you think.
Code:
DEFINE VARIABLE cQry AS CHARACTER   NO-UNDO.

ASSIGN cQry = "WHERE ":U  + h_bf_arclientvd:BUFFER-FIELD("no_client":U):NAME + " = ":U +  QUOTER(v_cd_client) + "AND ":U 
                  + h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):NAME + " = ":U  + QUOTER(bf_invquotevend.no_vendeur).

MESSAGE "cQry=" cQry SKIP
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

ASSIGN v_err_query_quotevd = h_bf_arclientvd:FIND-FIRST(cQry, EXCLUSIVE-LOCK) NO-ERROR.

3. Next, to make the code easier to read, < h_bf_arclientvd:BUFFER-FIELD("no_client":U):NAME > is the same as < 'no_client' >. Perhaps you have a reason for doing it your way, but the snippet above could be cleaned up a bit and changed like this:
Code:
DEFINE VARIABLE cQry AS CHARACTER   NO-UNDO.

ASSIGN cQry = "WHERE no_client = ":U +  QUOTER(v_cd_client) + " AND no_vendeur = ":U  + QUOTER(bf_invquotevend.no_vendeur).

MESSAGE "cQry=" cQry SKIP
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

ASSIGN v_err_query_quotevd = h_bf_arclientvd:FIND-FIRST(cQry, EXCLUSIVE-LOCK) NO-ERROR.

4. Also, when referring to dynamic buffer fields and values: < h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE > is the same as
< h_bf_arclientvd::no_vendeur >, so your assignment statement below would look like this:
Code:
--From this --
ASSIGN h_bf_arclientvd:BUFFER-FIELD("nr_arclientvd":U):BUFFER-VALUE =  DYNAMIC-NEXT-VALUE("seq_arclientvd":U,h_bf_arclientvd:DBNAME)
       h_bf_arclientvd:BUFFER-FIELD("no_vendeur":U):BUFFER-VALUE = bf_invquotevend.no_vendeur
       h_bf_arclientvd:BUFFER-FIELD("charge_cpt":U):BUFFER-VALUE = bf_invquotevend.charge_cpt
       h_bf_arclientvd:BUFFER-FIELD("no_client":U):BUFFER-VALUE = v_cd_client.

-- To this --
ASSIGN h_bf_arclientvd::nr_arclientvd = DYNAMIC-NEXT-VALUE("seq_arclientvd":U,h_bf_arclientvd:DBNAME)
       h_bf_arclientvd::no_vendeur    = bf_invquotevend.no_vendeur
       h_bf_arclientvd::charge_cpt    = bf_invquotevend.charge_cpt
       h_bf_arclientvd::no_client     = v_cd_client.

5. Finally - just throwing this out there - you seem to have a mix of static buffers, db tables AND dynamic buffers. Perhaps you could simplify everything by just changing over to a straightforward FIND? (where <TableName> is the database table of your dynamic buffer)
Code:
FIND FIRST <TableName> 
     WHERE <TableName>.no_client = QUOTER(v_cd_client)
       AND <TableName>.no_vendeur = QUOTER(bf_invquotevend.no_vendeur) EXCLUSIVE-LOCK NO-ERROR.
IF NOT AVAILABLE <TableName> THEN DO:
END.

Good luck!
 
I'm using 10.1C, I've try to correct the "space" before the " AND ":U it's won't help in my case.

For the rest I will try tomorrow morning ...

I can't use physical database in my case because i'm in a compagnie so I have to work with two different environment with the same program.
 
Based on your code, I believe your program is failing in the "if then else" after the FIND.

You set a local logical variable to true or false based on the results of the FIND. If the FIND is successful, you make some buffer assignments, if not successful, you also make some other buffer assignments to buffer fields in the failed FIND. Take a good look at the "else do:" as see if you don't agree.
 
He's OK there - he does a BUFFER-CREATE before those assigns.

Cringer had a good point. How DO you tell if that NO-ERROR applies to the ASSIGN or the METHOD?? Does it return errors from either statement?

...I can't use physical database in my case because i'm in a compagnie so I have to work with two different environment with the same program.
I'm not exactly sure what you mean by this, but check out the (-ld) STARTUP parameter...
 
Back
Top