Is there anything one could wish for?
(1) By anonymous on 2021-02-18 15:27:06 [source]
Yes. Here is a snippet of SQL SELECT CASE 1 WHEN (OLD.BA_UIC != NEW.BA_UIC) THEN RAISE (ABORT, 'Table LOCATION (INSERT): ERROR 54-30: The UIC may not be changed') END; What I really would like is to retrieve the errors messages from a table because that will make it easier to keep track of all error codes. Or being able to create an error message like: 'This ' || BA_UIC || ' is invalid."
(2.1) By Simon Slavin (slavin) on 2021-02-19 05:55:43 edited from 2.0 in reply to 1 [link] [source]
I don't see why you can't use
'This ' || NEW.BA_UIC || ' is invalid.'
doesn't it work ? Or you could use the
Also you should be able to maintain a table called ErrorMessages. Instead of using RAISE, just add a new row to that table.
RAISE(ABORT,…) actually does abort. So i fyou're trying to compile a list of rows which cause errors you can't use it, because you'll get only the first one. You might find that
RAISE(IGNORE,…) does what you want, depending on what you're actually doing.
(3) By anonymous on 2021-02-19 09:45:21 in reply to 2.1 [link] [source]
Thx, I will try this idea. Until now only hard code strings are possible in a RAISE (ABORT …
(4) By Clemens Ladisch (cladisch) on 2021-02-24 08:11:48 in reply to 2.1 [link] [source]
The RAISE function does not take a string expression but a name (an identifier, which is also allowed be written as a string literal).
In most cases, you could use a user-defined function that raises a 'normal' error.
(5) By anonymous on 2021-02-24 09:13:50 in reply to 4 [link] [source]
An extension function like const char* err("table name", "trigger name", "error code") How do I use this? Is this the correct syntax? raise (abort, err);
(6) By Clemens Ladisch (cladisch) on 2021-02-24 10:07:37 in reply to 5 [link] [source]
You would use something like
SELECT err('some message: ' || 'xxx');, without the built-in RAISE function.
(When I try this in Python, I get just "sqlite3.OperationalError: user-defined function raised exception", without the message. So it's not always useful.)