Error Find first/Last failed for table (565) when used in a METHOD of a CLASS

zeeshaan

New Member
Hi,

I am trying to run a program, where a method that is used in this class is defined.

Code:
CLASS classname:
  
  CONSTRUCTOR classname():
  method2().
  END CONSTRUCTOR.

  METHOD PRIVATE LOG method1():
  .....
  FIND FIRST tablename NO-LOCK.
  .....
  END METHOD.

  METHOD method2():
  method1().
  END METHOD.

END CLASS.

The only error i can see in the logs is Find first/Last failed for table (565).
I am using Openedge 10.2B on windows 7.

But the surprising part is, it works just fine on Windows XP machine. Does anyone knows what is the reason like too many databases are getting connected in one time. Or how can I resolve it.

Regards,
Zeeshaan
 
Last edited by a moderator:

RealHeavyDude

Well-Known Member
Most likely the error is not in the code ( although I have to state that I hate FIND FIRST - it is just bad practice, maybe Tom wants to step in on this ... ). Your environment is not the same. If the FIND statement fails then I suspect there is no record in the table in the database you connect to from the XP machine.

Is it the same database(s) that you connect to both from the Windows 7 and XP machine?

Heavy Regards, RealHeavyDude.
 

zeeshaan

New Member
RealHeavyDude,
It is the same DB, I connect to from both Windows 7 and XP. There are also records in the DB, which are retrieved from XP machine and the program runs just fine. From Windows 7 machine it gives the error.

Regards,
Zeeshaan
 

RealHeavyDude

Well-Known Member
I've never seen the OS ( Windows XP vs. 7 ) make a difference in that regard. I am still thinking that your environments are setup differently - connecting to different databases. If they were not I would consider this a critical bug and you should get in touch with tech support.


Heavy Regards, RealHeavyDude.
 

zeeshaan

New Member
I changed the class file to a procedure and contents of the constructor as main block. The methods that I made changed them to Functions. It just worked without giving any errors.

A while ago, while working with classes I had some problem too, a 1.cls file called another 2.cls file and the instance of the 2.cls file was created in a .p file. This was also giving some errors, I exaclty don't remember the errror. I removed the 2.cls file and adjusted the first 1.cls file to include the second one.
 

RealHeavyDude

Well-Known Member
Most probably you were running into a buffer scope issue. If you do finds on the same table in different parts of your software without using named buffers you might wind up facing all sorts of issues. I always strongly recommend the usage of named buffers for database tables and temp-tables. You scenario is a perfrect use case why it might be dangerous to use the default buffer that comes with a database table or a temp-table.

You can define a buffer for any table:
Code:
define buffer b_MyTable for MyTable.
and then strong-scope it:
Code:
do for b_MyTable:
  /* Your stuff goes here */
end.

This should help you.

Heavy Regards, RealHeavyDude.
 

zeeshaan

New Member
RealHeavyDude,

I created a buffer for the table for which I was getting the error before.

define buffer buf_table for tab_name.

for each other_table:
find table buf_table

/* Other code */
end.

But now the error I get is:
Disconnect from Server; DB is shut down (2659)
 

RealHeavyDude

Well-Known Member
Your code seems odd to me for several reasons:
  • You are not specifying any lock - are these temp-tables?
  • It is not syntactically correct because you are missing the dot at the end of the find statement.
  • What is the purpose of doing a find without any where criteria on the same table over which you loop without any where criteria.
You don't reveal the code that gets executed in the for each iteration.

The error message states that the database was shut down ( either on purpose or it shut itself down ) during execution of your code. In theory one should not be able to crash a database with ABL code - but I have been able to reproduce cases with particular code with particular versions of Progress OpenEdge down to the patch level that was able to crash a database under certain circumstances. Either way, you need to find out as to why the database was shut down. For that you need to have a look into its log file.

Heavy Regards, RealHeavyDude.
 

zeeshaan

New Member
RealHeavyDude,

I used NO-LOCK but here on blog I just did not mention it. I also missed the dot at the end of the find statement here on the blog to show the pseudocode of the program structure I made.

The code below is the exact method I have made in the class.

