Hi,
I wrote the following stored procedure:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
Alter PROCEDURE [dbo].[UW_VACANCIES_VACANCYMODULE_SEARCH]
@SQL nvarchar(4000),
@PageIndex INT,
@NumRows INT,
@VacancyCount INT OUTPUT
AS
BEGIN
SELECT @VacancyCount = (SELECT COUNT(*) FROM VW_VACANCYMODULE_ACTIVE_VACANCIES WHERE @SQL)
Declare @StartRowIndex INT;
Set @StartRowIndex = (@PageIndex * @NumRows) + 1;
WITH VacancyEntries AS (
SELECT ROW_NUMBER() OVER (ORDER BY DATE_VALID_FROM DESC)AS Row,
ID,
SHIFT_HOURS,
DATE_VALID_FROM,
TITLE,
JOB_DESCRIPTION,
BENEFITS_DESCRIPTION,
SALARY_PAYAMOUNT_MIN,
SALARY_PAYAMOUNT_MAX,
EXPERIENCE_YEARS,
REQUIRED_SKILLS_DESCRIPTION,
SCHEDULE_TYPE,
CLASSIFICATION_TYPE,
BRH_ID,
FNC_ID,
UME_ID
FROM VW_VACANCYMODULE_ACTIVE_VACANCIES
Where @SQL
)
SELECT
ID,
SHIFT_HOURS,
DATE_VALID_FROM,
TITLE,
JOB_DESCRIPTION,
BENEFITS_DESCRIPTION,
SALARY_PAYAMOUNT_MIN,
SALARY_PAYAMOUNT_MAX,
EXPERIENCE_YEARS,
REQUIRED_SKILLS_DESCRIPTION,
SCHEDULE_TYPE,
CLASSIFICATION_TYPE,
BRH_ID,
FNC_ID,
UME_ID
FROM VacancyEntries
WHERE Row between @StartRowIndex and @StartRowIndex+@NumRows-1
END
I would like to pass the where clause as a parameter (e.g.: ID=2 AND Name Like '%Jo%')
But I am getting an error where I on the line:
SELECT @VacancyCount = (SELECT COUNT(*) FROM VW_VACANCYMODULE_ACTIVE_VACANCIES WHERE @SQL)
It doesnt seem to accept @SQL, its giving the following error message:
An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Is it in anyway possible to resolve this problem?
I wrote the following stored procedure:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
Alter PROCEDURE [dbo].[UW_VACANCIES_VACANCYMODULE_SEARCH]
@SQL nvarchar(4000),
@PageIndex INT,
@NumRows INT,
@VacancyCount INT OUTPUT
AS
BEGIN
SELECT @VacancyCount = (SELECT COUNT(*) FROM VW_VACANCYMODULE_ACTIVE_VACANCIES WHERE @SQL)
Declare @StartRowIndex INT;
Set @StartRowIndex = (@PageIndex * @NumRows) + 1;
WITH VacancyEntries AS (
SELECT ROW_NUMBER() OVER (ORDER BY DATE_VALID_FROM DESC)AS Row,
ID,
SHIFT_HOURS,
DATE_VALID_FROM,
TITLE,
JOB_DESCRIPTION,
BENEFITS_DESCRIPTION,
SALARY_PAYAMOUNT_MIN,
SALARY_PAYAMOUNT_MAX,
EXPERIENCE_YEARS,
REQUIRED_SKILLS_DESCRIPTION,
SCHEDULE_TYPE,
CLASSIFICATION_TYPE,
BRH_ID,
FNC_ID,
UME_ID
FROM VW_VACANCYMODULE_ACTIVE_VACANCIES
Where @SQL
)
SELECT
ID,
SHIFT_HOURS,
DATE_VALID_FROM,
TITLE,
JOB_DESCRIPTION,
BENEFITS_DESCRIPTION,
SALARY_PAYAMOUNT_MIN,
SALARY_PAYAMOUNT_MAX,
EXPERIENCE_YEARS,
REQUIRED_SKILLS_DESCRIPTION,
SCHEDULE_TYPE,
CLASSIFICATION_TYPE,
BRH_ID,
FNC_ID,
UME_ID
FROM VacancyEntries
WHERE Row between @StartRowIndex and @StartRowIndex+@NumRows-1
END
I would like to pass the where clause as a parameter (e.g.: ID=2 AND Name Like '%Jo%')
But I am getting an error where I on the line:
SELECT @VacancyCount = (SELECT COUNT(*) FROM VW_VACANCYMODULE_ACTIVE_VACANCIES WHERE @SQL)
It doesnt seem to accept @SQL, its giving the following error message:
An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Is it in anyway possible to resolve this problem?