各位大大 帮帮忙

[复制链接]
查看11 | 回复4 | 2007-10-20 08:38:44 | 显示全部楼层 |阅读模式
我要把表中form_id =1 的数据 插入本表中 但 form_id 改为1qh,pk_id 自动增加,Sql 语句怎么写?
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
insert into table1 (pi_id, form_id, other_col)
select sequence_name.nextval, '1qh', other_col
from table1 where form_id = '1';
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
有错误报告errorORA-02289序列(号)不存在,
pk_id的值是00000000000000000299 这样的,插入数据时系统会自动加1,00000000000000000300
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
首先,你的序列没有建,当然报错了,第二如果你要的序列是你那样的格式的话,你左填0不就OK了lpad()
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
select to_char('00000000000000000299'+1,'00000000000000000000') as id from dual;
id
-----------------------------------------
00000000000000000300

insert intotable1 (pi_id, form_id, other_col)
select to_char(pi_id+1,'00000000000000000000'),'1qh', other_col
from table1 where form_id = '1';
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行