Code:
&GLOBAL-DEFINE PAUZETIJD 1
METHOD PRIVATE LOG checkKAD():
 
        DEF VAR lat#     AS DEC  NO-UNDO.
        DEF VAR lng#          AS DEC  NO-UNDO.
        DEF VAR Address# AS CHAR NO-UNDO.
        DEF VAR resval#     AS LOG  NO-UNDO.
        DEF VAR melding# AS CHAR NO-UNDO.
        DEF VAR save#       AS LOG  NO-UNDO.
        DEF BUFFER altkad FOR kad.

       /* FIND FIRST sys no-lock. */
        DEF BUFFER altsys FOR sys.
    

        FOR EACH kad WHERE kad.kadlong = 0 AND kad.kadlat = 0, FIRST lnd OF kad NO-LOCK BY kad.klanr BY kad.kadvlgnr:
            FIND FIRST altsys NO-LOCK.
            Address# = IF altsys.sysuni = 89 THEN
                           SUBSTITUTE("&1 &2 &3 &4", kad.kadstr, kad.kadwplts, kad.kadpc, TRIM(lnd.lndnaam))
                       ELSE
                           SUBSTITUTE("&1 &2 &3 &4 &5", kad.kadstr, kad.kadstr2, kad.kadwplts, kad.kadpc, TRIM(lnd.lndnaam)).
            resval# = coor:checkAdres(Address#, OUTPUT lat#, OUTPUT lng#, OUTPUT melding#, OUTPUT save#).
            IF melding# <> "" AND lat# = 603 THEN
                loggen:writeLog(5,  "kad:" + Address# + ":" + STRING(lat#) + ":" + melding#).
            ELSE IF melding# <> "" THEN
                loggen:writeLog(1,  "kad:" + Address# + ":" + STRING(lat#) + ":" + melding#).
            ELSE
                loggen:writeLog(10, "kad:" + Address# + ":" + STRING(lat#) + ":" + STRING(lng#) + ":success").
            IF resval# = FALSE THEN
                RETURN FALSE.

            IF save# THEN
            DO:
                FIND FIRST altkad WHERE ROWID(altkad) = ROWID(kad) EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
                IF AVAILABLE(altkad) THEN
                    ASSIGN
                        altkad.kadlat  = lat#
                        altkad.kadlong = lng#.
                RELEASE altkad.
            END.
            PAUSE {&PAUZETIJD} NO-MESSAGE.
        END.
        RETURN TRUE.
    END METHOD. /* checkKAD */

This is the method which has the table sys used in it. This gave the original error " FIND FIRST/LAST FAILED FOR TABLE sys " Then I created the buffer for that table sys as you(RealHeavyDude) advised. Then I get the " Disconnect from Server; db is shutdown " .

These error messages I see them in the log file after the program is run.
 

zeeshaan

New Member
The error that I see in the logs is:
[14/05/21@16:11:05.021+0200] P-015484 T-016708 1 4GL -- Log entry types activated: 4GLMessages
[14/05/21@16:11:13.045+0200] P-015484 T-016708 1 4GL -- (Procedure: 'checkODH mapsbatch .getCoordinates' Line:113) Disconnect from server; database is being shutdown. (2659)
Line 113 I have shown in the code.
The method checkODH is :

Code:
METHOD PRIVATE LOG checkODH():
  
  DEF VAR lat#  AS DEC  NO-UNDO.
  DEF VAR lng#  AS DEC  NO-UNDO.
  DEF VAR Address# AS CHAR NO-UNDO.
  DEF VAR resval#  AS LOG  NO-UNDO.
  DEF VAR melding# AS CHAR NO-UNDO.
  DEF VAR save# AS LOG  NO-UNDO.

  DEF BUFFER altodh FOR odh.

   /* The line 113 where it is showing the DB is shut down is below line */
  /* line 113 :  */ FOR EACH odh USE-INDEX Cust-order WHERE odh.odhlongaf = 0 AND odh.odhlataf = 0 NO-LOCK:
  IF (odh.odhlndaf > 0) THEN
  FIND FIRST lnd WHERE lnd.lndnr = odh.odhlndaf.
  Address# = SUBSTITUTE("&1 &2 &3 &4 &5", odh.odhstraf, odh.odhstraf2, odh.odhwplaf, odh.odhpcaf, IF (odh.lndnaamaf <> "") THEN odh.lndnaamaf ELSE TRIM(lnd.lndnaam)).
  resval# = coor:checkAdres(Address#, OUTPUT lat#, OUTPUT lng#, OUTPUT melding#, OUTPUT save#).
  IF melding# <> "" AND lat# = 603 THEN
  loggen:schrijfLog(5,  "odh:" + Address# + ":" + STRING(lat#) + ":" + melding#).
  ELSE IF melding# <> "" THEN
  loggen:schrijfLog(1,  "odh:" + Address# + ":" + STRING(lat#) + ":" + melding#).
  ELSE
  loggen:schrijfLog(10, "odh:" + Address# + ":" + STRING(lat#) + ":" + STRING(lng#)).
  IF resval# = FALSE THEN
  RETURN FALSE.

  IF save# THEN
  DO:
  FIND FIRST altodh WHERE ROWID(altodh) = ROWID(odh) EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
  IF AVAILABLE(altodh) THEN
  ASSIGN
  altodh.odhlat  = lat#
  altodh.odhlong = lng#.
  RELEASE altodh.
  END.
  PAUSE {&PAUZETIJD} NO-MESSAGE.
  END.
  RETURN TRUE.
  END METHOD. /* checkODH */
 
Top