Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8862973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:51:35+00:00 2026-06-14T15:51:35+00:00

i want to create a trigger that will select staffid where dateread = this

  • 0

i want to create a trigger that will

  • select staffid where dateread = this months date
  • to count the number of a staffID
  • if the count for that staff during that month is more than 5
  • a stop will be issued.

here is what i did that screws me up

I would like to know is this logically correct?
and here are my compiler log errors

This is my required outcome:
Meter readers can only read a maximum of 5 meters in any given calendar month

My Reading Table has
StaffID
MeterID
DateRead
ReadinID (PK)

Here is the error text:

Error(5,7): PL/SQL: SQL Statement ignored Error(5,27): 
PL/SQL:ORA-00923: FROM keyword not found where expected 
C:\Users\ChrisPin\AppData\Roaming\SQL Developer\assgn2 sat4.sql Error(5,7): 
PL/SQL: SQL Statement ignored Error(5,27): 
PL/SQL: ORA-00923: FROM keyword not found where expected

Here is the trigger code:

CREATE OR REPLACE TRIGGER LIMIT_5_REDINGS
      BEFORE UPDATE OR INSERT ON reading
    FOR EACH ROW
    DECLARE
    ReadingCount  INTEGER;      --# of depts for this employee
      max_read   INTEGER := 5; --max number of depts per employee.
      BEGIN
      select Reading COUNT(*) into ReadingCount
      from (select *
            from Reading
            where to_char(DateRead, 'YYYY-MM') = to_char(sysdate, 'YYYY-MM'))  
      WHERE STAFFID = :NEW.STAFFID;

    IF :OLD.STAFFID = :NEW.STAFFID THEN
        RETURN;
     ELSE
       IF ReadingCount >= max_read THEN
         RAISE_APPLICATION_ERROR (-20000,'Employees are limited to a max of two departments.');
    END IF;
    END IF;
    END;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:51:36+00:00Added an answer on June 14, 2026 at 3:51 pm

    It’s in this line

    select Reading COUNT(*) into ReadingCount 
    

    should be

    select COUNT(*) into ReadingCount
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a trigger in MySQL that will do two things: if
I want to create a trigger that will update the column LastActivityDate to the
I want to create a trigger in foxpro that will execute after every update
I want to make a trigger that will prevent the insertion if the birthdate
I want to add a trigger that will keep on updating autoincrement column by
I need to create a field that will show the number of days between
I want to create an insert trigger on MySQL which will automatically insert the
I have tow tables concept_access and concept_access_log. I want to create a trigger that
Is it possible to create a trigger that will check if a specific field
I am trying to create a Trigger, that will update the History Table with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.