简体   繁体   English

Sql 基于输入参数的限制子句

[英]Sql Limit clause based in input Parameter

I have been trying to find a solution for a limit-clause based on an input parameter from a Json-File.我一直在尝试根据来自 Json 文件的输入参数找到限制子句的解决方案。 The current code looks somewhat like this当前代码看起来有点像这样

With myJsonTable (JsonText)
as (
Select JsonText)

Select * from Data
Where...

Limit 
  Case
   WHEN (Select JSON_VALUE(JsonText, '$."Amount"') From myJsonTable is not null
     THEN (Select JSON_VALUE(JsonText, '$."Amount"') From myJsonTable)
     ELSE (10000000)
  END

Which I cant seem to get work.我似乎无法找到工作。 The Output I am getting is我得到的 Output 是

Non-negative integeter value expected in LIMIT clause

Is there a way to cast the select done?有没有办法完成 select? Trying different Selects anywhere in the Case clause caused the same error.在 Case 子句中的任何地方尝试不同的 Selects 都会导致同样的错误。

Exasol only allows constant expression in the limit clause, so it's not directly possible to specify a select statement that references myJsonTable there. Exasol 只允许在 limit 子句中使用常量表达式,因此无法直接在其中指定引用myJsonTable的 select 语句。

However, you can workaround this issue by using a approach similar to SQL query for top 5 results without the use of LIMIT/ROWNUM/TOP但是,您可以通过使用类似于SQL 查询前 5 个结果的方法来解决此问题,而无需使用 LIMIT/ROWNUM/TOP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM