oracle动态执行SQL字符串,字符串最大的长度是多少

 我来答
wf...2@163.com
2017-03-24 · TA获得超过109个赞
知道小有建树答主
回答量:302
采纳率:0%
帮助的人:272万
展开全部
你好:我知道的是最大可执行长度为6000个字符。通常在procedure中sql拼接的时候会有这个问题,一边解决方案是设置function对逻辑分别处理来实现减少sql长度的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

VAR_DYNAMIC_SQL := 'INSERT INTO RP_TRANS_LOG_MINUTE
(
TRANS_TIME,
TRANS_PROVINCE,
TRANS_TYPE,
SCORE_RANGE,
RULE_NAME,
POLICY_ACTION,
/*新加字段开始*/
CHALLENGE_SUCCESSFUL,
CHALLENGE_AUTH_METHOD,
PRIORITY,---
DESCRIBE,--
IS_USE_DEVICE,--
TRANS_DITCH,
TRANS_OPER_SYSTEM,
TRANS_BROWSER,
FLAGGED,
RESOLUTION,
/*新加字段结束*/
TRANS_NUM,
TRIGGERED_NUM,
TRIGGERED_SUCCESSFUL_NUM,
/*新加字段开始*/
WEB_TRANS_NUM,
MOBILE_TRANS_NUM,
IPAD_TRANS_NUM,
QA_LOGIN_NUM,
SMS_LOGIN_NUM,
CC_LOGIN_NUM,
REGISTRAR_QA_NUM,--***
CREATE_CUSTOMR_FILE_NUM,
ALLOW_TRANS_NUM,
REVIEW_TRANS_NUM,
CHALLENGE_TRANS_NUM,
DENY_TRANS_NUM,
TOTAL_SCORE_RANGE,
TOTAL_AMOUNT
/*新加字段结束*/
)
SELECT
TO_DATE(SUBSTR(TO_CHAR(SYS_CREATION_DATE,''YYYY-MM-DD HH24:MI:SS''),0,16),''YYYY-MM-DD HH24:MI''),
get_province(IP_COUNTRY,IP_CITY,ip_region) AS TRANS_PROVINCE,
GET_NAME_BY_CODE(GET_TOTAL_EVENT_TYPE(T.EVENT_TYPE,T.USER_DEFINED_EVENT_TYPE),''eventType'') AS TRANS_TYPE,
GET_SCORE_RANGE(T.RISK_SCORE) AS RISK_SCORE_RANGE,
NVL(POLICY_RULE_ID,''FALLBACK_RULE'') AS RULE_NAME,
POLICY_ACTION,
CHALLENGE_SUCCESSFUL,
CHALLENGE_AUTH_METHOD,
SUBSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),0,INSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),''+'')-1),--优先级
SUBSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),INSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),''-'')+1),--描述
NVL(IS_DEVICE_BOUND,''N''),
CHANNEL_INDICATOR,
OPERATING_SYSTEM,
BROWSER_TYPE,
FLAGGED,
RESOLUTION,
COUNT(1) AS TRANS_NUM,
SUM(CASE WHEN POLICY_ACTION = ''CHALLENGE'' THEN 1 ELSE 0 END) AS TRIGGERED_NUM,
SUM(CASE WHEN POLICY_ACTION = ''CHALLENGE'' AND CHALLENGE_SUCCESSFUL = ''Y'' THEN 1 ELSE 0 END) AS TRIGGERED_SUCCESSFUL_NUM,
SUM(case WHEN CHANNEL_INDICATOR = ''WEB'' then 1 else 0 end ) AS WEB_TRANS_NUM,--WEB交易量
SUM(case WHEN CHANNEL_INDICATOR = ''MOBILE'' then 1 else 0 end ) AS MOBILE_TRANS_NUM,--Mobile交易量
SUM(case WHEN '||get_vale_from_cd1('6','4')||' = ''IPAD'' then 1 else 0 end ) AS IPDA_TRANS_NUM,--Ipad交易量
(SELECT SUM(CASE WHEN T1.ACSPNAME = ''QUESTION'' AND T1.STATUS = ''ACTIVE'' THEN 1 ELSE 0 END) FROM ACSPUSERACCOUNT T1 WHERE TO_DATE(to_char( T1.lastmodified,''yyyy-mm-DD HH24:MI:SS'' ),''yyyy-mm-DD HH24:MI:SS'') > TO_DATE('''||TO_CHAR(VAR_BEGIN_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'') AND TO_DATE(to_char( T1.lastmodified,''yyyy-mm-DD HH24:MI:SS'' ),''yyyy-mm-DD HH24:MI:SS'') <= TO_DATE('''||TO_CHAR(VAR_END_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'') )AS QA_LOGIN_NUM,
(SELECT SUM(CASE WHEN T1.ACSPNAME = ''SMS'' AND T1.STATUS = ''ACTIVE'' THEN 1 ELSE 0 END) FROM ACSPUSERACCOUNT T1 WHERE TO_DATE(to_char( T1.lastmodified,''yyyy-mm-DD HH24:MI:SS'' ),''yyyy-mm-DD HH24:MI:SS'') > TO_DATE('''||TO_CHAR(VAR_BEGIN_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'') AND TO_DATE(to_char( T1.lastmodified,''yyyy-mm-DD HH24:MI:SS'' ),''yyyy-mm-DD HH24:MI:SS'') <= TO_DATE('''||TO_CHAR(VAR_END_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS''))AS SMS_LOGIN_NUM,
(SELECT SUM(CASE WHEN T1.ACSPNAME = ''CCC'' AND T1.STATUS = ''ACTIVE'' THEN 1 ELSE 0 END) FROM ACSPUSERACCOUNT T1 WHERE TO_DATE(to_char( T1.lastmodified,''yyyy-mm-DD HH24:MI:SS'' ),''yyyy-mm-DD HH24:MI:SS'') > TO_DATE('''||TO_CHAR(VAR_BEGIN_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'') AND TO_DATE(to_char( T1.lastmodified,''yyyy-mm-DD HH24:MI:SS'' ),''yyyy-mm-DD HH24:MI:SS'') <= TO_DATE('''||TO_CHAR(VAR_END_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS''))AS CC_LOGIN_NUM,
''11111'',
(SELECT COUNT(USERNAME) FROM USERS T2 WHERE T2.CREATED >= TO_DATE( '''||TO_CHAR(VAR_BEGIN_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'')
AND T2.CREATED <= TO_DATE('''||TO_CHAR(VAR_END_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'') ) AS CREATE_CUSTOMR_FILE_NUM ,
SUM(CASE WHEN POLICY_ACTION = ''ALLOW'' then 1 else 0 end ) as ALLOW_TRANS_NUM,
SUM(CASE WHEN POLICY_ACTION = ''REVIEW'' then 1 else 0 end ) as REVIEW_TRANS_NUM,
SUM(CASE WHEN POLICY_ACTION = ''AHALLENGE'' then 1 else 0 end ) as CHALLENGE_TRANS_NUM,
SUM(CASE WHEN POLICY_ACTION = ''DENY'' then 1 else 0 end ) as DENY_TRANS_NUM,
SUM(RISK_SCORE) AS TOTAL_SCORE_RANGE,
SUM(GET_AMT_BY_CURRENCY(AMOUNT_ORIGINAL,AMOUNT_CURRENCY)) AS TOTAL_AMOUNT--通过汇率表和币种转换再求和
FROM EVENT_LOG_REALTIME T
WHERE SYS_CREATION_DATE >= TO_DATE('''||TO_CHAR(VAR_BEGIN_TIME,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'') AND SYS_CREATION_DATE <= TO_DATE('''||TO_CHAR(VAR_END_TIME,'YYYY-MM-DD HH24:MI:SS')||''' ,''YYYY-MM-DD HH24:MI:SS'')
AND HAS_USED = ''T''
AND T.HAS_USED_TIME=T.LASTMODIFIED
GROUP BY
TO_DATE(SUBSTR(TO_CHAR(SYS_CREATION_DATE,''YYYY-MM-DD HH24:MI:SS''),0,16),''YYYY-MM-DD HH24:MI''),
get_province(IP_COUNTRY,IP_CITY,ip_region) ,
GET_NAME_BY_CODE(GET_TOTAL_EVENT_TYPE(T.EVENT_TYPE,T.USER_DEFINED_EVENT_TYPE),''eventType'') ,
GET_SCORE_RANGE(T.RISK_SCORE) ,
NVL(POLICY_RULE_ID,''FALLBACK_RULE'') ,
POLICY_ACTION,
CHALLENGE_SUCCESSFUL,
CHALLENGE_AUTH_METHOD,
SUBSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),0,INSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),''+'')-1),--优先级
SUBSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),INSTR(GET_RULE_ORDER_ID(ORG_ID,POLICY_RULE_ID),''-'')+1),--描述
NVL(IS_DEVICE_BOUND,''N''),
CHANNEL_INDICATOR,
OPERATING_SYSTEM,
BROWSER_TYPE,
FLAGGED,
RESOLUTION ';
-- insert into test (test_name) values(VAR_DYNAMIC_SQL);
--insert into test (test_name) values(TO_CHAR(VAR_BEGIN_TIME));
--insert into test (test_name) values(TO_CHAR(VAR_END_TIME));
-- commit;
execute immediate VAR_DYNAMIC_SQL;
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式