SqlError?

Discussion forum about all things TD Mobile.
FRBhote
India
Posts: 1230
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

SqlError?

Post by FRBhote » 24 Apr 2018, 05:15

What's the most convenient way to trap Sql errors? From what I see, every statement should be preceded by a When Sqlerror, and every Invoke should be succeeded by a call error dialog when error.

Funny part is that a Prepare does not give an error, while an execute says Prepare error.

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2167
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

SqlError?

Post by Jeff Luther » 25 Apr 2018, 16:02

Here's my 2 cents, FR:

You wrote to ask
What's the most convenient way to trap Sql errors?
That depends on the error, I'd think. I used to teach -- as a general rule of thumb -- that for SQL errors for specific SAL code, like a "non-unique key" error on an insert, etc. you'd trap that locally with When SqlError so you could allow for retries if that was appropriate. For general-type errors, like an Invalid Connection error and so on, you'd trap that globally and use On SAM_SqlError.

You also wrote that the
Funny part is that a Prepare does not give an error, while an execute says Prepare error.
That's odd. Are you sure you have a separate a When SqlError above the If SqlPrepare? And if that succeeds, a separate When SqlError above the (I'd guess next Sql line) If SqlExecute?
I'd think that if you "seLLect <something>..." (with 2 'L's) that the DB compiler would throw an "invalid syntax" or similar error on the SqlPrepare. Or maybe it depends on the DB brand at that backend??
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

FRBhote
India
Posts: 1230
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

SqlError?

Post by FRBhote » 26 Apr 2018, 05:17

Unfortunately, there's no On Sqlerror in TDM. Only a When Sqlerror before every statement.

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 770
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

SqlError?

Post by Igor Ivanovic » 26 Apr 2018, 07:18

Yep, pity, but there is no SAM_SqlError in TDM.
AFAIK our only option is "When SQLError" for now and I don't know if any improvements are planned in this area.

I do have a global function that is called to log an SQL Error, but still need to use the When SQL clause.

Regarding this, how do you return an error to the client from the operation?
If there is no "when sql", the client gets informed by an ugly looking error, but if I catch it - it doesn't and I didn't find a way to throw my own message to the client.
Igor Ivanovic
Image

FRBhote
India
Posts: 1230
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

SqlError?

Post by FRBhote » 26 Apr 2018, 11:10

In every class, there is a cErr subclass.

And after every Operation, I am checking class.cErr.nErr.

If greater than zero, then a error dialog box. Very tedious..

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 770
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

SqlError?

Post by Igor Ivanovic » 26 Apr 2018, 13:25

I have a similar solution also, but was hoping for an easier way.
As you say, it's really very tedious... :cry: :cry: :cry:
Igor Ivanovic
Image

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2167
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

SqlError?

Post by Jeff Luther » 26 Apr 2018, 15:20

OOPS... :oops: Sorry, FR! Didn't catch the "TD Mobile" topic heading. That *is* tedious indeed
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests