I’ve got an error 22 when I update a recordset in a postgresql database
did not find any relevant information about this error ?
it is on a table that has foreign keys on it
other tables with no foreignkey did not show the error.
ERROR: syntax error at or near "default"
LINE 1: ...xtension = $4, value = $5, include_mailings = $6, default = ...
^
I do not generate these $4,$5 or $6
I use rs.idxfield(i).stringvalue = “xxx”
it seems the rs.update generates this statement and the postgresql plugin sends it to the database server.
I’ve got an error 22 when I update a recordset in a postgresql database
did not find any relevant information about this error ?
it is on a table that has foreign keys on it
other tables with no foreignkey did not show the error.
You can use reserved keywords for field names. Depending on the SQL flavour (don’t have experience with Postgresql myself) you can enclose those names between double quotes or square brackets.
From experience, I would change the field name from “default” to “defaultvalue” or whatever makes sense. “Default” is such a generic name it doesn’t mean anything so your database field names should be just as descriptive as your Xojo variable names - something that makes sense at a glance. If I have to decipher the meaning of a field name I’ve already lost the battle.
And remember, you’re not designing the names of your variables and field names not for 6 days from now but for 6 years from now. You won’t remember so being descriptive is better than vague. Assume the programmer coming after you is an axe wielding psychopath that knows your address.
BTW, Postgres usually stops you from creating a field called default.
alter TABLE test add column default text;
ERROR: syntax error at or near “default”
SQL Status:42601
I assume you used PGAdmin to create the field and PGAdmin internally uses this syntax to create the field (probably in attempt to honor your capitalization):
alter TABLE test add column “default” text;
which the PG server won’t object to. So I usually create my fields with plain SQL to avoid things like that.