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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:38:24+00:00 2026-06-01T08:38:24+00:00

I am passing table field name as parameter to stored procedure but stored procedure

  • 0

I am passing table field name as parameter to stored procedure but stored procedure take field name as value instead of field name and throws error.

e.g if i pass value isEnabled via parameter FieldName, Mysql throws error unknown column ‘isEnabled’ in field list, which shows mysql automatically add quote.

Here is sample stored procedure i wrote.

CREATE `VSK_Comments_UpdateAction`(IN FieldName varchar(30),IN FieldValue tinyint,CID bigint)
BEGIN
Update comments Set FieldName=FieldValue WHERE commentid=CID;
END;

Is there is a way so i can properly pass field name dynamically properly.

  • 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-01T08:38:26+00:00Added an answer on June 1, 2026 at 8:38 am

    You can use prepared statements, for example –

    CREATE `VSK_Comments_UpdateAction`(IN FieldName varchar(30),IN FieldValue tinyint,CID bigint)
    BEGIN
      SET @query = CONCAT('Update comments Set ', FieldName, '=? WHERE commentid=?');
      PREPARE stmt FROM @query;
      SET @FieldValue = FieldValue;
      SET @CID = CID;
      EXECUTE stmt USING @FieldValue, @CID;
      DEALLOCATE PREPARE stmt;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a stored procedure that accept an XML parameter, parsing it's
I have a varchar(max) field containing Name Value pairs, in every line I have
I'm passing a table of up to 1000 rows, consisting of name, ID, latitude
I'm trying to solve the problem of passing a 2-dimensional table into JavaScript AJAX
I have one table TABLE_QUESTION. I need to fetch record by passing exam_id and
Passing an undimensioned array to the VB6's Ubound function will cause an error, so
passing post data using cURL requires that the name of the input. However, I
When passing named parameters of the form :name to PDOStatement::bindParam() , it seems to
I have a field in a SQL Server table that is of type bit
Please help with my final project in my intro/intermediate programming class. Using stored procedures,table

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.