Strange message

Strange message

Postby hag » Wed Oct 21, 2009 5:53 pm

I have a user who received the following error
Code: Select all  Expand view
Application
===========
   Path and name: E:\Spectral\Cash Flow\cashver3.exe (32 bits)
   Size: ********* bytes
   Time from start: 0 hours 1 mins 49 secs
   Error occurred at: 10/21/09, 11:50:12
   Error description: Error DBCMD/2001  Workarea not in use: ORDCREATE

Stack Calls
===========
   Called from:  => ORDCREATE(0)
   Called from: source\rdd\rddord.prg => DBCREATEINDEX(59)
   Called from: .\CASHVER3.PRG => GLOBAL1(2378)
   Called from: .\CASHVER3.PRG => MSCREEN2(802)


The error occurs at this line

use (exptyd) alias expty new
index on expty->prod_num to expty <<<<< here

How is it posible the work area no in use when the above line opens it?
This happens once in a while.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Strange message

Postby hua » Thu Oct 22, 2009 8:03 am

Harvey,
I believe the error message itself is self-explanatory. Your attempt to "use" a dbf obviously failed. It could be that the user runs more than 1 instance of your program or some other part of your program already has it opened or some other reasons.

That's why I normally open my dbf using a wrapper function that'll be able to let me know whether an attempt to open a dbf is successful or not. Here's a code snippet

Code: Select all  Expand view

#include "fivewin.ch"
#define  NET_WAIT    .05
#define  NET_SECS    5

function main()
  set exclusive off
  begin sequence
     if net_use("customer", .f.)
        set index to customer
     else
        break
     endif
     if net_use("invoice", .f.)
        index on inv to invoice
     else
        break
     endif
  recover
     dbCloseAll()
     msgstop("Can't proceed. Some data file can't be opened. Aborting...")
    return nil
  end

  // continue with the rest of the program
  .
  .
return nil  
//-----------------------------------------------------------------------------------------
function Net_Use( cDatabase, lOpenMode, nSeconds, cAlias, lRandom )

   LOCAL lForever                      // Retry forever?
   LOCAL lReturn:= .f.

   DEFAULT nSeconds := NET_SECS
   default lRandom := .f.

   lForever := ( nSeconds == 0 )
   if lRandom // auto-generate a random alias for user
      cAlias := tempfile() // generate a random alias
   endif

   /* Keep trying as long as our time''s not up  */

   while ( lForever .or. ( nSeconds > 0 ) )

      IF lOpenMode
         dbUseArea(.t.,, cDatabase, cAlias, .f. )
      else
         dbUseArea(.t.,, cDatabase, cAlias, .t. )
      ENDIF

      IF !neterr()
         lReturn := .t.
         exit
      ELSE
         IF !MsgYesNo( "Cannot open file '" + UPPER(cDatabase) + ".DBF'. Retry?" )
            lReturn := .f.
            Exit
         ENDIF
      ENDIF

      inkey( NET_WAIT )                // Wait

      nSeconds -= NET_WAIT

   ENDDO

RETURN( lReturn )
 
Last edited by hua on Fri Oct 23, 2009 1:20 am, edited 1 time in total.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1052
Joined: Fri Oct 28, 2005 2:27 am

Re: Strange message

Postby hag » Thu Oct 22, 2009 6:02 pm

Hua:
thank you for your response. I clearly understand the process and the code you sent me.

However I'm confused because if I attempted to open the database which is already open I would get an error message and it would not allow me to reopen the database.

So if it allows me to open the database here without an error message:
Use (expty) alias expty new
then why on the next line when I'm indexing the database would it tell me that database is not open.
There is no other copy of the program running and this is at the very beginning of the program so the database has not been opened and closed. It just happens for what appears to be no apparent reason.

Actually I've had several concerns because the following code has also told me the database is not open I'll show you lines 1 line blows out the other does not.

gl->(dbseek())
gl->ty1 := var
gl->(dbseek()) <<<< tells me work area NOT in use???????

