{"id":184,"date":"2019-05-03T10:44:12","date_gmt":"2019-05-03T02:44:12","guid":{"rendered":"http:\/\/www.hefeiyu.com\/?p=184"},"modified":"2019-05-03T10:45:15","modified_gmt":"2019-05-03T02:45:15","slug":"tiptop%e5%8f%a6%e4%b8%80%e7%a7%8dexcel%e4%b8%8a%e4%bc%a0%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.hefeiyu.com\/?p=184","title":{"rendered":"TIPTOP\u53e6\u4e00\u79cdEXCEL\u4e0a\u4f20\u65b9\u6cd5"},"content":{"rendered":"<blockquote><p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u5927\u6570\u91cf\u5bfc\u5165\uff0c\u652f\u6301\u4e2d\u6587\u3002\u8fd9\u79cd\u65b9\u6cd5\u672c\u8d28\u4e0a\u662f\u5728\u901a\u8fc7sqlldr\u5bfc\u5165\u6587\u672c\u6570\u636e\uff0c\u800c\u4e0d\u662fEXCEL\u3002<\/p><\/blockquote>\n<p><strong>\u9996\u5148\u7b2c\u4e00\u6b65\uff0c\u9700\u8981\u5c06EXCEL\u53e6\u5b58\u4e3aCSV<\/strong><\/p>\n<p>\u7136\u540e\u5728\u7a0b\u5e8f\u4e2d\u4e0a\u4f20\u8fd9\u4efdCSV<\/p>\n<p>\u5168\u90e8\u7a0b\u5e8f\u5c31\u4e0d\u5e16\u4e86\u3002\u5173\u952e\u4ee3\u7801\u5982\u4e0b<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">\r\n#....\u524d\u9762\u4e0a\u4f20\u7b49\u6b65\u9aa4\u7701\u7565\r\n#\u6e05\u7a7a\u4e34\u65f6\u8868( \u4e34\u65f6\u8868\u9700\u8981\u63d0\u524d\u5efa\u7acb\u597d \u672c\u4f8b\u4e2d\u662f cims300_tmp )\r\n    CALL cl_del_data(\"cims300_tmp\")\r\n#DELETE FROM cims300_tmp WHERE 1=1;\r\n   #\u4e0a\u4f20\u4e3acims300_tmp.csv\uff0c\u7b49\u5f85\u5904\u7406\uff0c\u6ce8\u610f\u662f tmp\r\n   IF NOT cl_upload_file(tm.path, '\/u1\/doc\/cims300_tmp.csv') THEN\r\n        CALL cl_err(NULL, \"lib-212\", 1)\r\n        RETURN FALSE\r\n   END IF \r\n   #\u5220\u9664\u5df2\u6709\u6587\u4ef6\uff0c\u6b63\u5f0f\u6587\u4ef6\uff0c\u6ca1\u6709tmp\r\n   RUN \" rm -f \/u1\/doc\/cims300.csv \"\r\n   LET g_msg=NULL\r\n   #\u4f7f\u7528iconv\u5c06gbk\u7f16\u7801\u8f6c\u5316\u4e3autf-8\u7f16\u7801 \u4e3a\u4e86\u9002\u5e94\u4e2d\u6587\u5bfc\u5165\u3002\u6ce8\u610f\u6587\u4ef6\u540d\u5df2\u7ecf\u7531tmp\u8f6c\u6210\u6ca1\u6709tmp\r\n   LET g_msg = \"iconv -f GBK -t UTF-8 \/u1\/doc\/cims300_tmp.csv -o \/u1\/doc\/cims300.csv\"\r\n   RUN g_msg\r\n   #\u6388\u6743\r\n   LET g_msg=\"chmod 777 \/u1\/doc\/cims300.csv 2&gt;\/dev\/null\"\r\n   RUN g_msg \r\n   LET g_msg=NULL\r\n   #\u5173\u952e\u4e00\u6b65,oracle\u901a\u8fc7sqlldr\u5bfc\u5165\u6587\u672c\u6570\u636e \uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u8bf7\u81ea\u884c\u767e\u5ea6\r\n   LET g_msg = \"sqlldr userid=\",g_plant,\"\/\",g_plant,\" control=\/u1\/doc\/cims300.ctl log=\/u1\/doc\/cims300.log\"\r\n   RUN g_msg\r\n   #\u786e\u8ba4\u4e34\u65f6\u8868\u4e2d\u6709\u6570\u636e\u4e86\r\n   LET g_cnt = 0\r\n   SELECT COUNT(*) INTO g_cnt FROM cims300_tmp WHERE C1 != '\u6599\u4ef6\u7f16\u53f7'\r\n   IF g_cnt &gt; 0 THEN\r\n       #\u5f00\u59cb\u5904\u7406\r\n       CALL cims300()\r\n   ELSE\r\n       CALL cl_err('insert_prep:','anm-259',1)# EXIT PROGRAM\r\n       LET sql_state ='N'\r\n   END IF<\/code><\/pre>\n<p>\u9644\u4e0acims300.ctl\u7684\u5199\u6cd5<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">load data\r\ninfile '\/u1\/doc\/cims300.csv'\r\nappend into table cims300_tmp\r\nwhen C1&lt;&gt;''\r\nfields terminated by ',' Optionally enclosed by '\"' \r\n(C1,C2,C3,C4,C5,C6,C7)<\/code><\/pre>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.hefeiyu.com\">\u8d6b\u975e\u57df<\/a> &raquo; <a href=\"https:\/\/www.hefeiyu.com\/?p=184\">TIPTOP\u53e6\u4e00\u79cdEXCEL\u4e0a\u4f20\u65b9\u6cd5<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u5927\u6570\u91cf\u5bfc\u5165\uff0c\u652f\u6301\u4e2d\u6587\u3002\u8fd9\u79cd\u65b9\u6cd5\u672c\u8d28\u4e0a\u662f\u5728\u901a\u8fc7sqlldr\u5bfc\u5165\u6587\u672c\u6570\u636e\uff0c\u800c\u4e0d\u662fEXCEL\u3002 \u9996\u5148\u7b2c\u4e00\u6b65\uff0c\u9700\u8981\u5c06EXCEL\u53e6\u5b58\u4e3aCSV \u7136\u540e\u5728\u7a0b\u5e8f\u4e2d\u4e0a\u4f20\u8fd9\u4efdCSV \u5168\u90e8\u7a0b\u5e8f\u5c31\u4e0d\u5e16\u4e86\u3002\u5173\u952e\u4ee3\u7801\u5982\u4e0b #&#8230;.\u524d\u9762\u4e0a\u4f20\u7b49\u6b65\u9aa4\u7701\u7565 #\u6e05\u7a7a\u4e34\u65f6\u8868( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[84,85,83],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category-4gl","tag-cims","tag-csv","tag-tmp"],"_links":{"self":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":3,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}