You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Anthony E. Carlos" <an...@digitalphenom.com> on 2004/11/11 15:12:01 UTC

arbitrary SQL

Hello,

How do I fire off a an arbitrary SQL statement that doesn't require a 
return value?

For example, (I already know how to do this using O/R mapping-- this is 
just a simple example)

	INSERT INTO colors VALUES ('red');

I've looked at the FAQs, but the only example is for SELECT statements, 
which obviously return values.

I've tried using

	String sql = "INSERT INTO colors (color) VALUES ('red')";
	Query query = QueryFactory.newQuery(ColorVO.class, sql);

I was using

	broker.getObjectByQuery(query);

but it complains that I have an invalid column. The problem is, why do 
I need "ColorVO.class" at all?

I've also tried

	broker.getReportQueryIteratorByQuery(query);

and it complains that I have an invalid SQL statement.

So, is there any way to fire off arbitrary SQL without a return value?

Thanks,

-Anthony


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: arbitrary SQL

Posted by Gerhard Grosse <ge...@lex-com.net>.
On Thu, 11 Nov 2004 08:33:39 -0600, "Robert r. Sanders"
<ro...@ipov.net> wrote:

>I believe you need to do something like:
>   
>        java.sql.Connection connection = 
>persistenceBroker.serviceConnectionManager().getConnection();
>        Statement statement = connection.createStatement();
>        statement.executeUpdate(...);
>
>

Alternatively:
persistenceBroker.serviceJdbcAccess().executeUpdateSQL(
  "INSERT INTO colors (color) VALUES ('red')",
  persistenceBroker.getClassDescriptor(ColorV0.class));

Gerhard

>Anthony E. Carlos wrote:
>
>> Hello,
>>
>> How do I fire off a an arbitrary SQL statement that doesn't require a 
>> return value?
>>
>> For example, (I already know how to do this using O/R mapping-- this 
>> is just a simple example)
>>
>>     INSERT INTO colors VALUES ('red');
>>
>> I've looked at the FAQs, but the only example is for SELECT 
>> statements, which obviously return values.
>>
>> I've tried using
>>
>>     String sql = "INSERT INTO colors (color) VALUES ('red')";
>>     Query query = QueryFactory.newQuery(ColorVO.class, sql);
>>
>> I was using
>>
>>     broker.getObjectByQuery(query);
>>
>> but it complains that I have an invalid column. The problem is, why do 
>> I need "ColorVO.class" at all?
>>
>> I've also tried
>>
>>     broker.getReportQueryIteratorByQuery(query);
>>
>> and it complains that I have an invalid SQL statement.
>>
>> So, is there any way to fire off arbitrary SQL without a return value?
>>
>> Thanks,
>>
>> -Anthony
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: arbitrary SQL

Posted by "Robert r. Sanders" <ro...@ipov.net>.
I believe you need to do something like:
   
        java.sql.Connection connection = 
persistenceBroker.serviceConnectionManager().getConnection();
        Statement statement = connection.createStatement();
        statement.executeUpdate(...);


Anthony E. Carlos wrote:

> Hello,
>
> How do I fire off a an arbitrary SQL statement that doesn't require a 
> return value?
>
> For example, (I already know how to do this using O/R mapping-- this 
> is just a simple example)
>
>     INSERT INTO colors VALUES ('red');
>
> I've looked at the FAQs, but the only example is for SELECT 
> statements, which obviously return values.
>
> I've tried using
>
>     String sql = "INSERT INTO colors (color) VALUES ('red')";
>     Query query = QueryFactory.newQuery(ColorVO.class, sql);
>
> I was using
>
>     broker.getObjectByQuery(query);
>
> but it complains that I have an invalid column. The problem is, why do 
> I need "ColorVO.class" at all?
>
> I've also tried
>
>     broker.getReportQueryIteratorByQuery(query);
>
> and it complains that I have an invalid SQL statement.
>
> So, is there any way to fire off arbitrary SQL without a return value?
>
> Thanks,
>
> -Anthony
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>

-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    www.ipov.net


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org