Using Dual to get nexval oracle activejdbc

102 views
Skip to first unread message

Sarndeep Nijjar

unread,
Nov 2, 2012, 10:28:32 AM11/2/12
to activejd...@googlegroups.com
Hi All,

Im trying to execute the following to get keys from a dual table:


{{{
new DB("gti_sequence").open("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@c4t-db05-vip:1521:ORAINT1", "gti_sequence", "gti_sequence");
Sequence.findBySQL("select SEQ_GTI.nextval from DUAL")
}}}

using this basic class:

{{{
@DbName("gti_sequence")
@Table("DUAL")


public class Sequence extends Model {

    }

}}}

Whats happening, instead of getting the attributes populated im getting dummy=null

Is there something specific you have to do to get the values from the dual table?

igor

unread,
Nov 2, 2012, 11:00:00 AM11/2/12
to activejd...@googlegroups.com
Sarndeep, you are using a model class to get values that have nothing to do with that model. Please read JavaDoc for this method:

It says: " Returned columns that are not part of this model will be ignored"

If you need to write a free hand SQL, you can only use this method to get values related to this models. If you want complete freedom, use a Bas class instead.

thanks
igor

Sarndeep Nijjar

unread,
Nov 2, 2012, 12:10:37 PM11/2/12
to activejd...@googlegroups.com
Ah I see, thank you very much, your a legend.I have solved it using the the following:

Base.firstCell("select SEQ_GTI.nextval from DUAL").toString()

igor

unread,
Nov 2, 2012, 12:17:45 PM11/2/12
to activejd...@googlegroups.com
yep, this will work
Reply all
Reply to author
Forward
0 new messages