NullColumn$
Jump to navigation
Jump to search
Description
- When using a QueryResultRow object Run BASIC will translate NULL values into 0 when asked for a numeric value, and into an empty string when asked for a string.
- You can change the default values to something else if you like by changing the contents of the NullColumn$ and NullColumn variables, which are globally visible.
Syntax
These variables are case sensitive.
- NullColumn
- NullColumn$
Hints
- NullColumn and NullColumn$ are only supported by SQL database objects
Example
' set null value for display
NullColumn = -9999
NullColumn$ = "Nothing"
' check DBs existence
files #accessor, "Records.db"
exists = #accessor hasAnswer()
if exists then kill "Records.db"
' create DB
sqliteconnect #records, "Records.db"
query$ = "create table Payables (company char(50), invoice char(12), due integer, amt char(10))"
#records execute(query$)
' fill DB
data "IBM","1029A",38945,"19.95"
data "Brooks Brothers","029528",38915,"199.95"
data "Joe's Garage","330Z",38995,"48.99"
data "Toyota","834-18",38999,"129.95"
for i = 1 to 4
read company$, invoice$, due, amt$
query$ = "insert into Payables (company, invoice, due, amt) values ('"; company$; "', '"; invoice$; "', "; due; ", '"; amt$; "')"
if i = 2 then query$ = "insert into Payables default values"
#records execute(query$)
next
query$ = "select * from Payables"
#records execute(query$)
print "Render query result as a table"
render #records
print
print "Render query result manually"
dim items$(3, 3)
i = 0
while #records hasanswer()
#row = #records #nextrow()
items$(0, i) = #row company$()
items$(1, i) = #row invoice$()
items$(2, i) = str$(#row due())
items$(3, i) = #row amt$()
i = i + 1
wend
table #manual, items$()
#manual columnnames("company,invoice,due,amt")
render #manual
#records disconnect()
end
Useful Procedures
' Place a useful function or sub using this keyword here