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 9028581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:01:13+00:00 2026-06-16T07:01:13+00:00

Table1: customers cust_no | cust_credbal | cred_status Table2:customer_credittopup cust_no | trans_amount I have the

  • 0
  1. Table1: customers

    cust_no | cust_credbal | cred_status

  2. Table2:customer_credittopup

    cust_no | trans_amount

I have the above two tables, I have written an update trigger after insert into the Table2 to update Table1. Thus the amount in Table1 cust_credbal is updated after adding cust_credbal in Tabl1 + the new value in trans_amount in Table2. How do i add an if statement after the update to check if cust_credbal is > than 20 then cred_status is is set to ‘VALID’ else ‘EXHAUSTED’

My trigger showing this error: Error at line 8: PLS-00049: bad bind variable ‘NEW.CUST_CREDITBAL’

CREATE OR REPLACE TRIGGER after_insert_credittopup
AFTER INSERT ON customer_credittopup
FOR EACH ROW 
DECLARE 
  credit number(11);
BEGIN
  UPDATE customers
     SET cust_creditbal=cust_creditbal +:new.trans_amount
   WHERE cust_no=:new.cust_no;

  SELECT Cust_creditbal INTO credit 
    FROM customers WHERE cust_no=:new.cust_no;

  IF(:new.cust_creditbal>0) THEN
    UPDATE customers
       SET Cust_credstatus='Valid'
     WHERE cust_no=:new.cust_no;
  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-16T07:01:15+00:00Added an answer on June 16, 2026 at 7:01 am

    It seems that all you need here is just 1 update statement :

    UPDATE customers
    SET cust_creditbal=cust_creditbal +:new.trans_amount,
    Cust_credstatus = CASE WHEN cust_creditbal +:new.trans_amount > 0 THEN 'Valid'
     ELSE 'Invalid' 
     --or if you don't want to change status in such case just put 
     --ELSE Cust_credstatus 
     END
     WHERE cust_no=:new.cust_no;
     --SELECT Cust_creditbal INTO credit FROM customers WHERE cust_no=:new.cust_no;
     --IF(:new.cust_creditbal>0) THEN
     --UPDATE customers
     --SET Cust_credstatus='Valid'
     --WHERE cust_no=:new.cust_no;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables: Customers ID_CUSTOMER NAME Products ID_PRODUCT PRODUCTNAME PRICE Orders ID_ORDER CUSTOMER_ID
I have 5 tables: customers id - name p_orders id - id_customer - code
I have 2 related MySQL tables in a one to many relationship. Customers: cust_id,
I have two tables, one that contains questions (that are considered 'templates'): |QuestionID|QuestionText |
I have the following tables customers cust_id cust_name 1 a company 2 a company
I have a oracle query: select * from table1,table2 where table1.id1 = table2.id2 and
I have two tables. One contains Potential Customer information along with their Vehicle requirements
i have to update total_orders of customers column to be equal to the total
I have a table Customers with a CustomerId field, and a table of Publications
I have a customers table, and an orders table. Each customer can have many

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.