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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:01:23+00:00 2026-05-24T02:01:23+00:00

I have the following mysql procedure: CREATE PROCEDURE db.processEvent( IN eventId INT , IN

  • 0

I have the following mysql procedure:

CREATE PROCEDURE db.processEvent( IN eventId INT , IN creatorId INT , IN typeId INT , IN eventName VARCHAR( 60 ) , IN startDateTime DATETIME , IN endDateTime DATETIME , IN validStartTime TIME , IN validEndTime TIME )
BEGIN
    INSERT INTO tbl_event
    VALUES
    (
        eventId , creatorId , typeId , eventName , startDateTime , endDateTime , validStartTime , validEndTime
    )
    ON DUPLICATE KEY UPDATE
        creator_user_id = creatorID ,
        event_type_id = typeId ,
        event_name = eventName ,
        start_date = startDateTime ,
        end_date = endDateTime ,
        valid_time_start = validStartTime ,
        valid_time_end = validEndTime
    ;
END;

ON first run it does the correct thing and create a new record as I pass NULL into eventId. It also updates when I pass an id in for eventId (I am assuming it updates correctly at this stage).

However… If I go to create a new record by pass NULL in to eventId the initial record is updated.

I have tried adding:

    IF eventId != 0 OR eventId IS NOT NULL THEN
        set eID = eventId;
    END IF;

and using eID in the values list but to no avail.

Any clues would be a great help.

Thanks peeps.

==========================

Requested Info:

table strcuture:

CREATE TABLE `tbl_event` (
`event_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`creator_user_id` int(10) unsigned NOT NULL,
`event_type_id` int(11) NOT NULL,
`event_name` varchar(60) DEFAULT NULL,
`start_date` datetime DEFAULT NULL,
`end_date` datetime DEFAULT NULL,
`valid_time_start` time DEFAULT NULL,
`valid_time_end` time DEFAULT NULL,
PRIMARY KEY (`event_id`,`creator_user_id`),
UNIQUE KEY `event_id_UNIQUE` (`event_id`),
UNIQUE KEY `creator_user_id_UNIQUE` (`creator_user_id`),
KEY `fk_tbl_event_tbl_cm_profile1` (`creator_user_id`),
KEY `fk_tbl_event_tbl_event_type1` (`event_type_id`),
CONSTRAINT `fk_tbl_event_tbl_cm_profile1` FOREIGN KEY (`creator_user_id`) REFERENCES `tbl_cm_user_profile` (`cm_user_id`),
CONSTRAINT `fk_tbl_event_tbl_event_type1` FOREIGN KEY (`event_type_id`) REFERENCES `tbl_event_type` (`event_type_id`)
) ENGINE=InnoDB

called via php:pdo like so:

$db     = \lib\DBObj::getInstance( DBUSE );
$prEvnt = $db->prepare( 'CALL processEvent(:id , :creator , :type , :name , :startDate , :endDate , :startTime , :endTime );' );

$prEvnt->bindValue( ':id' , $event_id , \PDO::PARAM_INT || \PDO::PARAM_NULL );
$prEvnt->bindValue( ':creator' , $usr->getId() , \PDO::PARAM_INT );
$prEvnt->bindValue( ':type' , $event_type , \PDO::PARAM_INT );
$prEvnt->bindValue( ':name' , $event_name , \PDO::PARAM_INT );
$prEvnt->bindValue( ':startDate' , $start_date , \PDO::PARAM_STR );
$prEvnt->bindValue( ':endDate' , $end_date , \PDO::PARAM_STR );
$prEvnt->bindValue( ':startTime' , $start_time , \PDO::PARAM_STR || \PDO::PARAM_NULL );
$prEvnt->bindValue( ':endTime' , $end_time , \PDO::PARAM_STR || \PDO::PARAM_NULL );
$prEvnt->execute();
  • 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-05-24T02:01:25+00:00Added an answer on May 24, 2026 at 2:01 am

    Oh Dear – I just noticed the primary key and the references!!!

    Removed creator_id from primary key and the identifying refernce to event type – all is now sweet…

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

Sidebar

Related Questions

I have the following MySQL query: DELIMITER // CREATE PROCEDURE InsertResult (IN winnerID INT,
I have the following MySQL routine: DELIMITER $$ CREATE DEFINER=`root`@`%` PROCEDURE `getGroupOrders`(grp INT, ord
I have a mysql stored procedure which is giving me the following error:- #1064
I have written the following procedure to create a series of 20 databases. But
I am using MySQL 5.0. I have table with following structure and data. CREATE
Hi I have the following scenario. I am calling stored procedures to MySQL 5.x
I have the following mysql query. Could you please tell me how to write
I have the following mysql query, which is producing a list of entries by
I have the following MySQL-query: SELECT s.student_socialnr, s.student_lastname, s.student_firstname, cs.city_name, scp.cpl_startdate, scp.cpl_enddate, scp.cpl_invoice, cu.customer_name,
I have the following MySQL/InnoDB table. I added a compound index as the primary

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.