Jump to content

[HELP] executeSQLQuery() Problem


InDev

Recommended Posts

Hi, I'm new in MTA Scripting i learned some things and i have a problem with an SQL Query :

Here is the script:

function SQLDelColumnInTable( thePlayer, commandName, tabletarget, column )
local query = executeSQLQuery( "ALTER TABLE ? DROP COLUMN ? ", tabletarget, column )
if(query)then
outputChatBox( "Column: " ..column.. " in table "..tabletarget.." has been deleted !", thePlayer )
else outputChatBox( "The column can't be deleted, an error has occured", thePlayer )
end
end
addCommandHandler( "deletecolumn", SQLDelColumnInTable )

And When i test my command the Server send me this error message:

ERROR: Database query failed: near "DROP": syntax error

Can someone help me ? :|

Edited by Guest
Link to comment
Hi, I'm new in MTA Scripting i learned some things and i have a problem with an SQL Query :

Here is the script:

function SQLDelColumnInTable( thePlayer, commandName, tabletarget, column )
local query = executeSQLQuery( "ALTER TABLE ? DROP COLUMN ? ", tabletarget, column )
if(query)then
outputChatBox( "Column: " ..column.. " in table "..tabletarget.." has been deleted !", thePlayer )
else outputChatBox( "The column can't be deleted, an error has occured", thePlayer )
end
end
addCommandHandler( "deletecolumn", SQLDelColumnInTable )

And When i test my command the Server send me this error message:

ERROR: Database query failed: near "DROP": syntax error

Can someone help me ? :|

May need to embed it in `'s ("ALTER TABLE `?` DROP COLUMN `?`;")

Link to comment
Only the RENAME TABLE and ADD COLUMN variants of the ALTER TABLE command are supported. Other kinds of ALTER TABLE operations such as DROP COLUMN, ALTER COLUMN, ADD CONSTRAINT, and so forth are omitted.

Oops, looks like you're at a dead end. Why would you want to drop columns at runtime anyways?

  • Thanks 1
Link to comment

Because i made infos of players in a table, then i created a command for add columns, who works perfectly now, but in the beginning i had a bug, the command must set a default valor (a valor that i choose ( 0 ) ) but the command did'nt set this valor that's why i want to delete it it takes place for just a test columns...

I repaired the create command, but you can see that the delete does'nt work ^^

So if i can use anything else except recreate the table, i'll try it.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...