Jump to content

[HELP] executeSQLQuery() Problem


InDev

Recommended Posts

Posted (edited)

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
Posted
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 `?`;")

Posted

No it send me the same Error message

I think the MTA'SQL does not recognize the DROP COLUMN and he think it is an syntax error so if there is any other way to delete a Column i'll try it...

Posted
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
Posted

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.

Posted
It is your "registry.db" file in your server folder.

Thank you subenji99

Thnk you very much guys my problem it's to the past now :lol:

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...