Home > database >  Oracle call a stored procedure and return the cursor result sets, please advise
Oracle call a stored procedure and return the cursor result sets, please advise

Time:09-23

The following is baotou
The CREATE OR REPLACE PACKAGE REPORTUSER. REPORT_CN_UA IS

PROCEDURE SALES_BYGROUP (
V_REPORT_DATE_DRG IN VARCHAR2,
V_SBS_NO_LOK IN VARCHAR2,
V_STORE_NO_LOK IN VARCHAR2,
"REPORT_CURSOR OUT SYS_REFCURSOR
);
END REPORT_CN_UA;

Here are inclusions
The CREATE OR REPLACE PACKAGE BODY REPORTUSER. REPORT_CN_UA IS

The FUNCTION COMMON_FILTERS
(
V_REPORT_DATE_DRG IN VARCHAR2,
DATE_COL IN VARCHAR2,
V_SBS_NO_LOK IN VARCHAR2,
SBS_COL IN VARCHAR2,
V_STORE_NO_LOK IN VARCHAR2,
STORE_COL VARCHAR2 IN
)
RETURN LONG
AS
TMPSTRSQL LONG;
The BEGIN
IF the TRIM (V_REPORT_DATE_DRG) IS NOT NULL THEN
TMPSTRSQL:=TMPSTRSQL | | 'AND,' | | PKG_PARSER. GETRANGESHORTDATESTR (V_REPORT_DATE_DRG DATE_COL, DATE_COL) | | ') '.
END IF;
IF the TRIM (V_SBS_NO_LOK) IS NOT NULL THEN
TMPSTRSQL:=TMPSTRSQL | | 'AND' | | SBS_COL | | 'IN' | | V_SBS_NO_LOK;
END IF;
IF the TRIM (V_STORE_NO_LOK) IS NOT NULL THEN
TMPSTRSQL:=TMPSTRSQL | | 'AND,' | | SBS_COL | | ', '| | STORE_COL | |') IN the '| | V_STORE_NO_LOK;
END IF;

RETURN TMPSTRSQL;
END COMMON_FILTERS;

PROCEDURE SALES_BYGROUP (
V_REPORT_DATE_DRG IN VARCHAR2,
V_SBS_NO_LOK IN VARCHAR2,
V_STORE_NO_LOK IN VARCHAR2,
"REPORT_CURSOR OUT SYS_REFCURSOR
) IS

TMPSTRSQL CLOB.
ARRDATE TOKENTABLETYPE;
DATEFROM DATE;
DATETILL DATE;
DATEFROMSTR VARCHAR2 (100);
DATETILLSTR VARCHAR2 (100);
The BEGIN

IF the TRIM (V_REPORT_DATE_DRG) IS NOT NULL THEN
ARRDATE:=PKG_PARSER GETTOKEN (V_REPORT_DATE_DRG, ', ');
IF ARRDATE. LAST=3 THEN

DATEFROM=TO_DATE (TRIM (' ' ' 'the FROM ARRDATE (2)), PKG_PARSER. SHORT_DATE_FORMATE);
DATETILL:=TO_DATE (TRIM (' ' ' 'the FROM ARRDATE (3)), PKG_PARSER. SHORT_DATE_FORMATE);

DATEFROMSTR:=ARRDATE (2);
DATETILLSTR:=ARRDATE (3);

The ELSE
DATEFROM=TRUNC (SYSDATE ());
DATETILL:=TRUNC (SYSDATE ());

DATEFROMSTR:=' '| | TO_CHAR (SYSDATE (), PKG_PARSER. SHORT_DATE_FORMATE) | |' ' ' ';
DATETILLSTR:=' '| | TO_CHAR (SYSDATE (), PKG_PARSER. SHORT_DATE_FORMATE) | |' ' ' ';
END IF;
The ELSE
DATEFROM=TRUNC (SYSDATE ());
DATETILL:=TRUNC (SYSDATE ());

