Android Question DBUtils, why the IDE warns for an unreachable code ?

Laurent95

Active Member
Licensed User
Longtime User
Hello,

Edit : It's not really due to DBUtils i think, but i want to use a modified DBUtils module in my code, that's why i put this title.

I have an interrogate.
I get a Warrning # 1 (Unreachable code detected) in the IDE when i uses this code
B4X:
Sub TestWarning1(SQL As SQL) As String
    SQL.BeginTransaction
    Try
        'Do anything you want
        SQL.TransactionSuccessful
        Return "Ok"
    Catch
        Return LastException.Message
    End Try
    SQL.EndTransaction
But in example given by SQL Library, it's exactly like that it's showed how to use Begin/EndTransaction.

I know i can ignore the warning, but if someone can tell me why ?
Thanks.

Laurent.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
but if someone can tell me why ?
You are calling
B4X:
SQL.EndTransaction
at the end of your sub. BUT you are using return statements...
B4X:
SQL.EndTransaction
will never be called in your code. You should place the EndTransaction in the line just before the return "OK"...
 
Upvote 0

Laurent95

Active Member
Licensed User
Longtime User
BUT you are using return statements...
B4X:
SQL.EndTransaction
will never be called in your code. You should place the EndTransaction in the line just before the return "OK"...

Thank you so much Manfred for the quick reply :cool:

That's evident, when i wrote the code i focused on another warning #2 (Not all code paths return a value), i think that's why i did this mistake :rolleyes:.

Mmmmmm, it seems sometime i will do better to do a little nap , already that i have difficulty to sleep actually :(.
.
 
Upvote 0
Top