我如何 link 两个表并获取进行中的值 4gl
How can i link two tables and get the values in progress 4gl
我有两个 table 员工和订单,其中 emp-id(字段)在 tables.i 中很常见,需要从员工中获取 emp-name 和 emp-ph table, and order-num from order table.how to link these table and get the values
define variable c as integer.
define query q1 for customer,order SCROLLING.
INPUT FROM Value ( "C:\src\New folder\cnum.txt").
IMPORT c.
open query q1 for each employee where employee.emp-id=c ,
each order where (order.emp-id = employee.emp-id ).
it is throwing me error as conflict from query Browse use
您需要为两个表定义查询:
DEFINE QUERY q1 FOR Customer, Order SCROLLING.
您的要求没有提到客户table,您也不需要从文件中输入,所以我将重点关注您所说的您需要的内容:
for each employee no-lock,
each order no-lock where order.emp-id = employee.emp-id:
display employee.name employee.emp-ph order.order-num.
end.
如果您尝试从文本文件中获取员工 ID,应该这样做。它将读取文件每一行的 ID,找到员工记录并显示订单信息。
DEFINE VARIABLE c AS INTEGER NO-UNDO.
INPUT FROM VALUE("C:\src\New folder\cnum.txt").
REPEAT:
IMPORT c.
FIND FIRST Employee WHERE Employee.Emp-ID = c NO-LOCK NO-ERROR.
IF NOT AVAILABLE(Employee) THEN
DO:
MESSAGE "Cannot find employee with ID " c VIEW-AS ALERT-BOX ERROR.
NEXT.
END.
FOR EACH Order NO-LOCK WHERE Order.Emp-ID = Employee.Emp-ID:
DISPLAY
Employee.Emp-Name
Employee.Emp-Ph
Order.Order-Num.
END.
END.
INPUT CLOSE.
我有两个 table 员工和订单,其中 emp-id(字段)在 tables.i 中很常见,需要从员工中获取 emp-name 和 emp-ph table, and order-num from order table.how to link these table and get the values
define variable c as integer.
define query q1 for customer,order SCROLLING.
INPUT FROM Value ( "C:\src\New folder\cnum.txt").
IMPORT c.
open query q1 for each employee where employee.emp-id=c ,
each order where (order.emp-id = employee.emp-id ).
it is throwing me error as conflict from query Browse use
您需要为两个表定义查询:
DEFINE QUERY q1 FOR Customer, Order SCROLLING.
您的要求没有提到客户table,您也不需要从文件中输入,所以我将重点关注您所说的您需要的内容:
for each employee no-lock,
each order no-lock where order.emp-id = employee.emp-id:
display employee.name employee.emp-ph order.order-num.
end.
如果您尝试从文本文件中获取员工 ID,应该这样做。它将读取文件每一行的 ID,找到员工记录并显示订单信息。
DEFINE VARIABLE c AS INTEGER NO-UNDO.
INPUT FROM VALUE("C:\src\New folder\cnum.txt").
REPEAT:
IMPORT c.
FIND FIRST Employee WHERE Employee.Emp-ID = c NO-LOCK NO-ERROR.
IF NOT AVAILABLE(Employee) THEN
DO:
MESSAGE "Cannot find employee with ID " c VIEW-AS ALERT-BOX ERROR.
NEXT.
END.
FOR EACH Order NO-LOCK WHERE Order.Emp-ID = Employee.Emp-ID:
DISPLAY
Employee.Emp-Name
Employee.Emp-Ph
Order.Order-Num.
END.
END.
INPUT CLOSE.