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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:40:45+00:00 2026-06-15T16:40:45+00:00

I have a problem where my function is only working when I don’t use

  • 0

I have a problem where my function is only working when I don’t use the parameters that I pass.

Here is the code I would like to have work:

DELIMITER $$

CREATE DEFINER=`root`@`%` FUNCTION `getTableColumns`(schemaName varchar(100), tableName varchar(100), omitColumns varchar(200)) RETURNS varchar(5000) CHARSET latin1
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE res  VARCHAR(5000) DEFAULT "";

  DECLARE col  VARCHAR(200);
  DECLARE cur1 CURSOR FOR 
    select COLUMN_NAME from information_schema.columns 
    where table_schema = @schemaName AND table_name = @tableName AND FIND_IN_SET(COLUMN_NAME, @omitColumns) = 0 ORDER BY ORDINAL_POSITION;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
  OPEN cur1;
  REPEAT
       FETCH cur1 INTO col;
       IF NOT done THEN 
          set res = CONCAT(res,IF(LENGTH(res)>0,",",""),col);
       END IF;
    UNTIL done END REPEAT;
  CLOSE cur1;
  RETURN res;
END

Here is the code that does works when I replace the parameters with literal strings:

DELIMITER $$

CREATE DEFINER=`root`@`%` FUNCTION `getTableColumns`(schemaName varchar(100), tableName varchar(100), omitColumns varchar(200)) RETURNS varchar(5000) CHARSET latin1
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE res  VARCHAR(5000) DEFAULT "";

  DECLARE col  VARCHAR(200);
  DECLARE cur1 CURSOR FOR 
    select COLUMN_NAME from information_schema.columns 
    where table_schema = 'test' AND table_name = 'employees' ORDER BY ORDINAL_POSITION;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
  OPEN cur1;
  REPEAT
       FETCH cur1 INTO col;
       IF NOT done THEN 
          set res = CONCAT(res,IF(LENGTH(res)>0,",",""),col);
       END IF;
    UNTIL done END REPEAT;
  CLOSE cur1;
  RETURN res;
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-15T16:40:46+00:00Added an answer on June 15, 2026 at 4:40 pm

    Try this:

    DELIMITER $$
    
    CREATE DEFINER=`root`@`%` FUNCTION `getTableColumns`(_schemaName varchar(100), _tableName varchar(100), _omitColumns varchar(200)) RETURNS varchar(5000) CHARSET latin1
    BEGIN
      DECLARE done INT DEFAULT 0;
      DECLARE res  VARCHAR(5000) DEFAULT "";
    
      DECLARE col  VARCHAR(200);
      DECLARE cur1 CURSOR FOR 
        select COLUMN_NAME from information_schema.columns 
        where table_schema = _schemaName AND table_name = _tableName ORDER BY ORDINAL_POSITION;
    
      DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
      OPEN cur1;
      REPEAT
           FETCH cur1 INTO col;
           IF NOT done THEN 
              set res = CONCAT(res,IF(LENGTH(res)>0,",",""),col);
           END IF;
        UNTIL done END REPEAT;
      CLOSE cur1;
      RETURN res;
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a piece of code that I am working on using function
I have problem with fancybox. I want to write a function that will run
I have a problem to create a preprocessor macro function, that concatenates two Strings
I have used the following code to get click outside to close working: Here
Here is my problem... I don't understand why this isn't working for me :)
i don't face this problem while working on localhost only when I access the
I have some code (which I cannot change) that I need to get working
I have an intermittent problem with some code that writes to a Windows Event
I have an app that is working fine when the dev option Don't keep
I have problem with function checking collision. No matter what I do it throws

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.