Problems with MYSQL-type ORACLE sequence implementation

Source: Internet
Author: User

Problems with MYSQL-type ORACLE sequence implementation MYSQL implements the nextval method of ORACLE to create a function, as follows: -- -------------------------------------------------------------------------- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- Role DELIMITER $ create definer = 'root' @ 'localhost' FUNCTION 'nextval' (seq_name varchar (100) RETURNS bigint (20) begin declare cur_val bigint (20); SELECT cur_value INTO cur_val FROM sequence WHERE name = seq_name; IF cur_val is not null then update sequence SET cur_value = cur_value + increment WHERE name = seq_name; end if; RETURN cur_val; end create a TABLE sequence create table 'sequence '('name' varchar (100) not null, 'credentials' int (11) unsigned not null default '1 ', 'cur _ value' bigint (20) un Signed DEFAULT '1', primary key ('name') ENGINE = InnoDB default charset = utf8; the application uses SSI to obtain the Sequence Value Through select nextval ('seq. Problem: When select nextval ('A') and then use select nextval ('B') in another function, the system prompts no column nextval ('A '), throw an SQL exception. I didn't understand it at first. Baidu and Google are all released. Later I thought about it. It would be 2nd times that nextval ('A') was treated as an alias. Therefore, in the ibatis SQL configuration, slightly modify select nextval ('A') as x and then OK.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.