PROP:SQL select into alias - does it make sense

sql
Tags: #<Tag:0x00007f46dac441b8>

#1

regionslookup is an alias of REGIONS - does this make sense
records in regions = 34 and printable = 1 = 16
records in regionslookup = 34 - obviously

regionslookup{PROP:SQL}= 'Select * from regions where Printable=1 order by sortorder'
!message(records(regionslookup))
loc:recordsregions = records(regionslookup)!jvz
display(?loc:recordsregions)!JVZ
LOC:countregionerrors = 0 !JVZ
LOOP
	Next(regionslookup)
	if error()
		stop('Regionslookup Region: '& CLIP(RegL:ShortName)&' '&errorcode()&' '&error())
	END

#2

I don’t know that the records(regionslookup) will work as expected.
You need to be VERY careful using Select * the order of fields returned may not be as expected.

Other than that it looks ok.


#3

No.

When using prop:sql, the structure you use for the prop:sql is just a record declaration into which data can be placed, it is not a file.

So…

CLEAR(Regions_Lookup,0)
regionslookup{PROP:SQL}= 'Select * from regions where Printable=1 order by sortorder'
IF ERROROCDE()
  STOP(FILEERROR())
ELSE
  LOOP
	Next(regionslookup)
	if error()
          BREAK
	END
        STOP('Regionslookup Region: '& CLIP(RegL:ShortName)&' '&errorcode()&' '&error())
  END
END

… should loop for each Printable record