ORALCE: Select into VS Insert into select(真的晕)

发表于:2007-07-02来源:作者:点击数: 标签:
想实现 一个很简单的功能 费了我好长时间; 目的: 把一个料号记录COPY一份修改主键再存放到原表里去; 1) 凭记忆采用 Select * into a from b 的这种形式,死也不行~~ 2) 上网GOOGLE了一下 ==http://fengyu.china.com/sql1.htm INSERT (往数据表里插入记录的语

想实现 一个很简单的功能 费了我好长时间;
目的: 把一个料号记录COPY一份修改主键再存放到原表里去;

1) 凭记忆采用

Select * into a from b 的这种形式,死也不行~~

2) 上网GOOGLE了一下

==>http://fengyu.china.com/sql1.htm

INSERT  (往数据表里插入记录的语句)

INSERT INTO 表名(字段名1, 字段名2, ……) VALUES ( 值1, 值2, ……);
INSERT INTO 表名(字段名1, 字段名2, ……)  SELECT (字段名1, 字段名2, ……) FROM 另外的表名;

第二个的语法很符合,决定试试.
不想还是提示: 右括号MISSING!

奇怪,仔细对了一次又一次,发现语法格式和上面的一模一样;
~~~~~~~~~~~~~~~无语
真试试看把括号去掉试试
INSERT INTO 表名(字段名1, 字段名2, ……)  SELECT 字段名1, 字段名2, …… FROM 另外的表名;

OK搞定,真不懂;头都发晕,算了,记下来,下次说不定又忘记了

INSERT INTO 表名(字段名1, 字段名2, ……)  SELECT (字段名1, 字段名2, ……) FROM 另外的表名;
==>红色的括号一定要去掉~~!!

 

正确贴在下面:

insert into sales_part_tab (CATALOG_NO ,contract,PART_NO,CATALOG_GROUP,BONUS_BASIS_FLAG,BONUS_VALUE_FLAG,
ENG_ATTRIBUTE,CUSTOMS_STAT_NO,NOTE_ID,DISCOUNT_GROUP,PRINT_CONTROL_CODE,
NOTE_TEXT,PACKAGE_TYPE,SALES_UNIT_MEAS,PACKAGE_WEIGHT,ACTIVEIND,PRICE_CONV_FACTOR,
CATALOG_DESC,PRICE_UNIT_MEAS,CATALOG_TYPE,CONV_FACTOR,COST,DATE_ENTERED,
LIST_PRICE,PRICE_CHANGE_DATE,PURCHASE_FLAG,SO_FLAG,VOLUME,WEIGHT_GROSS,WEIGHT_NET,
FEE_CODE,TAXABLE,PROPOSED_PARCEL_QTY,CLOSE_TOLERANCE,SALES_PRICE_GROUP_ID,
CONFIGURATION,WARRANTY,CREATE_SM_OBJECT_OPTION,EAN_NO,SALES_PART_SOURCING,
EXPECTED_AVERAGE_PRICE,PURCHASE_PART_NO,REPLACEMENT_PART_NO,DATE_OF_REPLACEMENT,
CUST_WARRANTY_ID,NON_INV_PART_TYPE,INTRASTAT_CONV_FACTOR,ROWVERSION )

select CATALOG_NO,@#PCB@#,PART_NO,CATALOG_GROUP,BONUS_BASIS_FLAG,BONUS_VALUE_FLAG,
ENG_ATTRIBUTE,CUSTOMS_STAT_NO,NOTE_ID,DISCOUNT_GROUP,PRINT_CONTROL_CODE,
NOTE_TEXT,PACKAGE_TYPE,SALES_UNIT_MEAS,PACKAGE_WEIGHT,ACTIVEIND,PRICE_CONV_FACTOR,
CATALOG_DESC,PRICE_UNIT_MEAS,CATALOG_TYPE,CONV_FACTOR,COST,DATE_ENTERED,
LIST_PRICE,PRICE_CHANGE_DATE,PURCHASE_FLAG,SO_FLAG,VOLUME,WEIGHT_GROSS,WEIGHT_NET,
FEE_CODE,TAXABLE,PROPOSED_PARCEL_QTY,CLOSE_TOLERANCE,SALES_PRICE_GROUP_ID,
CONFIGURATION,WARRANTY,CREATE_SM_OBJECT_OPTION,EAN_NO,SALES_PART_SOURCING,
EXPECTED_AVERAGE_PRICE,PURCHASE_PART_NO,REPLACEMENT_PART_NO,DATE_OF_REPLACEMENT,
CUST_WARRANTY_ID,NON_INV_PART_TYPE,INTRASTAT_CONV_FACTOR,ROWVERSION

from sales_part_tab where catalog_no = @#810370111F1291@# and contract = @#TMP@#


 

原文转自:http://www.ltesting.net