Comments - Dynamic Columns

8 years, 2 months ago John Ledyard

Is it possible to use a string from a variable into the column_create function? For example: set @stringvar = "'column1', 'value1', 'column2', 'value2'"

Insert into table1 COLUMN_CREATE(@stringvar); This fails with check your syntax error.

It seems MariaDB doesn't like this and it only wants to use literal string in the COLUMN_CREATE() function like COLUMN_CREATE('column1', 'value1', 'column2', 'value2')

It seems like you should be able to pass a variable into it and have it create the columns with the values. Any ideas or help on this matter would be great. Thanks.

 
8 years, 2 months ago Oleksandr Byelkin

Any expression which can be turned to string can be used as an argument, but each parameter separatly. What you want is parsing some sting for argument which is not function of any SQL function.

COLUMN_ADD("", @key, @value) should work ass well as COLUMN_CREATE(2+4, repeat("X",22))

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.