请教,ORACLE中SQL语句最大长度是多少
4个回答
展开全部
你好:我知道的是最大可执行长度为6000个字符。通常在procedure中sql拼接的时候会有这个问题,一边解决方案是设置function对逻辑分别处理来实现减少sql长度的。
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;
展开全部
没有限制。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有这个说法的吧。有的就是参数里面可以规定字符的长度
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询