DATEFROMSTR:=' '| | TO_CHAR (SYSDATE (), PKG_PARSER. SHORT_DATE_FORMATE) | |' ' ' ';
DATETILLSTR:=' '| | TO_CHAR (SYSDATE (), PKG_PARSER. SHORT_DATE_FORMATE) | |' ' ' ';
END IF;

TMPSTRSQL:='
SELECT ';
IF the TRIM (V_REPORT_DATE_DRG) IS NOT NULL THEN
TMPSTRSQL:=TMPSTRSQL | | DATEFROMSTR | | 'AS the START_DATE,';
TMPSTRSQL:=TMPSTRSQL | | DATETILLSTR | | 'AS END_DATE,';
END IF;
TMPSTRSQL:=TMPSTRSQL | |
'
INVC SBS_NO AS PARTNER,
STO. STORE_NAME AS STORE_NAME,
STO UDF1_VALUE AS STORE_CODE,
CASE the WHEN STO. PRICE_LVL=1 THEN "BH" ELSE "FH" 'END as STORE_TYPE,
STO ADDRESS6 AS CITY,
STO TOTAL_SURFACE AS SQM,
The SUM (CASE WHEN INVC. INVC_TYPE=2 THEN ITEM. ELSE QTY * - 1 ITEM, QTY END) AS UNITS,
The SUM (ITEM. The ITEM PRICE *. QTY * CASE WHEN INVC. THEN 1 ELSE INVC_TYPE=2 1 END) AS SALES,
The SUM (ITEM. ORIG_PRICE * ITEM. QTY * CASE WHEN INVC. THEN 1 ELSE INVC_TYPE=2 1 END) AS ORIG_SALES,
STO GLOB_STORE_CODE AS STORE_CODE1,
DECODE (SUBSTR (DCS_CODE, 0, 3), ' '101', 'App', '102', 'Footware', '104', ' ' ' 'Acc) AS GROUP_TYPE
The FROM INVOICE_V INVC, INVC_ITEM ITEM, STORE_V STO, INVENTORY_V INVEN
WHERE
INVC. INVC_SID=ITEM. INVC_SID
AND INVC. STORE_NO=STO. STORE_NO AND INVC. SBS_NO=STO. SBS_NO
AND INVEN. ITEM_SID=ITEM. ITEM_SID AND INVEN. SBS_NO=INVC. SBS_NO
AND INVC. HISEC_TYPE IS NULL
AND INVC. STATUS2=0 ';
TMPSTRSQL:=TMPSTRSQL | | COMMON_FILTERS (V_REPORT_DATE_DRG, 'TRUNC (INVC. CREATED_DATE)', V_SBS_NO_LOK, 'INVC. SBS_NO, V_STORE_NO_LOK,' INVC. STORE_NO ');

TMPSTRSQL:=TMPSTRSQL | | '
GROUP BY
INVC SBS_NO,
STO. STORE_NAME,
STO UDF1_VALUE,
CASE the WHEN STO. PRICE_LVL=1 THEN "BH" ELSE "FH" 'END,
STO ADDRESS6,
STO TOTAL_SURFACE,
STO GLOB_STORE_CODE,
DECODE (SUBSTR (DCS_CODE, 0, 3), ' '101', 'App', '102', 'Footware', '104', 'Acc')
The ORDER BY INVC SBS_NO, STO. STORE_NAME
';
OPEN "REPORT_CURSOR" FOR
TMPSTRSQL;
END SALES_BYGROUP;

END REPORT_CN_UA;

How do I call this function, I also tried my calls, can not, how can you write this call SQL statements?


Attach I write call SQL

DECLARE
"REPORT_CURSOR SYS_REFCURSOR;"
V_REPORT_DATE_DRG varchar2 (10);
V_SBS_NO_LOK varchar2 (100);
V_STORE_NO_LOK varchar2 (100);
The begin
V_REPORT_DATE_DRG:=TO_CHAR (sysdate, 'the MM/DD/YYYY).
Dbms_output. Put_line (V_REPORT_DATE_DRG);
V_SBS_NO_LOK:='1';
V_STORE_NO_LOK:='0';
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related