Alpha Documentation



Example 1 - simple


dim cn as sql::Connection

dim rs as sql::ResultSet

dim args as sql::Arguments

cn.open("::name::conn")


vsql = "SELECT name FROM developers"

cn.execute(vsql)

rs = cn.resultset

dim arr[0] as p


'assume rs is:

'Steve

'Jack

'Mary


cn.topropertyarray(vsql,args,arr)


dim names as c

for x = 1 to arr.size() ' size will be 3

       names = names + arr[x].name + ","

next

?names = "Steve,Jack,Mary,"


names = strip_trailing_char(names,",")

?names = "Steve,Jack,Mary"


Example 2 - Geocoding 


function geocodeDeveloperAddresses as c (e as p)

debug(1)


dim cn as sql::Connection

dim rs as sql::ResultSet

dim args as sql::Arguments

cn.open("::name::conn")


vsql = "SELECT * FROM developers WHERE lat=''"

if cn.execute(vsql) = .f.

       errorout("|GEOCODE_DEV_MAIN|"+cn.callresult.text)

end if

rs = cn.resultset

dim arr[0] as p

dim lat as n = 0

dim pa as p

x=1


cn.topropertyarray(vsql,args,arr)


for x = 1 to arr.size()

               address = arr[x].city + " " + arr[x].province + " " + arr[x].state + " " + arr[x].zipcode  + " " + arr[x].country

               sleep(.125)

           pa = geocode_address(address,"Google")

           if convert_type(pa.lat,"C") <> ""

                       vsql = "UPDATE developers SET latitude=:vlat,longitude=:vlon WHERE id=:vid"

                       args.add("vlat",pa.lat)

                       args.add("vlon",pa.lon)

                       args.add("vid",arr[x].id)

                       if cn.execute(vsql,args) = .f.

                               errorout("GEOCODE_DEVS_EACH|"+cn.callresult.text)

                       end if

       end if

next


cn.close()

geocodeDeveloperAddresses = "alert('" + x + " geocoded');"


end function