Ticket #1: cyp_update_product_11.sh

File cyp_update_product_11.sh, 1.7 KB (added by chenchongqi, 15 years ago)
Line 
1#!/bin/sh
2
3NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
4ORACLE_HOME=/oracle/product/10.2.0
5ORACLE_SID=v880
6ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
7PATH=/usr/ccs/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/ucb:/etc:$ORACLE_HOME/bin:.
8export NLS_LANG
9export ORACLE_HOME
10export ORACLE_SID
11export ORA_NLS33
12export PATH
13
14cd /data/oracle/crontab/app
15
16sqlplus "/ as sysdba " <<EOF
17alter session set current_schema=cyp_nw_app;
18
19update pdl_product_base  set EMALL_OWNED=0 where create_date>sysdate-700;
20
21
22commit;
23
24update pdl_product_base p1 set EMALL_OWNED=1 where
25exists (select 1 from (select t1.product_id
26from ent_product_item t1, ent_user t2, ent_company t6
27where t1.user_id = t2.id and  t1.user_id = t6.id
28and t1.sell_status = 1 and t1.start_date <= sysdate
29and sysdate <= t1.end_date and t1.status in (0,1)
30and t2.status = 1 and t6.status = 1 ) p2  where p1.id=p2.product_id);
31
32commit; 
33
34update pdl_product a set a.EYP_PRICE_COUNT=0;
35
36update pdl_product a set a.EYP_PRICE_COUNT=(select b.company_count from (
37SELECT product_id, count(*) as company_count
38FROM V_ENT_PRODUCT
39group by product_id) b where b.product_id= a.id)
40where exists (select 1 from v_ent_product c where a.id=c.product_id);
41
42
43commit ;
44
45update ent_product_item set price_status=1 where company_product_id in
46(select t1.company_product_id from ent_product_item t1,v_pdl_product t2
47where t1.product_id=t2.id
48and t2.price<>0 and (t1.RETAIL_PRICE>t2.price*1.4 or t1. RETAIL_PRICE<t2.price*0.6) and t1.price_status=0);
49
50commit;
51
52truncate table product_app.eml_price;
53
54insert into eml_price(product_id,min_price,max_price) 
55(SELECT product_id, min(retail_price),max(retail_price)
56FROM V_ENT_PRODUCT where price_status=0
57group by product_id);
58
59commit;
60
61
62EOF