变量中的声明列不起作用
我正在尝试在变量中声明该列,并想在程序中调用该变量。 这是我的光学查询代码,它返回我 - 找不到列。 请帮助了解我的查询中的问题。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦
$ 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 anop: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)