Is it possible to have a non-null column where the value is generated at insert by calling a stored procedure the parameters of which are values passed to insert into the row?
For example, I have table User:
| username | name | surname | id | Insert looks like this:
INSERT INTO USER (username, name, surname) VALUES ('myusername', 'myname', 'mysurname'); The id column is populated with an (integer) value retrieved by calling stored procedure mystoredproc with parameters myusername, myname, mysurname.
A further question is, would this stored procedure be called on each row, or can it be called in a grouped fashion. For example, I'd like my stored procedure to take the name and append a random integer to it so that that if I insert 100 users with the name 'David', they will get the same id and the stored procedure will be called only once. A bit of a bad example on the second point.
id? I can't remember how to define custom logic for a primary key which rather than auto-increments, calls a stored proc. What do I need to google for? Although, columniddoesn't have to be primary key and in my extension, of course, can't be one.