SQL Server 查询中的这个参数 - 我复制到我正在编写的 Oracle 查询,但它没有编译:
PROCEDURE OGEN.DBD_NOT_GET_NOTES_DETAIL 的编译错误
错误:PLS-00103:在预期以下情况之一时遇到符号“(”:
:= 。) , @ % 默认字符
符号 ":=" 被替换为 "(" 以继续。行: 6 文本: , NOTETYPE NUMERIC(1) = 1
如何在 Oracle 中编写代码?
完整的 SQL Server T-SQL 查询:
ALTER PROCEDURE [OEN].[DB_NOT_GET_NOTES_DETAIL]
(
@FACILITYKEY CHAR(4),
@DATEFROM DATETIME,
@DATETHRU DATETIME,
@UNITSTR VARCHAR(250),
@NOTETYPE NUMERIC(1) = 1
)
AS
BEGIN
SELECT P.FACILITY_KEY, P.PAT_NUMBER, P.PATIENT_ID,
OEN.DATEONLY(N.CREATED_ON) CREATED_ON, N.NOTE_HEADER,
N.CREATED_BY, P.LAST_NAME, P.FIRST_NAME, P.MIDDLE_NAME, P.UNIT_CODE
FROM OEN.EN_M_PATIENT_MAST P INNER JOIN OPTC.NOT_M_MAST N
ON (P.PAT_NUMBER = N.PAT_NUMBER AND N.FACILITY_KEY = @FACILITYKEY)
WHERE N.NOTE_STATUS = 0
AND (OEN.DATEONLY(N.CREATED_ON) BETWEEN OEN.DATEONLY(@DATEFROM) AND OEN.DATEONLY(@DATETHRU))
AND (@UNITSTR IS NULL OR @UNITSTR = '' OR CHARINDEX(P.UNIT_CODE, @UNITSTR) % 2 = 1)
AND @NOTETYPE = 1
END
甲骨文版本:
CREATE OR REPLACE PROCEDURE OEN.DBD_NOT_GET_NOTES_DETAIL (
FACILITYKEY varchar2
, DATEFROM DATE
, DATETHRU DATE
, UNITSTR varchar2
, NOTETYPE NUMERIC(1) = 1
, OCURSOR OUT SYS_REFCURSOR
) as
BEGIN
OPEN OCURSOR FOR
SELECT P.FACILITY_KEY,
P.PAT_NUMBER,
P.PATIENT_ID,
OEN.DATEONLY(N.CREATED_ON) CREATED_ON, N.NOTE_HEADER,
N.CREATED_BY, P.LAST_NAME, P.FIRST_NAME, P.MIDDLE_NAME, P.UNIT_CODE
FROM OEN.EN_M_PATIENT_MAST P
INNER JOIN OPTC.NOT_M_MAST N ON (P.PAT_NUMBER = N.PAT_NUMBER AND N.FACILITY_KEY = FACILITYKEY)
WHERE N.NOTE_STATUS = 0
AND (OEN.DATEONLY(N.CREATED_ON) BETWEEN OEN.DATEONLY(DATEFROM) AND OEN.DATEONLY(DATETHRU))
AND CREATED_ON BETWEEN DATEFROM AND DATETHRU
AND (UNITSTR IS NULL OR P.UNIT_CODE = UNITSTR);
END;