... and you have to have this system property set: -Dh2.check=false
On Tue, Jun 22, 2010 at 4:57 PM, Kerry Sainsbury <[email protected]> wrote:
> I had a little play, and it looks somewhat promising. Hope this is enough
> to get you started...
>
> Cheers
> Kerry
>
>
> public class TestSelectHacking extends TestBase {
>
> private void testParser() throws SQLException {
> JdbcConnection cj = (JdbcConnection) getConnection("play");
>
> Session s = (Session) cj.getSession();
>
> Statement stat = cj.createStatement();
> stat.execute("drop table if exists tab");
>
> stat.execute("create table tab(v1 int, v2 int)");
> stat.execute("insert into tab(v1, v2) values (6, 7)");
>
> Prepared prep = s.prepare("SELECT v1 from tab");
>
> Select select = (Select) prep;
> select.getExpressions().add(new ExpressionColumn(s.getDatabase(),
> null, null, "V2"));
>
> select.getExpressions().add(ValueExpression.get(ValueString.get("BBBB")));
>
> select.init();
>
> System.out.println("NOW: " + prep.getPlanSQL());
>
> ResultSet rs = stat.executeQuery(prep.getPlanSQL());
> assertTrue(rs.next());
> assertEquals(6, rs.getInt(1));
> assertEquals(7, rs.getInt(2));
> assertEquals("BBBB", rs.getString(3));
>
> stat.execute("drop table tab");
> }
>
>
> On Tue, Jun 22, 2010 at 2:57 PM, Erin Drummond <[email protected]> wrote:
>
>> Hi,
>>
>> I have a need to take a user-supplied SQL query and perform a few
>> modifications to it before allowing it to execute against the
>> database. Mostly, this consists of injecting in extra field names and
>> conditions. I need this to be transparent to the user because the user
>> cannot be relied on to include this information.
>>
>> Is it possible to use H2 to take a SQL string, convert it into a
>> datastructure, then allow me to manipulate that datastructure (to add
>> extra tables/fields/conditions/expressions), then convert it back into
>> a SQL statement for executing against the database?
>>
>> Thanks,
>> Erin
>>
>> --
>> 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]<h2-database%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/h2-database?hl=en.
>>
>>
>
--
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.