pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Input validation
4+ messages / 4 participants
[nested] [flat]

* Input validation
@ 2019-08-07 18:07  stan <stanb@panix.com>
  0 siblings, 2 replies; 4+ messages in thread

From: stan @ 2019-08-07 18:07 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

 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





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Input validation
@ 2019-08-07 18:18  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: stan <stanb@panix.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Adrian Klaver @ 2019-08-07 18:18 UTC (permalink / raw)
  To: stan <stanb@panix.com>; pgsql-general@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Input validation
@ 2019-08-07 18:21  Rob Sargent <robjsargent@gmail.com>
  parent: stan <stanb@panix.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Rob Sargent @ 2019-08-07 18:21 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


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.






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Input validation
@ 2019-08-07 21:38  Benedict Holland <benedict.m.holland@gmail.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Benedict Holland @ 2019-08-07 21:38 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

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:

>
> 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.
>
>
>
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-08-07 21:38 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 18:07 Input validation stan <stanb@panix.com>
2019-08-07 18:18 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-08-07 18:21 ` Rob Sargent <robjsargent@gmail.com>
2019-08-07 21:38   ` Benedict Holland <benedict.m.holland@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox