变量中的声明列不起作用

发布于 2025-02-12 06:39:14 字数 1520 浏览 1 评论 0原文

我正在尝试在变量中声明该列,并想在程序中调用该变量。 这是我的光学查询代码,它返回我 - 找不到列。 请帮助了解我的查询中的问题。

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
import module namespace ofn="http://marklogic.com/optic/expression/fn" at "/MarkLogic/optic/optic-fn.xqy";
import module namespace osql="http://marklogic.com/optic/expression/sql" at "/MarkLogic/optic/optic-sql.xqy";  
declare option xdmp:mapping "false";
let $view := op:from-view("GTM2_Shipment", "Shipment_View")
let $count := op:view-col("Shipment_View", "Ancillary_QuotePrice")
return $view
=> op:where(op:and((
                   op:gt(op:col("$count"), 0)

                   ))
                   )
=> op:group-by("transMode", op:count("QuotePrice", "$count"))
=> op:result()

这是我得到的结果 -

[1.0-ml] SQL-NOCOLUMN: Column not found: $count
Stack Trace
At line 1 column 2:
In sem:execute(plan:sparql(" * { sample(transMode) AS transMode) count($count) AS QuotePrice) { FILTER ($count gt xs:integer("0") and fn:format-dateTime(xs:dateTime(BookingCreateDt), xs:string("[Y0001]-[M01]-[D01]")) gt sql:dateadd(xs:string("month"), xs:int("-6"), fn:format-dateTime(xs:dateTime("2022-06-30T10:42:50.2654743+01:00"), xs:string("[Y0001]-[M01]-[D01]")))) } GROUP BY transMode }"), (), ()

我还试图像这样声明列 - 让$ count:= op:col(“ ancillary_quoteprice”) 而且它没有从视图中识别列,而是给出相同的错误。

I am trying to declare the column in a variable and want to call that variable inside my program.
Here is my optic query code which returns me - Column not found.
Please help to understand the problem in my query.

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
import module namespace ofn="http://marklogic.com/optic/expression/fn" at "/MarkLogic/optic/optic-fn.xqy";
import module namespace osql="http://marklogic.com/optic/expression/sql" at "/MarkLogic/optic/optic-sql.xqy";  
declare option xdmp:mapping "false";
let $view := op:from-view("GTM2_Shipment", "Shipment_View")
let $count := op:view-col("Shipment_View", "Ancillary_QuotePrice")
return $view
=> op:where(op:and((
                   op:gt(op:col("$count"), 0)

                   ))
                   )
=> op:group-by("transMode", op:count("QuotePrice", "$count"))
=> op:result()

here is the result I get -

[1.0-ml] SQL-NOCOLUMN: Column not found: $count
Stack Trace
At line 1 column 2:
In sem:execute(plan:sparql(" * { sample(transMode) AS transMode) count($count) AS QuotePrice) { FILTER ($count gt xs:integer("0") and fn:format-dateTime(xs:dateTime(BookingCreateDt), xs:string("[Y0001]-[M01]-[D01]")) gt sql:dateadd(xs:string("month"), xs:int("-6"), fn:format-dateTime(xs:dateTime("2022-06-30T10:42:50.2654743+01:00"), xs:string("[Y0001]-[M01]-[D01]")))) } GROUP BY transMode }"), (), ()

I have also tried to declare the column like this-
let $count := op:col("Ancillary_QuotePrice")
And it doesnot recognize the column from the view and gives the same error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执妄 2025-02-19 06:39:19

一旦$ count定义为op:view-col(),然后将其用作变量。请参阅下面的建议:

  • op:gt(op:col(“ $ count”),0),0) ----更改为 - > OP:GT($ Count,0)

  • op:count(“ quoteprice”,“ $ count”) --------------------更改为 - > op:count(“ quoteprice”,$ count)

Once $count is defined as an op:view-col(), then just use it as a variable. See suggestions below:

  • op:gt(op:col("$count"), 0) ---change to--> op:gt($count, 0)

  • op:count("QuotePrice", "$count") ---change to--> op:count("QuotePrice", $count)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文