Search This Blog

Thursday, September 10, 2009

What makes the difference b/w array and load lookup?

(1) Load-lookup:-

----------------------

1) Load-lookup will be populated at compilation time

2) We can adjust the size of load-lookup

3) It is only for text data type

4) We can only select two fields, but by string concatenation we can select more than two fields.

5) Size of the load-lookup will be increased automatically

(2) Array :-

---------------

1) Array get populated at Execution time

2) We can't modify size of the Array. if we given more than the size of the array Program automatically aborts

3) We can select any number of fields we want

4) Array Supports all data types

With LOAD-LOOKUP, you can reduce the number of tables that are joined in one SELECT. Use this command in conjunction with one or more LOOKUP commands.

Example begin-setup

load-lookup

name=prods

table=products

key=product_code

return_value=description

end-setup

...

begin-select

order_num (+1,1)

product_code

lookup prods &product_code $desc

print $desc (,15)

from orderlines

end-select

In this example, the LOAD-LOOKUP command loads an array with the product_code and description columns from the products table. The lookup array is named prods. The product_code column is the key and the description column is the return value. In the SELECT paragraph, a LOOKUP on the prods array retrieves the description for each product_code. This technique eliminates the need to join the products table in the SELECT.

No comments:

Post a Comment