Web サイトの一部用に新しい Oracle パッケージの作成に取り組んでいます。パッケージを実行すると 6 つの結果が得られ、SQL を直接実行すると 8 つの結果が得られます。現在、すべてをハードコーディングしているため、SQL に関して動的なものは何もありません。ハードコードされた正確なSQLを使用しているため、それらがどのように異なる結果になるかわかりません。
PACKAGE RESULTS:
BEGIN
DBMS_OUTPUT.ENABLE (1000000);
INTERNET.Appt.GetAppointments(:p_OpenAppointments);
END;
CREATE OR REPLACE PACKAGE INTERNET."Appt" AS タイプ ResultSet は参照カーソルです。
procedure GetAppointments(
p_Appointments OUT ResultSet );
END アプリケーション; /
procedure GetAppointments(
p_Appointments OUT ResultSet )
IS
v_sql varchar2(5000);
BEGIN
OPEN p_Appointments FOR
SELECT
tableC.legalname Carrier,
tableAli.st State,
tableType.contracttypename ContractType,
tableStatus.contractsttsname Status,
tableContracting.carrieragtnbr ApptNo,
NVL (TO_CHAR (tableAppt.apptdt, 'MM/DD/YYYY'), 'N/A') Effective,
tableAppt.apptdt,
tableAppt.dtverified,
tableAli.residentyn,
decode(nvl(tableAli.residentyn, 'U'), 'R', 'Resident', 'N', 'Non-Resident', 'Unknown') residentdesc
FROM
tableType,
tableC,
tableContract,
tableSubAccount,
tableContracting,
tableStatus,
tableAli,
tableAppt,
organization
WHERE
tableAppt.contractingid = tableContracting.contractingid
AND tableAppt.agtlicenseid = tableAli.agtlicenseid
AND tableContracting.gasubaccountid = tableSubAccount.gasubaccountid
AND tableContracting.agentnbrid = tableAli.agentnbrid
AND tableContracting.contracttypeid = tableType.contracttypeid
AND tableAppt.currentstatus = tableStatus.contractsttsid
AND tableSubAccount.gacontractid = tableContract.gacontractid
AND tableContract.carrierid = tableC.carrierid
AND tableSubAccount.organizationid = organization.organizationid
AND tableContracting.agentnbrid = 123456
AND
(
(tableAppt.currentstatus = 1)
OR
(tableAppt.currentstatus = 3 AND tableAppt.dateterminated >= trunc(sysdate-60))
)
ORDER BY
tableStatus.contractsttsname,
tableC.legalname;
END GetAppointments
SQL RESULTS:
SELECT
tableC.legalname Carrier,
tableAli.st State,
tableType.contracttypename ContractType,
tableStatus.contractsttsname Status,
tableContracting.carrieragtnbr ApptNo,
NVL (TO_CHAR (tableAppt.apptdt, 'MM/DD/YYYY'), 'N/A') Effective,
tableAppt.apptdt,
tableAppt.dtverified,
tableAli.residentyn,
decode(nvl(tableAli.residentyn, 'U'), 'R', 'Resident', 'N', 'Non-Resident', 'Unknown') residentdesc
FROM
tableType,
tableC,
tableContract,
tableSubAccount,
tableContracting,
tableStatus,
tableAli,
tableAppt,
organization
WHERE
tableAppt.contractingid = tableContracting.contractingid
AND tableAppt.agtlicenseid = tableAli.agtlicenseid
AND tableContracting.gasubaccountid = tableSubAccount.gasubaccountid
AND tableContracting.agentnbrid = tableAli.agentnbrid
AND tableContracting.contracttypeid = tableType.contracttypeid
AND tableAppt.currentstatus = tableStatus.contractsttsid
AND tableSubAccount.gacontractid = tableContract.gacontractid
AND tableContract.carrierid = tableC.carrierid
AND tableSubAccount.organizationid = organization.organizationid
AND tableContracting.agentnbrid = 123456
AND
(
(tableAppt.currentstatus = 1)
OR
(tableAppt.currentstatus = 3 AND tableAppt.dateterminated >= trunc(sysdate-60))
)
ORDER BY
tableStatus.contractsttsname,
tableC.legalname;