Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] [COMMAND] Database null values

From: davidegessi::tin::it at: 26-Jan-2003 4:59

Hi all, if I want to append new records to a table I can insert into a command port insert cmd-port [ "INSERT INTO tab (f1,f2,f3) VALUES (?,?,?)" v1 v2 v3 ] but how can I handle null values ? if f1 is a text field and v1 is none, then f1 will set to [to-string none] :( Could be the following a good approach ? to-sql-value: func [ v [any-type!] ][ either none? v [ return "null" ][ either string? v [ return rejoin ["'" to-string v "'"] ][ either date? v [ return rejoin ["#" to-string v "#"] ][ return to-string v ] ] ] ] sql-str: rejoin ["INSER INTO tab (f1,f2,f3) VALUES (" to-sql-value v1 "," to-sql-value v2 "," to-sql-value v3 ")"] insert cmd-port sql-str Any hint ? Davide