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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:00:46+00:00 2026-06-14T08:00:46+00:00

this procedure code is to apply a discount to the new insert. The problem

  • 0

this procedure code is to apply a discount to the new insert. The problem I’m having is too many records are being fetched. How would i fix this? do i use a trigger or a function?

Ok i have created a trigger but am i getting a PLS-00103: Encountered the symbol “=” when expecting one of the following: := . ( @ % ;

CREATE OR REPLACE PROCEDURE CHECK_DISCOUNT
AS

V_COUNT NUMBER;
V_C_NO APPOINTMENT.C_NO%TYPE;
V_BILL APPOINTMENT.BILL%TYPE;

BEGIN

SELECT C_NO,COUNT(C_NO)
INTO V_C_NO,V_COUNT
FROM APPOINTMENT
GROUP BY C_NO;

SELECT BILL
INTO V_BILL
FROM APPOINTMENT;

IF V_COUNT=3 THEN
V_BILL:=V_BILL * 0.9;
END IF;

UPDATE APPOINTMENT
SET BILL = V_BILL 
WHERE C_NO=:new.C_NO;
COMMIT;

END;
/

Create or replace TRIGGER CHECK_DISCOUNT 
BEFORE INSERT OR UPDATE OF C_NO ON APPOINT     
FOR EACH ROW 

DECLARE CURSOR C_APPTMENT IS 
SELECT C_NO,COUNT(C_NO) 
FROM APPOINTMENT GROUP BY C_NO; 

VISIT NUMBER; V_C_NO APPOINTMENT.C_NO%TYPE; 
V_BILL APPOINTMENT.BILL%TYPE; 
V_TEN NUMBER(3):=0.9; 

BEGIN 
   LOOP 
            OPEN C_APPTMENT; FETCH C_APPTMENT INTO V_C_NO, VISIT;
            EXIT WHEN C_APPTMENT%NOTFOUND; 

  SELECT BILL INTO V_BILL FROM APPOINTMENT; 
  IF VISITS =3 THEN V_BILL=V_BILL * V_TEN 
  WHERE :NEW.C_NO=V_C_NO; 
  UPDATE APPOINTMENT SET BILL:= V_BILL 
  WHERE:NEW.C_NO=V_C_NO; 
    END LOOP; 
      CLOSE C_APPTMENT; 

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-14T08:00:47+00:00Added an answer on June 14, 2026 at 8:00 am

    When using select … into you must assure you only select one row.
    Usually you will add a where clause with primary- or unique key columns. That way you are sure to select only one row. You will also have to provide for instances where no rows are selected. Add a exception handler to trap no_data_found exceptions

    declare
       v_bill appointment.bill%type;
    begin
       begin
          select a.bill
            into v_bill
            from appointment a
           where a.id = :my_id;  -- assuming ID is a primary key colomn
       exception
          when no_data_found then
             null;
       end;
    
       if v_bill is not null
       then
          --.. do something with v_bill
       end if;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am passing a datatable from Code to stored procedure in this way. DataTable
I have written grammar for a language (sample code below) //this is a procedure
IS this bit of code in PHP/mysql considered a stored procedure? $sql = 'SELECT
I asked the question here and now i would like to reverse this procedure
I have this following code with Inno Setup. But how can I apply this
I'm having a hard time describing this problem. Maybe that's why I'm having a
This code is not working for me on Delphi XE: http://delphi.about.com/cs/adptips2000/a/bltip0800_5.htm procedure TForm1.FormDeactivate(Sender: TObject)
i've built this sample code based on a real problem I have in an
The following code was designed to apply a procedure to all the child elements
I have a procedure and the code looks like this: ALTER PROCEDURE [dbo].[usp_Gen_Proc] (@ID

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.