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

  • Home
  • SEARCH
  • 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 9242065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:30:10+00:00 2026-06-18T08:30:10+00:00

I am passing two arguments and I need to populate stats table with multiple

  • 0

I am passing two arguments and I need to populate stats table with multiple insert call. It is not working, can anyone help me on this?

CREATE PROCEDURE STAT(IN arg_From DATETIME, IN arg_End DATETIME)

INSERT INTO stats(source_id_fk,source_type,stat_type_id_fk,
                 stat_count,modified_on,created_on)   
(SELECT -1 as source_id_fk ,3 as source_type, 1 AS stat_type_id_fk ,
                 COUNT( 1 ) AS stat_count, NOW( ) AS modified_on , 
                 NOW( ) AS created_on 
FROM  wall_posts WHERE post_type =1 
and created_on >= arg_From 
and created_on <= arg_End group by 1,2,3,5,6)

INSERT INTO stats(source_id_fk,source_type,stat_type_id_fk,stat_count,
                 modified_on,created_on) 
(SELECT -1 as source_id_fk ,3 as source_type, 2 AS stat_type_id_fk , 
                 COUNT( 1 ) AS stat_count  , NOW( ) AS modified_on , 
                 NOW( ) AS created_on 
FROM  wall_posts WHERE post_type =2  
and created_on >= arg_From 
and created_on <= arg_End group by 1,2,3,5,6);
  • 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-18T08:30:11+00:00Added an answer on June 18, 2026 at 8:30 am

    You need to end the first insert statement with ;

    To make MySQL not think that your procedure is finished there you have to encapsulate those multiple statements in a BEGIN ... END block and change the delimiter.

    DELIMITER $$
    CREATE PROCEDURE STAT(IN arg_From DATETIME, IN arg_eND DATETIME)
    BEGIN
    INSERT INTO stats(source_id_fk,source_type,stat_type_id_fk,
                     stat_count,modified_on,created_on)   
    (SELECT -1 as source_id_fk ,3 as source_type, 1 AS stat_type_id_fk ,
                     COUNT( 1 ) AS stat_count, NOW( ) AS modified_on , 
                     NOW( ) AS created_on 
    FROM  wall_posts WHERE post_type =1 
    and created_on >= arg_From 
    and created_on <= arg_End group by 1,2,3,5,6);
    
    INSERT INTO stats(source_id_fk,source_type,stat_type_id_fk,stat_count,
                     modified_on,created_on) 
    (SELECT -1 as source_id_fk ,3 as source_type, 2 AS stat_type_id_fk , 
                     COUNT( 1 ) AS stat_count  , NOW( ) AS modified_on , 
                     NOW( ) AS created_on 
    FROM  wall_posts WHERE post_type =2  
    and created_on >= arg_From 
    and created_on <= arg_End group by 1,2,3,5,6);
    END $$
    DELIMITER ; /*and change it back to the normal `;` again*/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project in which I need to pass multiple arguments
I want to call a function from a controller, my_controller, passing in two arguments
I am getting the following error,it says not enough arguments,am already passing two arguments...what
I have this code below. As you can see I am passing two variables
psql has a construct for passing named arguments: psql -v name='value' which can then
I'm running the following method and I'm successfully passing two arguments (inventory, quantity) into
I'm passing two strings between two activities and for some reason, it crashes when
I'm passing two strings between two activities and for some strange reason, the strings
How do I go about passing two sets of Data to a view in
Possible Duplicate: Passing only two variables between controller and view - best practice? There

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.