Can error messages be concatenated in the raise function?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can error messages be concatenated in the raise function?

Shane Dev
Hello,

From the documentation https://www.sqlite.org/syntax/raise-function.html,
it is not clear to me if the 'error-message' must be a fixed string. Is
there a way to raise a concatenated message?

For example, a fix string error message -

CREATE TABLE readonly(num int);
CREATE TRIGGER ti_readonly before insert on readonly begin select
raise(FAIL, 'inserts not allowed in table readonly'); end;

sqlite> insert into readonly select 4;
Error: inserts not allowed in table readonly

Defining an empty table where inserts are prohibited is more or less
pointless but its purpose is only to demonstrate the raise function.

However the following trigger definition with a concatenated error gives me
an error message -

sqlite> drop trigger ti_readonly;
sqlite> CREATE TRIGGER ti_readonly before insert on readonly begin select
raise(FAIL, 'Not allowed to insert '||new.num||' into table readonly'); end;
Error: near "||": syntax error
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can error messages be concatenated in the raise function?

Richard Hipp-3
On 1/10/18, Shane Dev <[hidden email]> wrote:
> Hello,
>
> From the documentation https://www.sqlite.org/syntax/raise-function.html,
> it is not clear to me if the 'error-message' must be a fixed string.

The current implementation requires that the 2nd argument to RAISE()
be a fixed string.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users