Raise custom Database Exception from Advanced SQL
64
Views
4
Comments
New
Database

Hi,

I'm not sure if this is possible but I will share something that I just experienced.

I have a query that creates/updates data in several entities. This query has 200 lines which is heavy enough. I need 2/3 validations before doing this heavy CRUD, I would like to do that inside the Advanced SQL node and be able to output the error code and error message. As of today, the only error that comes out of a query is "Error executing query" which doesn't allow me to handle the error properly.

To accomplish those validations, I need to have more aggregates or even SQL nodes outside the heavy create/update which will increase even further the complexity of the action.


I'm not a fan of 200 lines of sql in a single node (and you are going to add even more)  Why pay for a lowcode platform if you are going to code in sql?)

But if you want to go this route, you do have options to pass information out about what is happening (like stopping and giving back a message when a validation fails)  Not sure if this is what you are looking for, but you can do something like this :

(SQLOutput is a structure with 2 attributes, Code and Text)


or, if you want all errors raised to come out with the details of the error, so you can do something with it in your code, you can do something like this (put the whole thing in a try catch)

If you do this, you become responsible for deciding if rollbacks need to happen in you happy flow after the sql call (or do it in your catch)

Look like a discussion for the forum, not Ideas.

Thanks a lot for your replies Dorine, very helpful and I'm gonna test them.

I agree Daniel, should've posted this on forum instead.