Understanding the Sample Program for Exporting Data
The following sample program creates an export file that you can load into a document such as a spreadsheet or word processing file. The tabs create columns in your spreadsheet or word processing document that correspond to the columns in your database table.
Program ex11a.sqr
begin-setup
! No margins, wide enough for the widest record
! and no page breaks
declare-layout default
left-margin=0 top-margin=0
max_columns=160 formfeed=no
end-declare
end-setup
begin-program
do main
end-program
begin-procedure main
encode '<009>' into $sep ! Separator character is TAB
let $cust_num = 'Customer Number'
let $name = 'Customer Name'
let $addr1 = 'Address Line 1'
let $addr2 = 'Address Line 2'
let $city = 'City'
let $state = 'State'
let $zip = 'Zip Code'
let $phone = 'Phone Number'
let $tot = 'Total'
string $cust_num $name $addr1 $addr2
$city $state $zip $phone $tot by $sep into $col_hds
print $col_hds (1,1)
new-page
begin-select
cust_num
name
addr1
addr2
city
state
zip
phone
tot
string &cust_num &name &addr1 &addr2
&city &state &zip &phone &tot by $sep into $db_cols
print $db_cols ()
new-page
from customers
end-select
end-procedure ! main