[Zope] sqlvar

Duncan Booth duncan@rcp.co.uk
Tue, 9 Nov 1999 10:02:24 +0000


> 
> I have noticed that I get ODBC errors if I attempt to insert character
> strings longer than the database field length.
> 
> I can restrict the character lengths by using the maxlength attribute in
> the data entry forms, but would it not be better to have an attribute of
> sqlvar that restricts the length of strings being passed to the ODBC
> adapter?

You can use Python's string slicing to effectively limit the length of a 
variable. For example instead of:
  <dtml-sqlvar myfield type=nb>
try writing:
  <dtml-sqlvar "myfield[:20]" type=nb>
to take only the first 20 characters.

-- 
Duncan Booth                                             duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan