用excel檔把item與price匯入oracle erp
1, 先把excel整理成item,price兩欄,此兩欄要是用'值'的方式儲存,且不含小數,如有小數,先變成整數,如要2位小數,則全部*100.=round(price,2)*100
2,把excel另存為.dbf檔
3,用工具把.dbf匯入oracle erp db中的import_price(item varchar2(20),item varchar2(20))臨時table
4,用以下plus sql更新db
[@more@]declare
ifhave number;
v_list_line_id number;
v_list_header_id number;
cursor cur_into(p_list_header_id in number) is
select b.inventory_item_id ,
round(a.price/100,2) price
from (select distinct item,price from import_price) a,
mtl_system_items_b b
where b.segment1=a.item
and b.organization_id=1
and a.item is not null
and not exists
(select 1 from qp_pricing_attributes a1,qp_list_lines b1
where 1=1
and nvl(b1.end_date_active,sysdate)>=sysdate
and b1.list_line_id=a1.list_line_id
and b1.list_header_id=a1.list_header_id
and a1.list_header_id=p_list_header_id
and a1.product_attr_value=b.inventory_item_id
) ;
cursor cur_update(p_list_header_id in number) is
select b.inventory_item_id ,
round(a.price/100,2) price
from (select distinct item,price from import_price) a,
mtl_system_items_b b
where b.segment1=a.item
and b.organization_id=1
and a.item is not null
and exists
(select 1 from qp_pricing_attributes a1,qp_list_lines b1
where 1=1
and nvl(b1.end_date_active,sysdate)>=sysdate
and b1.list_line_id=a1.list_line_id
and b1.list_header_id=a1.list_header_id
and a1.list_header_id=p_list_header_id
and a1.product_attr_value=b.inventory_item_id
) ;
begin
select list_header_id
into v_list_header_id
from qp_list_headers
where name ='???';
for rec in cur_into(v_list_header_id) loop
select qp_list_lines_s.nextval into v_list_line_id from dual;
insert into qp_pricing_attributes
(pricing_attribute_id,creation_date,created_by,
last_update_date,last_updated_by,last_update_login,
list_line_id,excluder_flag,accumulate_flag,
product_attribute_context,product_attribute,product_attr_value,
product_uom_code,attribute_grouping_no,product_attribute_datatype,
comparison_operator_code,list_header_id,pricing_phase_id,
qualification_ind
)
values
(qp_pricing_attributes_s.nextval,sysdate,-1,
sysdate,-1,-1,
v_list_line_id,'N','N',
'ITEM','PRICING_ATTRIBUTE1',rec.inventory_item_id,
'PCS',qp_pricing_attr_group_no_s.nextval,'C',
'BETWEEN',v_list_header_id,1,
4
);
insert into qp_list_lines
(list_line_id,creation_date,created_by,
last_update_date,last_updated_by,list_header_id,
list_line_type_code,automatic_flag,modifier_level_code,
arithmetic_operator,operand,reprice_flag,
pricing_phase_id,pricing_group_sequence,incompatibility_grp_code,
product_precedence,list_line_no,revision_date,
start_date_active, qualification_ind
)
values
(v_list_line_id,sysdate,-1,
sysdate,-1,v_list_header_id,
'PLL','Y','LINE',
'UNIT_PRICE',rec.price,'Y',
1,0,'EXCL',
220,v_list_line_id,sysdate,
sysdate,4
);
end loop;
for rec in cur_update(v_list_header_id) loop
select list_line_id,counts
into v_list_line_id,ifhave
from (
select a.list_line_id,count(*) counts
from qp_pricing_attributes a,qp_list_lines b
where 1=1
and nvl(b.end_date_active,sysdate)>=sysdate
and b.list_line_id=a.list_line_id
and b.list_header_id=a.list_header_id
and a.product_attr_value=rec.inventory_item_id
and a.list_header_id=v_list_header_id
group by a.list_line_id
)
where rownum=1;
if ifhave>0 then
update qp_list_lines
set operand=rec.price
where 1=1
and list_line_id=v_list_line_id
and list_header_id=v_list_header_id;
end if;
end loop;
end;
/*
commit;
*/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-872656/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 匯入excel檔案Excel
- 用php把資料匯出excelPHPExcel
- Angular Excel 匯入與匯出AngularExcel
- 把Excel表資料匯入到mysqlExcelMySql
- Oracle 資料匯入ExcelOracleExcel
- excel表格生成與匯入Excel
- Java POI匯入Excel檔案JavaExcel
- 把vfp表中的資料匯入指定的excel檔案中 (轉)Excel
- EasyExcel完成excel檔案的匯入匯出Excel
- mysql匯入文字或excel檔案MySqlExcel
- excel的匯入與匯出---通用版Excel
- 如何使用JavaScript匯入和匯出Excel檔案JavaScriptExcel
- Oracle匯入excel資料快速方法OracleExcel
- ASP.NET MVC 匯入Excel檔案ASP.NETMVCExcel
- 把csv檔案的資料匯入到oracle資料庫中Oracle資料庫
- 使用Oracle SQL Developer匯入Excel資料OracleSQLDeveloperExcel
- MATLAB匯入txt和excel檔案技巧彙總:批量匯入、單個匯入MatlabExcel
- vue excel匯入匯出VueExcel
- 用Navicat把SQLServer資料匯入MySQLServerMySql
- oracle匯入dmp檔案Oracle
- excel匯入工具Excel
- 原生PHP網頁匯出和匯入excel檔案例項PHP網頁Excel
- 用GridView匯入匯出Excel,並列印GridViewViewExcel
- 用Oracle sqlldr匯入文字檔案TXT 總結OracleSQL
- 用SQL語句匯入excel資料SQLExcel
- office for Mac Excel匯入csv檔案亂碼MacExcel
- windows下把資料從oracle匯入hbaseWindowsOracle
- Oracle匯入(imp )與匯出(exp )Oracle
- banq您好,請問如何把excel的資料匯入mysql.ExcelMySql
- Excel匯入匯出神器(Java)ExcelJava
- php讀取excel檔案資料的匯入和匯出PHPExcel
- plsql Oracle匯入dmp檔案SQLOracle
- txt檔案匯入oracle方法Oracle
- Maatwebsite\Excel匯入用法WebExcel
- C#匯入EXCELC#Excel
- maatwebsite/excel": "^3.1 匯入excel 問題WebExcel
- excel檔案中的資料匯入Oracle資料庫的幾種方法ExcelOracle資料庫
- kxcel, 方便匯入和匯出 ExcelExcel