create or replace package body scott.pkg_etl_trans
isprocedure HQ_HISTORY_2_CLOSED
is
--当前系统日期
v_cur_day date;--前一个交易日期
v_last_day date;--当前交易日期
v_trans_dayBEGIN --记录当前时间
v_cur_day:=sysdate;
--获取当天交易日期
select DATA_TIME into v_trans_day
from T_LX_HQ_HISTORY
where et_cd='SH' and sec_code='000001' and DATA_TIME=v_cur_day;
--当前日期是否开盘
if v_trans_day is null
then
exit;
end if;
--获取前一个交易日期
select max(DATA_TIME) into v_last_day
from T_LX_TRANS_DATE_AFTER_CLOSED
where sec_code='000001' and et_cd='SH'
--前一个交易日期必须有
if v_last_day is null
then
exit;
end if;
--将日行情数据同步到CLOSED表
merge into T_LX_TRANS_DATE_AFTER_CLOSED
using
(
select *
from T_LX_HQ_HISTORY
where DATA_TIME=v_trans_day
)s
on t.sec_code=s.sec_code
when matched then
update set
t.sec_code=s.sec_code
,
,
;
--将当日缺少数据补齐
merge into T_LX_TRANS_DATE_AFTER_CLOSED
using
(
--在T_LX_TRANS_DATE_AFTER_CLOSED表中有,但在T_LX_HQ_HISTORY表中无
select *
from T_LX_TRANS_DATE_AFTER_CLOSED
where DATA_TIME=v_last_day and sec_code not in (
select sec_code from T_LX_HQ_HISTORY where DATA_TIME=v_trans_day
)
)s
on t.sec_code=s.sec_code
when matched then
update set
t.sec_code=s.sec_code,
t.data_time=v_trans_day,
,
,
;
commit;END HQ_HISTORY_2_CLOSED;end scott.pkg_etl_trans ;编译报以下错误:
警告: 创建的包体带有编译错误。SQL> show error
PACKAGE BODY SCOTT.PKG_ETL_TRANS 出现错误:LINE/COL ERROR
-------- -----------------------------------------------------------------
15/1 PLS-00103: 出现符号 "BEGIN"在需要下列之一时:
constant exception
<an identifier> <a double-quoted delimited-identifier> table
LONG_ double ref char time timestamp interval date binary
national character nchar41/3 PLS-00103: 出现符号 "IF"在需要下列之一时:
* & - + ; / at for mod
remainder rem <an exponent (**)> and or group having
intersect minus order start union where connect || multiset
符号 ";" 被替换为 "IF" 后继续。LINE/COL ERROR
-------- -----------------------------------------------------------------49/9 PLS-00103: 出现符号 "INTO"在需要下列之一时:
:= . ( @ % ;
<a SQL statement>大家帮我看看!
isprocedure HQ_HISTORY_2_CLOSED
is
--当前系统日期
v_cur_day date;--前一个交易日期
v_last_day date;--当前交易日期
v_trans_dayBEGIN --记录当前时间
v_cur_day:=sysdate;
--获取当天交易日期
select DATA_TIME into v_trans_day
from T_LX_HQ_HISTORY
where et_cd='SH' and sec_code='000001' and DATA_TIME=v_cur_day;
--当前日期是否开盘
if v_trans_day is null
then
exit;
end if;
--获取前一个交易日期
select max(DATA_TIME) into v_last_day
from T_LX_TRANS_DATE_AFTER_CLOSED
where sec_code='000001' and et_cd='SH'
--前一个交易日期必须有
if v_last_day is null
then
exit;
end if;
--将日行情数据同步到CLOSED表
merge into T_LX_TRANS_DATE_AFTER_CLOSED
using
(
select *
from T_LX_HQ_HISTORY
where DATA_TIME=v_trans_day
)s
on t.sec_code=s.sec_code
when matched then
update set
t.sec_code=s.sec_code
,
,
;
--将当日缺少数据补齐
merge into T_LX_TRANS_DATE_AFTER_CLOSED
using
(
--在T_LX_TRANS_DATE_AFTER_CLOSED表中有,但在T_LX_HQ_HISTORY表中无
select *
from T_LX_TRANS_DATE_AFTER_CLOSED
where DATA_TIME=v_last_day and sec_code not in (
select sec_code from T_LX_HQ_HISTORY where DATA_TIME=v_trans_day
)
)s
on t.sec_code=s.sec_code
when matched then
update set
t.sec_code=s.sec_code,
t.data_time=v_trans_day,
,
,
;
commit;END HQ_HISTORY_2_CLOSED;end scott.pkg_etl_trans ;编译报以下错误:
警告: 创建的包体带有编译错误。SQL> show error
PACKAGE BODY SCOTT.PKG_ETL_TRANS 出现错误:LINE/COL ERROR
-------- -----------------------------------------------------------------
15/1 PLS-00103: 出现符号 "BEGIN"在需要下列之一时:
constant exception
<an identifier> <a double-quoted delimited-identifier> table
LONG_ double ref char time timestamp interval date binary
national character nchar41/3 PLS-00103: 出现符号 "IF"在需要下列之一时:
* & - + ; / at for mod
remainder rem <an exponent (**)> and or group having
intersect minus order start union where connect || multiset
符号 ";" 被替换为 "IF" 后继续。LINE/COL ERROR
-------- -----------------------------------------------------------------49/9 PLS-00103: 出现符号 "INTO"在需要下列之一时:
:= . ( @ % ;
<a SQL statement>大家帮我看看!
解决方案 »
- 在windows 的MFC中用OCCI通过连接字符串连接Windows上的oracle10g 报告ora12560
- ORA-00942: table or view does not exist
- linux下oracle由10201升级到10205出错
- pl/sql急求插入和删除记录的函数!源码
- @spcreate 为什么不行?
- 请教各位高手一个SQL的写法!
- 如何在Oracle中使用SQL中的Case?????
- 向大家请教一个简单的问题
- PL/SQL简单问题
- 请问oracle有没有类似charindex的函数,获取某个子串在一个字符串里的位置?
- 类似QQ查找好友那种, 根据名字简拼快速查找好友?
- 如何在查询结果中显示空值
--当前交易日期
v_trans_day date;--获取前一个交易日期
select max(DATA_TIME) into v_last_day
from T_LX_TRANS_DATE_AFTER_CLOSED
where sec_code='000001' and et_cd='SH';--另外下面那两个merge into 最后的 , 是什么意思呢。
v_last_day date;merge into 后面的是表名
v_trans_day date ; 定义一下。--获取前一个交易日期
select max(DATA_TIME) into v_last_day
from T_LX_TRANS_DATE_AFTER_CLOSED
where sec_code='000001' and et_cd='SH' ;
,
,
; 这几个没明白~~~
when matched then
update set
t.sec_code=s.sec_code, t.data_time=v_trans_day
;SQL> @d:/pkg_etl_trans.sql
94 /警告: 创建的包体带有编译错误。SQL> show error
PACKAGE BODY SCOTT.PKG_ETL_TRANS 出现错误:LINE/COL ERROR
-------- ----------------------------------------------
49/3 PL/SQL: SQL Statement ignored
56/6 PL/SQL: ORA-00969: 缺失 ON 关键字
68/3 PL/SQL: SQL Statement ignored
78/6 PL/SQL: ORA-00969: 缺失 ON 关键字
93/11 PLS-00103: 出现符号 "."在需要下列之一时:
;这是什么错误
where sec_code='000001' and et_cd='SH' ;
on 后面要加括号。
89/11 PLS-00103: 出现符号 "."在需要下列之一时:
;
isprocedure HQ_HISTORY_2_CLOSED
is
--当前系统日期
v_cur_day date;--前一个交易日期
v_last_day date;--当前交易日期
v_trans_day date;BEGIN --记录当前时间
v_cur_day:=sysdate;
--获取当天交易日期
select DATA_TIME into v_trans_day
from T_LX_HQ_HISTORY
where et_cd='SH' and sec_code='000001' and DATA_TIME=v_cur_day;
--当前日期是否开盘
if v_trans_day is null
then exit;
end if;
--获取前一个交易日期
select max(DATA_TIME) into v_last_day
from T_LX_TRANS_DATE_AFTER_CLOSED
where sec_code='000001' and et_cd='SH' ;
--前一个交易日期必须有
if v_last_day is null
then
exit;
end if;
--将日行情数据同步到CLOSED表
merge into T_LX_TRANS_DATE_AFTER_CLOSED
using
(
select *
from T_LX_HQ_HISTORY
where DATA_TIME=v_trans_day
)s
on (t.sec_code=s.sec_code)
when matched then
update set
t.sec_code=s.sec_code
;
--将当日缺少数据补齐
merge into T_LX_TRANS_DATE_AFTER_CLOSED
using
(
--在T_LX_TRANS_DATE_AFTER_CLOSED表中有,但在T_LX_HQ_HISTORY表中无
select *
from T_LX_TRANS_DATE_AFTER_CLOSED
where DATA_TIME=v_last_day and sec_code not in (
select sec_code from T_LX_HQ_HISTORY where DATA_TIME=v_trans_day
)
)s
on (t.sec_code=s.sec_code)
when matched then
update set
t.sec_code=s.sec_code,
t.data_time=v_trans_day
;
commit;END HQ_HISTORY_2_CLOSED;end scott.pkg_etl_trans ;
把建表的sql、包头sql 都粘出来。