Input validation

Started by stanover 6 years ago4 messagesgeneral
Jump to latest
#1stan
stanb@panix.com

Have table that contains employee keys, paired up with work type keys
(both foreign keys) and a 3rd column that you enter a billing rate in.
Then I have a table where employees enter their work. I need to validate
that the employee, work type pair exists, before allowing the new record
to be inserted.

Any thoughts as to good way to do this?

--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: stan (#1)
Re: Input validation

On 8/7/19 11:07 AM, stan wrote:

Have table that contains employee keys, paired up with work type keys
(both foreign keys) and a 3rd column that you enter a billing rate in.
Then I have a table where employees enter their work. I need to validate
that the employee, work type pair exists, before allowing the new record
to be inserted.

Any thoughts as to good way to do this?

INSERT UPDATE trigger:

https://www.postgresql.org/docs/11/sql-createtrigger.html

https://www.postgresql.org/docs/11/plpgsql-trigger.html

--
Adrian Klaver
adrian.klaver@aklaver.com

#3Rob Sargent
robjsargent@gmail.com
In reply to: stan (#1)
Re: Input validation

On 8/7/19 12:07 PM, stan wrote:

Have table that contains employee keys, paired up with work type keys
(both foreign keys) and a 3rd column that you enter a billing rate in.
Then I have a table where employees enter their work. I need to validate
that the employee, work type pair exists, before allowing the new record
to be inserted.

Any thoughts as to good way to do this?

Does the employee interactively specify the "work type" then some
time-spent value?

Can the work-type be chosen from a drop-down generated by

    select work_type from table where employee = <current user>

Otherwise you'll need a trigger on the insert into "enter their work"
table.  Sad thing here is the user has likely left the scene.

#4Benedict Holland
benedict.m.holland@gmail.com
In reply to: Rob Sargent (#3)
Re: Input validation

I think a check will also work but I second triggers.

Thanks,
~Ben

On Wed, Aug 7, 2019, 2:21 PM Rob Sargent <robjsargent@gmail.com> wrote:

Show quoted text

On 8/7/19 12:07 PM, stan wrote:

Have table that contains employee keys, paired up with work type keys
(both foreign keys) and a 3rd column that you enter a billing rate in.
Then I have a table where employees enter their work. I need to

validate

that the employee, work type pair exists, before allowing the new

record

to be inserted.

Any thoughts as to good way to do this?

Does the employee interactively specify the "work type" then some
time-spent value?

Can the work-type be chosen from a drop-down generated by

select work_type from table where employee = <current user>

Otherwise you'll need a trigger on the insert into "enter their work"
table. Sad thing here is the user has likely left the scene.