Bug #19447 Have default values for fields when using INSERT on a view
Submitted: 30 Apr 2006 16:53
Reporter: Mike Hartmann Email Updates:
Status: Open Impact on me:
Category:MySQL Server Severity:S4 (Feature request)
Version:5 OS:Any (all)
Assigned to: CPU Architecture:Any

[30 Apr 2006 16:53] Mike Hartmann
Might be only interesting for a few people, but nevertheless helpful.

We have a table with a set of fields, one of them named gid.
As well we have several VIEWs on that table that shows all entries with a given gid. 
(like CREATE VIEW `manager_options` AS select ...fields selection... from `options` where (`gid` = 1) WITH LOCAL CHECK OPTION;

or CREATE VIEW `user_options` AS select ...fields selection... from `options` where (`gid` = 2) WITH LOCAL CHECK OPTION;)

the table "options" only gets accessed via the views (that do not output the gid-field), data is inserted via an INSERT on the view. 
Now I'd like to be able to define a default-value for gid when inserting via the view (ie. gid=1 for manager_options or gid=2 for user_options)

unfortunately it is impossible to set the gid-field via the application, because the view is used to give some old apps access to the table who don't know about the gid-field :-)

Best regards

How to repeat:

Suggested fix:
Be able to specify default-values for fields like in CREATE TABLE