Hi all,

I've been using the raise() function in select statements in triggers  
to check data entry. I give it text to return a meaningful error to  
the user, but would like to include some specific info about the data  
being entered. Is this possible? The SQLite syntax suggests tat only a  
static string can be returned, and not an expression.

For instance, I have a trigger that checks that an entered Account  
Code exists:

create trigger "Entries update Account Code"
before update of "Account Code"
on "Entries"
begin
select raise(rollback, 'Account Code does not exist')
where not exists
(       select 1 from Accounts where Code = new."Account Code"
)
;
end
;

But I'd like to change the raise function line to return more detail  
about the problem:

select raise(rollback, 'Failed to set Account Code = ' || new."Account  
Code" || ' where ID = ' || new.ID || ' because this Account Code does  
not exist in the Accounts table.')

but SQLite won't accept it, giving an error: SQL error near line 6:  
near "||": syntax error

Is there another way? Or can the raise() function be enhanced to allow  
it?

Thanks,
Tom
BareFeet

  --
Comparison of SQLite GUI applications:
http://www.tandb.com.au/sqlite/compare/?ml

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to