Dial plan issue

I want to have a caller enter an employee number and validate that number to make sure it is an active employee from a database.

caller calls in and enters 1234
I then would need to do some database validation and return whether or not I could find that 1234 in my employees table in my database.
If I found it I would do something
If I didn’t find it I would do something else.

you can simply think about simple AGI script