procedure creation error due to a variable that is being referenced.

Database

procedure creation error due to a variable that is being referenced.

I am getting error for procedure creation where i wanted to resolve the value for the tmpval (which is part of the table name in the drop table sytax)

the tmpval is being set but is not being referenced .how can i make it work ?

REPLACE PROCEDURE  send_tst_param

  (  

   OUT Message     integer

  )

 Begin

 Declare tmpval VARCHAR(6) ;

 select     cast(cast(add_months(current_date,-1) as date format  'yyyymmdd')as varchar(6))  into tmpval

;

sel count(1) into message from  gdw_stg_dev3.pmt_brand_d_tmpval;

End;

1 REPLY
Junior Supporter

Re: procedure creation error due to a variable that is being referenced.

You need to use dinamic SQL to reference the different table(s) that you may get from the DATE SELECT.

Cheers.

Carlos.