Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT DBF
select most recently created auto_increment value
Rob Gansevles
2009-02-23 05:51:17.0
Hi,

I read in the release notes that there is a currval function to retrieve the value generated by a auto_increment column.

I tried following sql, but the currval select returned an error.
How should this be done?

Thanks
Rob


create table tst (id integer not null auto_increment, val integer default null, primary key (id))
insert into tst (val) values (100)
select currval('tst','id')
Re:select most recently created auto_increment value
HXTT Support
2009-02-23 06:13:57.0
>How should this be done?
You doen't use SEQUENCE so that you needn't use currval.

You should use Statement.RETURN_GENERATED_KEYS. For instance,
stmt.executeUpdate("insert into tst (val) values (100);",Statement.RETURN_GENERATED_KEYS);
ResultSet rs=stmt.getGeneratedKeys();
rs.next();
System.out.println("The id for inserted row is "+rs.getObject(1));
Re:Re:select most recently created auto_increment value
Rob Gansevles
2009-02-23 07:30:26.0
But why does the currval not work?
I could not use Statement.RETURN_GENERATED_KEYS when I want to script it all


Rob
Re:Re:Re:select most recently created auto_increment value
HXTT Support
2009-02-23 17:16:42.0
Checked. Yeah.
select currval(tst.id);
select currval('tst','id')
is correct according to API document.

Please download the latest package after about 3 hours.

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap