Hi,

I'm doing some data analysis using H2 and Squirrel SQL Client.

How do I cause my script to exit with an exception?  I can't find
anything in the doco or list history to do this.

I came up with my own 'throwErrorIf' function.  Is there a better
way?....
-- my error function ----------------------------------
drop alias if exists throwErrorIf;
create alias throwErrorIf AS
'void throwError(Boolean condition,String msg) throws
java.sql.SQLException {if (condition) throw new
java.sql.SQLException(msg);}';

-- basic tests ----------------------------------
call throwErrorIf(false, 'some message');
call throwErrorIf(true, 'some message'); -- will throw exception

-- proper test ----------------------------------
drop table if exists norows;
create table norows (id int primary key);
select throwErrorIf(count(*) > 0, 'should be no rows') from NOROWS;
insert into norows values(1);
select throwErrorIf(count(*) > 0, 'should be no rows') from NOROWS; --
will throw exception

Thanks in advance,
Pete

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to