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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:24:19+00:00 2026-06-12T12:24:19+00:00

Im trying to convert a procedure from using sql plus to mysql but am

  • 0

Im trying to convert a procedure from using sql plus to mysql but am getting a syntax error on the third line where it says (W_IN IN NUMBER) and it has IN highlighted as the syntax error.

SQL Plus:

CREATE OR REPLACE PROCEDURE PRC_CUS_BALANCE_UPDATE (W_IN IN NUMBER) AS
W_CUS NUMBER := 0;
W_TOT NUMBER := 0;
BEGIN
-- GET THE CUS_CODE
SELECT CUS_CODE INTO W_CUS 
FROM INVOICE
WHERE INVOICE.INV_NUMBER = W_IN;

-- UPDATES CUSTOMER IF W_CUS > 0
IF W_CUS > 0 THEN
    UPDATE CUSTOMER
    SET CUS_BALANCE = CUS_BALANCE + 
                (SELECT INV_TOTAL FROM INVOICE WHERE INV_NUMBER = W_IN)
    WHERE CUS_CODE = W_CUS;
END IF;
END;

mySQL:

-- Trigger DDL Statements
DELIMITER $$

CREATE PROCEDURE prc_cus_balance_update (W_IN IN NUMBER) 
AS
W_CUS NUMBER = 0;
W_TOT NUMBER = 0;
BEGIN
-- GET CUS_CODE
SELECT CUS_CODE INTO W_CUS 
FROM INVOICE
WHERE INVOICE.INV_NUMBER = W_IN;

-- UPDATES CUSTOMER IF W_CUS > 0
IF W_CUS > 0 THEN
    UPDATE CUSTOMER
    SET CUS_BALANCE = CUS_BALANCE + 
                (SELECT INV_TOTAL FROM INVOICE WHERE INV_NUMBER = W_IN)
    WHERE CUS_CODE = W_CUS;
END IF;
END $$

DELIMITER ;

Any help is greatly appreciated!

  • 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-12T12:24:20+00:00Added an answer on June 12, 2026 at 12:24 pm

    This compiles in MySQL 5.5.23:

    -- Trigger DDL Statements
    DELIMITER $$
    
    DROP PROCEDURE IF EXISTS prc_cus_balance_update;
    
    CREATE PROCEDURE prc_cus_balance_update (IN W_IN INT UNSIGNED) 
    BEGIN
    DECLARE W_CUS INT UNSIGNED DEFAULT 0;
    DECLARE W_TOT DOUBLE DEFAULT 0; -- NOT USED?
    -- GET CUS_CODE
    SELECT CUS_CODE INTO W_CUS 
    FROM INVOICE
    WHERE INVOICE.INV_NUMBER = W_IN;
    
    -- UPDATES CUSTOMER IF W_CUS > 0
    IF W_CUS > 0 THEN
        UPDATE CUSTOMER
        SET CUS_BALANCE = CUS_BALANCE + 
                    (SELECT INV_TOTAL FROM INVOICE WHERE INV_NUMBER = W_IN)
        WHERE CUS_CODE = W_CUS;
    END IF;
    END $$
    
    DELIMITER ;
    

    Of course, in this case, a stored procedure is not needed, as the following query will perform the same function much faster (and easier to understand):

    UPDATE 
        CUSTOMER c
    INNER JOIN
        INVOICE i ON i.CUS_CODE = c.CUS_CODE
    SET 
        c.CUS_BALANCE = c.CUS_BALANCE + i.INV_TOTAL 
    WHERE 
        i.INV_NUMBER = W_IN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert a MS Access query into a SQL Sever stored procedure
i´m using subsonic 3 trying convert a SQL2008 project to MySQL. when the projects
I'm trying to call a parameterized stored procedure from SQL Server 2005 in my
I am simply trying to call a store procedure (SQL Server 2008) using C#
I am trying to update SQL Server Agent schedules using msdb.dbo.sp_update_schedule , but when
I am trying to call a SQL Server stored procedure from my Python code,
I'm trying to call a stored procedure (on a SQL 2005 server) from C#,
I'm trying to convert MS Access Cross Tab query into SQL Server stored procedure
I am new to Linq and trying to convert this SQL Server stored procedure
When trying to convert records to xml in sql, I get the following error

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.