Re: Prepared statements and default values
От | Marc Herbert |
---|---|
Тема | Re: Prepared statements and default values |
Дата | |
Msg-id | khju0ccmnmf.fsf@meije.emic.fr обсуждение исходный текст |
Ответ на | Prepared statements and default values (Assad Jarrahian <jarraa@gmail.com>) |
Список | pgsql-jdbc |
Assad Jarrahian <jarraa@gmail.com> writes: > thanks for your response David! > > Is that the only way, cause that surely does not seem easy when you > have say 20 columns, of which 15 have default values. > > given all the combinations (sometimes this set of column values is > needed to be default, otherwise another set .... and so on. > > Am I stuck with writing out all possible statements ...or is there > another way? Move the location of your default values out of the DB into the JDBC application. Of course your application has to be the only DB user :-( Else "import" the defaults from the DB into your application. Insert into the DB a fake user with defaults for every field and get it back immediately after; like this you easily "import"/duplicate all the default values. Clean-up the fake user then systematically .set(defaults) on all your prepared statements, and re- .set() them/override them only if the user provided some input. The issue of course is the duplication/desync of the default values between the DB and application. How often should they be updated? My 2 cents.
В списке pgsql-jdbc по дате отправления: