Geoserver SQL View

时间:2017-08-04 13:00:40

标签: sql geoserver

I am trying to create a view in Geoserver and pass three parameters, including a parameter for an operator but seem to be having problems.

My code is:

SELECT proposed_water_reticulation.*
FROM rev_1.proposed_water_reticulation
WHERE proceed = '%a%' AND pipe_diam '%b%' '%c%';

Ultimately I am trying to let the user pass an operator sign to b and then a value to c. Is this possible?

eg:

SELECT proposed_water_reticulation.*
FROM rev_1.proposed_water_reticulation
WHERE proceed = 'YES' AND pipe_diam '>' '150';

1 个答案:

答案 0 :(得分:0)

我对Geoserver一无所知,也不确定此响应是否有用,但在SQL Server中你可以这样做

CREATE PROCEDURE spRunSomeSQL
(
    @a BIT,
    @b VARCHAR(3),
    @c INT
)
AS
BEGIN
   -- error check @b here to see if it is a valid operator
    DECLARE @sql VARCHAR(MAX)

    SET @sql = 'SELECT proposed_water_reticulation.*
                FROM rev_1.proposed_water_reticulation
                WHERE proceed = '+ CONVERT(VARCHAR(1),@a) +' AND pipe_diam ' + @b + CONVERT(VARCHAR(32),@c)

    EXEC (@sql)
END