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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:57:07+00:00 2026-05-26T08:57:07+00:00

The below SP is not giving any result even though there are 48 rows

  • 0

The below SP is not giving any result even though there are 48 rows as per the where clause

BEGIN
DECLARE SelectClause VARCHAR(2000);
  if v_mode='SearchByString' then
    SET SelectClause ='select SURVEY_USER.username,SURVEY.* from SURVEY, SURVEY_USER';

if v_SearchString is not null then
    SET SelectClause=CONCAT(@SelectClause,'  where ');
    Set SelectClause=CONCAT(@SelectClause,v_SearchString);
end if;
SET SelectClause=CONCAT(@SelectClause,'  order by SURVEY.created_date DESC;') ;
select SelectClause;
SET @query = SelectClause;
    PREPARE stmt FROM  @query;
    EXECUTE stmt;
 select stmt;
end if;
END

I tried a lot but not getting any problem. I also tried select clause to print the command at various places to not able to print it.
Please give me some solution.
There are my parameters that I am passing
v_mode=’SearhByString’
v_SearchString=’SURVEY_USER.username=chiragfanse’

It should return 48 rows but does not return anything.

  • 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-26T08:57:08+00:00Added an answer on May 26, 2026 at 8:57 am
    BEGIN
    
      DECLARE SelectClause VARCHAR(2000);
    
      IF v_mode = 'SearchString' THEN
    
        SET SelectClause = CONCAT('select SURVEY_USER.username,SURVEY.* from SURVEY, SURVEY_USER');
    
        IF SearchString IS NOT NULL THEN
          SET SelectClause = CONCAT(SelectClause, ' where ', SearchString);
        END IF;
    
        SET SelectClause = CONCAT(SelectClause, '  order by SURVEY.created_date DESC;');
    
        SET @query = SelectClause;
        PREPARE stmt FROM  @query;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    
      END IF;
    END
    
    1. All declaration have to be at the begining.
    2. Rename @SelectClause to SelectClause, because you are declaring this variable.
    3. Check the usage of SET clauses. I have added one.
    4. Have a look at prepared statements reference, it will help you to execute the query you built.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to fetch a collection by giving an initial model parameter
I am creating Relative Layout which looks fine not giving any error at that
My query is like below (not working correctly) SELECT RentACar.dbo.Car.car_id as clm_CAR_ID, RentACar.dbo.Car_Image.car_image_url as
I would like to solve rounding mechanism by using php4,5.2 and below (not 5.3)
Below code not work, but it's work fine for jsf1.2. Now the framework is
The below does not compile: Func<int, int> fac = n => (n <= 1)
The question below is not really a programming question, but more of how can
The code below does not work but meant to illustrate what I want to
Why does this graphml file below does not render the node color properly in
I have this horrible habit of typing the below and not catching it until

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.