Any thoughts?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Strange message

Postby Jonathan Hodder » Thu Oct 22, 2009 9:39 pm

Hi Harvey,

Hua has the correct method updated for win.
This method goes way back to early clipper days.
The neterr() function is what u need to test for.
From Clipper manual

This example opens a shared database file with associated
index files in a network environment. If NETERR() returns false

(.F.), indicating the USE was successful, the indexes are opened:

USE Accounts SHARED NEW
IF !NETERR()
SET INDEX TO AcctNames, AcctZip
ELSE
? "File open failed"
BREAK
ENDIF

Put in neterr() after 'use' it will return a true or false.
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Re: Strange message

Postby hag » Thu Oct 22, 2009 9:51 pm

Thanks for the response.
Are you saying that you can open a file get no error message but the file is not open so there needs to be a test to see if it opened correctly.
So in the example I gave on one line it was open but on the next line it wasn't How is that possible. In this example I'm not opening a database its already been opened yet its ok on one line of code then the next no good.

This was the example:
gl->(dbseek()) <<<<<< it works
gl->ty1 := var <<<<<< it works
gl->(dbseek()) <<<< tells me work area NOT in use???????

That seems odd to me.
When I was using old fw192 it never happened only after the conversion to fwh.

Very strange
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Strange message

Postby TecniSoftware » Thu Oct 22, 2009 9:52 pm

hag wrote:
The error occurs at this line

use (exptyd) alias expty new
index on expty->prod_num to expty [b]<<<<< here[/b]

How is it posible the work area no in use when the above line opens it?
This happens once in a while.


Don´t include the alias in the key expresion, just:

index on prod_num to expty

Regards
Alejandro Cebolido
Buenos Aires, Argentina
User avatar
TecniSoftware
 
Posts: 235
Joined: Fri Oct 28, 2005 6:29 pm
Location: Quilmes, Buenos Aires, Argentina

Re: Strange message

Postby hua » Fri Oct 23, 2009 1:39 am

Harvey,

hag wrote:Are you saying that you can open a file get no error message but the file is not open so there needs to be a test to see if it opened correctly.


That has happened to me before and the reason why I make it a point to never use USE on its own. I'm not really sure what's causing you to see the errors that you're getting but I very much doubt the cause is somewhere in the [x]Harbour's RDD itself. If that was the case, there'd reports from a lot of other programmers.

Unless you can come up with some self-contained example that demonstrates the error, I've no further idea on how to approach this, sorry :( I do recommend for the time being you replace all standalone USE with net_use() first, give that to your customer and wait and see if the error recurs. For all we know, the error might be due to some sort of network lag but I'm just guessing here.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1052
Joined: Fri Oct 28, 2005 2:27 am

Re: Strange message

Postby James Bott » Fri Oct 23, 2009 5:06 am

Harvey,

use (exptyd) alias expty new
index on expty->prod_num to expty <<<<< here

How is it posible the work area no in use when the above line opens it?


Correction, the above line attempts to open it. If it is unsuccessful in opening it, there will not be any error message. As others have mentioned, you have to check neterr() to find out if there was an error in attempting to open the file. Otherwise, you will get an error message on the next line as you found out.

In this example I'm not opening a database its already been opened yet its ok on one line of code then the next no good.

This was the example:
gl->(dbseek()) <<<<<< it works
gl->ty1 := var <<<<<< it works
gl->(dbseek()) <<<< tells me work area NOT in use???????


I think you must be oversimplifiying your example. I have been programming in xBase since it was invented in the early 80's and I have never seen anything like your example.

So, you have to write your programs to handle the possiblity that the desired database won't be successfully opened.

Alternately, my TData class automatically handles file open errors and makes automatic retrys. This makes your work much easier.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Strange message

Postby hag » Fri Oct 23, 2009 3:25 pm

Ill be outof town for about 5 days and get back to the discussion at that time. Thanks all for the help.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto and 43 guests