cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence in SQLJ

Former Member
0 Kudos

Hi!

I have a problem.

I created a sequence un SQL Studio, there I can obtain the next value of the sequence using:

SELECT user.seqname.nextval from dual

but I'm not able to retrieve it from a java program with sqlj. When I try the previous query, It says that 'dual' is not a table...

How do you get the next value of a sequence from sqlj?

Thank you!!!

Accepted Solutions (1)

Accepted Solutions (1)

Jeff-Gebo
Advisor
Advisor
0 Kudos

Hi Sergio,

you must use JDBC to do this. You can get the connection from you SQLJ connect context and use that with JDBC.

Good luck!

Cheers,

Jeff

Former Member
0 Kudos

Thank you for your answer, but I tried that, too...

I executed the following query with JDBC: "SELECT testseq.nextval from dual"

and I got:

java.lang.SQLException: The SQL statement "SELECT "TESTSEQ"."NEXTVAL" FROM "DUAL"" contains the semantics error[s]: table "DUAL" unknown

I don't know what i'm doing wrong...

Answers (1)

Answers (1)

Jeff-Gebo
Advisor
Advisor
0 Kudos

Hmmm...now that I think about this I think I last did this with 6.20 J2EE Engine when there was no underlying DB...I don't think Open SQL allows you to select from sequences since it doesn't know about them. Try this, create a new datasource to MaxDB, and set the connection type to Native or Vendor SQL...get a connection to that datasource and send your SQL sequence selection to it....I bet that will work.

Good luck!

Jeff

Former Member
0 Kudos

Jeff,

I thank you very much for your kind attention to this matter.

Best regards,

Sergio Fierens Bayo.