后端是 PostgreSQL 服务器 9.1。
我正在尝试构建 AdHoc XML 报告。报告文件将包含 SQL 查询,所有这些查询都必须以 SELECT 语句开头。SQL 查询将具有参数。根据相关列的数据类型,这些参数将相应地呈现给用户以提供值。
粗略的 SQL 查询:
SELECT * FROM customers
WHERE
(
customers.customer_code=@customer_code AND customers.location=@location
AND customers.type=
(
SELECT type from types
WHERE types.code=@type_code
AND types.is_active = @type_is_active
)
AND customers.account_open_date BETWEEN @start_date AND @end_date
)
OR customers.flagged = @flagged;
我想从查询字符串中获取列名和参数的列表,并将它们放入字符串数组并稍后处理。
我只能使用以下正则表达式匹配参数:
@(?)(?<parameter>\w+)
预期比赛:
customers.customer_code=@customer_code
customers.location=@location
types.code=@type_code
types.is_active = @type_is_active
customers.account_open_date BETWEEN @start_date AND @end_date
customers.flagged = @flagged
如何立即匹配“@Parameter”、“=”和“BETWEEN”?