Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Error Code

Status
Not open for further replies.

bx1423

Programmer
May 8, 2001
14
US
I am connecting to a Sybase database from a Paradox 4.5 application. I need to capture an error code from the server to determine if the password has expired or not. I know the error code, but how do I capture it? I have seen the SQLERRORCODE function in the PAL Reference, but it doesn't really say how to use it. Can anyone provide some assistance?

Thanks
 
bx1423,

I'd hoped someone with direct experience would chime in, but apparently not. So, I did some digging and found a couple of things you might find interesting.

1. Here's something that was once posted to the TOPIC database once used by Borland's Paradox Tech Support team:

Code:
   In an error procedure, if the user wants to test 
   for an errorcode e.g. 50000, the errorcode should be 
   converted to a string. Otherwise, the test fails.

   ; RIGHT
   If strval(sqlerrorcode()) = "50000" then

   ; WRONG
   If sqlerrorcode() = 50000 then

As you can see, it wasn't terribly complete, so I kept digging and ran across a demo script buried deep within Corel's FTP site (ftp://ftp.corel.com/pub/Paradox/PdoxDos/UnIndexed/pdoxdos/gen/insert.sc). It's old code that was originally posted to Borland's TechBBS, but it looks like it might have something useful for you.

Unfortunately, it seems to be too long to post here, however, here's the section you might find most relevant:

Code:
Proc Error_Handler()
DEBUG
; Show error On Screen
  Clear
   @3,15  ?? "E R R O R   S T A T U S"
   @8,7 ?? "      ErrorCode() = " + StrVal(ErrorCode())
   @9,7 ?? "   ErrorMessage() = " + ErrorMessage()
  @12,7 ?? "   SQLErrorCode() = " + StrVal(SQLErrorCode())
  @13,7 ?? "SQLErrorMessage() = " + SQLErrorMessage()

; Give user choice of COMMITTING or ROLLINGBACK the transaction

    ShowMenu
      "Commit"   : "Cleanup SQL environment by COMMITTING CHANGES ON SERVER",
      "RollBack" : "Cleanup SQL environment by ROLLINGBACK CHANGES ON SERVER",
      "Quit"     : "Rollback Transaction & QUIT Application"
    DEFAULT "Commit"
    To Choice

    Switch
    Case Choice = "Commit" :
      Message "Committing Changes On Server"
      SQLCOMMIT

    Case Choice = "RollBack" :
      Message "Rolling Back Changes On Server"
      SQLROLLBACK

    Case Choice = "Quit" :
      SQLROLLBACK
      SQLAUTOCOMMIT YES
      QUIT "Application aborted.  Transaction ROLLED BACK.."
    ENDSwitch

   RETURN 1
EndProc  ; Error_Handler

You should probably download the full script and review it in context.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top