gpt4 book ai didi

openedge - OpenEdge 中的动态查询

转载 作者:行者123 更新时间:2023-12-02 20:42:10 27 4
gpt4 key购买 nike

美好的一天:

简单问题:我可以在 OpenEdge 中执行动态查询吗?

示例:

def temp-table tt-num1
field f1 as int
field f2 as int.

def temp-table tt-num2
field f1 as int
field f2 as int.

def temp-table tt-num3
field f1 as int
field f2 as int.

我需要的是这样的东西:

procedure repeat-query:
for each 'variable that contains table-name' no-lock.

disp f1 f2.

end.
end procedure.

或者其他可以解决我的问题的方法。

我该如何继续?我尝试在互联网上检查动态查询,但没有成功。提前致谢。

最佳答案

如果直接访问https://documentation.progress.com/#page/progdocindex%2Fopenedge.html您可以找到有关 OpenEdge 的所有内容的文档。例如动态查询。

我不明白你到底想做什么,但这是一个动态查询的示例。

DEFINE TEMP-TABLE tt-num1 NO-UNDO
FIELD f1 AS INTEGER
FIELD f2 AS INTEGER.

DEFINE TEMP-TABLE tt-num2 NO-UNDO
FIELD f1 AS INTEGER
FIELD f2 AS INTEGER.

DEFINE TEMP-TABLE tt-num3 NO-UNDO
FIELD f1 AS INTEGER
FIELD f2 AS INTEGER.


CREATE tt-num1.
ASSIGN
tt-num1.f1 = 1
tt-num1.f2 = 1.

CREATE tt-num1.
ASSIGN
tt-num1.f1 = 1
tt-num1.f2 = 2.

CREATE tt-num1.
ASSIGN
tt-num1.f1 = 2
tt-num1.f2 = 1.

CREATE tt-num1.
ASSIGN
tt-num1.f1 = 2
tt-num1.f2 = 2.

DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE cBuffer AS CHARACTER NO-UNDO.
DEFINE VARIABLE cField AS CHARACTER NO-UNDO.
DEFINE VARIABLE iValue AS INTEGER NO-UNDO.

ASSIGN
cBuffer = "tt-num1"
cField = "f1"
iValue = 1.

CREATE QUERY hQuery.

hQuery:ADD-BUFFER(cBuffer).
hQuery:QUERY-PREPARE("for each " + cBuffer + " where " + cBuffer + "." + cField + " = " + STRING(iValue)).
hQuery:QUERY-OPEN().

queryLoop:
REPEAT:
hQuery:GET-NEXT().

IF hQuery:QUERY-OFF-END THEN LEAVE queryLoop.

DISPLAY hQuery:GET-BUFFER-HANDLE(1):BUFFER-FIELD(cField):BUFFER-VALUE.
END.
hQuery:QUERY-CLOSE().

DELETE OBJECT hQuery.

正如 Stefan Drissen 在一个非常有效的评论中提到的:循环可以更紧凑:

DO WHILE hQuery:GET-NEXT():
/* Code goes here */
END.

关于openedge - OpenEdge 中的动态查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45832144/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com