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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:04:12+00:00 2026-06-04T14:04:12+00:00

I have been sitting with a stored procedure for MySQL for days now, it

  • 0

I have been sitting with a stored procedure for MySQL for days now, it just won’t work, so I thought I’d go back to basic and do a very simple function that checks if an item exists or not.

The problem I had on the first one was that it said END IF is invalid syntax on one of my IF clauses, but not the other two. The second one won’t even recognize BEGIN as valid syntax…

Is it I that got everything wrong, or have I stumbled upon a MYSQL Workbench bug? I have Workbench 5.2 (latest version when I’m writing this) and this is the code:

DELIMITER $$

CREATE FUNCTION `filmsidan`.`f_lateornot` (movie_id INT)
BEGIN
    DECLARE check_val INT;
    DECLARE return_val INT;

    SELECT stockId
    FROM orders
    WHERE stockId = movie_id
    INTO check_val;

    IF check_val <= 0
    THEN
        SET return_val = 1;
    ELSE
        SET return_val = 0;
    END IF;

    RETURN return_val;

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-04T14:04:15+00:00Added an answer on June 4, 2026 at 2:04 pm

    to fix the “begin” syntax error, you have to declare a return value, like this:

    CREATE FUNCTION `filmsidan`.`f_lateornot` (movie_id INT) RETURNS INT(11)
    

    after doing that, Workbench won’t return an error anymore ;o)

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

Sidebar

Related Questions

So basically I have this relatively long stored procedure. The basic execution flow is
I have been working on this, very, small photo cms lately. And now i
I have a collation conflict in a stored procedure I am trying to run
I have an issue with the below stored procedure. It runs fine as long
I’ve been tasked with optimizing a rather nasty stored procedure in a legacy system.
I have a date that's stored as a number of days since January 1,
I have been working on a method to sync core data stored in an
I have been working on this for a few days and this is doing
I have not been doing TDD and Unit Tests for 7 months now and
For the last couple of days I have been struggling with the following issue

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.