Hello ...
I'm trying to create a Stored Procedure that receives two parameters (both are Date). The SP must create a View from a Select containing two JOIN and three WHERE conditions involving the two parameters.
I am working with DB2 9.7 FixPack 2 on Windows 7 32-bit and IBM Data Studio 2.2.
The problem I have is that by making the deployment of the SP returns the following error:
The code of my SP is as follows:
Can anyone help me?
I'm trying to create a Stored Procedure that receives two parameters (both are Date). The SP must create a View from a Select containing two JOIN and three WHERE conditions involving the two parameters.
I am working with DB2 9.7 FixPack 2 on Windows 7 32-bit and IBM Data Studio 2.2.
The problem I have is that by making the deployment of the SP returns the following error:
COBR.SP_CREATEV IEWMOVCUSTOMER: 17: "STARTDATEMONIT OR" is not valid in the context .. Where It is Used SQLCODE =- 206, SQLSTATE = 42703, DRIVER = 3.61.65The code of my SP is as follows:
Code:
CREATE PROCEDURE SP_CreateViewMovCustomer (StartDateMonitor IN DATE, FinishDateMonitor IN DATE) SPECIFIC SP_CreateViewMovCustomer P1: BEGIN If Exists (Select 1 From SYSIBM.SYSVIEWS Where Name = 'VIEWMOVCUSTOMER' and creator = 'Cobra') Then DROP VIEW COBR.VIEWMOVCUSTOMER; End If; CREATE view COBR.VIEWMOVCUSTOMER (CustCod, PolCod, MonCod, RamCod, EmiTypeCod, EmiNro, EmiDate, MovTypeCod, MovPolNro) AS SELECT CUST.CustCod, POL.PolCod, POL.MonCod, POL.RamCod, MOV.EmiTypeCod, MOV.EmiNro, MOV.EmiDate, MOV.MovTypeCod, MOV.MovPolNro FROM COBR.CUSTOMER AS CUST JOIN COBR.POLICY AS POL ON CUST.CustomerCod = POL.CustomerCod JOIN COBR.MOVEMENTS AS MOV ON MOV.PolCod = POL.PolCod and MOV.MonCod = POL.MonCod and MOV.RamCod = POL.RamCod WHERE MOV.MovTypeCod = 'PAY' and MOV.MovPolDate> = StartDateMonitor and MOV.MovPolDate <= FinishDateMonitor; END P1
Comment