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

  • Home
  • SEARCH
  • 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 8844743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:33:49+00:00 2026-06-14T11:33:49+00:00

I am trying to write a trigger to validate if the customer/address exist before

  • 0

I am trying to write a trigger to validate if the customer/address exist before inserting but i encounter some error. Able to advise on this?

Below is the table:
Customer (CustID,CustName,DOB)

CREATE OR REPLACE TRIGGER CREATEACCOUNT
  BEFORE INSERT ON ACCOUNT
  FOR EACH ROW 
DECLARE
  newCustID     varchar(10);
  newPostCode   int;
  newStreet     char;
  newAccType    varchar(15);
  newAccStatus  char(9);
  newAccBalance int;
  varRowCount   int;
BEGIN

  newCustID := :new.CustID;

  SELECT COUNT(*) 
    INTO varRowCount
    FROM Customer
   WHERE CustID = newCustID;

  IF (varRowCount > 0) THEN 
    RETURN;
  END IF;

  IF (varRowCount = 0) THEN
    BEGIN
      INSERT INTO CUSTOMER VALUES (newCustID,:new.CustName,:new.DOB);
    END;
  END IF;
END;

Below is the error message:
Error(27,46): PLS-00049: bad bind variable ‘NEW.CUSTNAME’
Error(27,60): PLS-00049: bad bind variable ‘NEW.DOB’

  • 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-14T11:33:50+00:00Added an answer on June 14, 2026 at 11:33 am

    The trigger is defined on the ACCOUNT table. You’ve posted the definition of the CUSTOMER table. Unless the ACCOUNT table has columns CustName and DOB, which seems highly unlikely, you can’t refer to :new.CustName or :new.DOB— the :new record is for the row that is currently being inserted into the ACCOUNT table.

    Where do you intend to get the CustName and DOB to insert into the Customer table?

    Taking a step back, why is a trigger on the Account table trying to insert a row into the Customer table in the first place. That seems like an exceptionally poor design. The CustID in the Account table would presumably be a foreign key that references the Customer table. That would mean, though, that you could only insert the parent row in a trigger if you declare the constraints as deferable and defer them at the beginning of every transaction. The trigger would also generally have no way of determining the information for the Customer columns that you want to populate which is the source of the error you’re getting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a trigger but getting syntax error: CREATE TRIGGER archive_domain_trig
I am trying to write a before delete trigger on mysql table here's is
I've never created a trigger before and I'm trying to read online but am
Overview: Trying to write a trigger for a SQL Server 2008 database. TableA and
So I'm trying to write a SQL Server Trigger that will call an ASP.Net
I'm trying to write an after update trigger that does a batch update on
I am trying write a function that generates simulated data but if the simulated
Trying to write out syslog entries containing strings but they don't register. // person.name
I'm trying to write a trigger within SQL, and the code within needs to
I'm trying to write a table trigger which queries another table that is outside

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.