PostgreSQL:如何在查询中定义PARAMETER?

时间:2015-12-22 00:38:45

标签: postgresql

在MSSQL中,我通常使用以下参数:

declare @StartDate as date, @EndDate as date
set @StartDate  = '08/01/2015' set @EndDate = '08/15/2015'

----------- and use it here as my Date Range of Records:

Select * from Table_Name 
where DateRange between @StartDate and @EndDate 

如何在PostgreSQL中执行此操作以生成报告/记录?

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

这样做 在$ BODY $

之后
DECLARE startdate date;
DECLARE enddate date;

开始后

startdate ='2015-08-01';
Enddate ='2015-08-15';

retrun query 

select * from Table where daterange between startdate and endate