你能帮我吗,请修复下面的SQL语句,我在第一行有错误。感谢
DECLARE @T_SYS_FROM SMALLINT,VARCHAR(8);
SET @T_SYS_FROM = 20200922,DATE;
SELECT
T_SYS_FROM,
N_D_AHDJ,
N_FUND_ID,
N_AHDJ,
T_SYS_USER,
BUDAT
FROM
dss.acn_ahdj_h
where
T_SYS_FROM=@ T_SYS_FROM
ORDER by
T_SYS_USER;
您的DECLARE
看起来像是从另一种SQL方言中获取语法,因为它不是有效的Oracle PL/SQL语法。
如果您使用PL/SQL,那么类似于(假设您的查询将只返回一行(:
DECLARE
v_your_date DATE := DATE '2020-09-22';
v_T_SYS_FROM dss.acn_ahdj_h.T_SYS_FROM%TYPE;
v_N_D_AHDJ dss.acn_ahdj_h.N_D_AHDJ%TYPE;
v_N_FUND_ID dss.acn_ahdj_h.N_FUND_ID%TYPE;
v_N_AHDJ dss.acn_ahdj_h.N_AHDJ%TYPE;
v_T_SYS_USER dss.acn_ahdj_h.T_SYS_USER%TYPE;
v_BUDAT dss.acn_ahdj_h.BUDAT%TYPE;
BEGIN
SELECT T_SYS_FROM,
N_D_AHDJ,
N_FUND_ID,
N_AHDJ,
T_SYS_USER,
BUDAT
INTO v_T_SYS_FROM,
v_N_D_AHDJ,
v_N_FUND_ID,
v_N_AHDJ,
v_T_SYS_USER,
v_BUDAT
FROM dss.acn_ahdj_h
WHERE T_SYS_FROM = v_your_date
ORDER BY T_SYS_USER;
END;
/
如果您想要SQL查询,那么:
SELECT T_SYS_FROM,
N_D_AHDJ,
N_FUND_ID,
N_AHDJ,
T_SYS_USER,
BUDAT
FROM dss.acn_ahdj_h
WHERE T_SYS_FROM = DATE '2020-09-22'
ORDER BY T_SYS_USER;