2017-07-07 31 views
0

如何从正在进行的db中获取数值4gl,最初有一个来自用户的输入,用于根据记录显示的值来选择记录。我们尝试,但我们无法获取确切的价值。如何检索正在进行的db数据4gl?

这是我们的计划:

def var b as int. 
def var obj as int. 
/*set obj. 
prompt-for obj.*/ 
def var sum as int. 
def var a as int no-undo. 
def var i as int no-undo. 
for each po_mstr break by po_nbr. 
select count (*) from po_mstr. 
    assign 
     a = 1 
     b = 583 . 
    repeat: 
     if first-of (po_nbr) then 
      set obj. 
     prompt-for obj. 
     if (a le obj and obj lt b) then 
      disp po_nbr po_vend po_ship po_ord_date with 2 col. 
    end. 
end. 

我可以检索单个数据只有我们给超过2值意味着它将显示相同的第一个值。

+0

在ABL中使用SELECT是一个坏主意! – Austin

回答

0

我们来分析一下。你在使用很多命令而没有真正意识到它们的用途。

FOR EACH打开一个块并按照选定的排序顺序(如果没有被选择,则它使用主索引)为每个循环执行记录读取。

SELECT将执行数据库操作,但不一定在执行,但它可能会。

REPEAT还会打开一个块,其中您可能会或可能不会使用其他命令循环记录。话虽如此,以下是我如何写这个:

def var a as int no-undo. 
def var b as int. 
def var sum as int. 
/* 
def var obj as int. 
update obj. 
def var i as int no-undo. 
you're not using this */ 
select count (*) into sum from po_mstr. 
/* is this what you wanted? To have the count in sum? I don't see a reason, but suit yourself */ 
assign a = 1 b = 583 . /* or use UPDATE a b. if you would like to make that variable */ 
/* Since a and b are not changing, I moved it to outside the loop */ 
for each po_mstr where po_nbr >= a and po_nbr < b: 
    disp po_nbr po_vend po_ship po_ord_date with 2 col. 
end. 

我采取了一些自由。我删除了obj,因为据我所能评估,你试图将po_nbr值复制到它,然后用它来查看它是否在你想看到的范围内。因为我相信po_nbr代表po数,这可能是独一无二的,我也猜想每次迭代都会有不同的值。所以如果是第一次就不需要使用。它也消除了将其复制到变量的需要。只需将其与您想要查看的宝的范围直接比较即可。最后,显示应该没问题。

我打算继续并假设你的团队还没有接受过培训。这将是非常重要的,因为QAD(实际上任何ERP软件)都会夸大实际上快速且写得很差的代码,即使无害,可能会影响性能和可用性,这可能会成为整个操作的问题。堆栈溢出可能对准时性问题有所帮助,但如果您没有准备好,遇到的问题可能无法在此处解决。

希望这会有所帮助。