|
Post by lotusdesignz on Dec 7, 2021 12:51:22 GMT
Running this code I keep getting Error Message: near "COLUMN": syntax error
try
{
bool recordExists;
string sqlSelect = "SELECT sowulo FROM StatsTable";
dbManager.QueryFirstRecord<Statistics>(out recordExists, sqlSelect);
SQLite3.Result res = 0;
string errorMsg = "";
if (recordExists)
{ //string sqlAlter = "ALTER TABLE StatsTable RENAME COLUMN sowulo TO sowilo";
string sqlAlter = "ALTER TABLE StatsTable RENAME COLUMN sowulo TO sowilo;";
//dbManager.Execute(sqlAlter);
dbManager.ExecuteWithResult(out res, out errorMsg, sqlAlter);
Debug.Log("SQLite3.Result: " + res);
Debug.Log("Error Message: " + errorMsg);
}
else
{
Debug.Log("Column 'sowulo' has been renamed to 'sowilo'");
}
}
catch (SQLiteException e)
{
Debug.Log("SQLiteException: " + e);
}
}
According to this post I should be able to rename columns: echo17.proboards.com/post/360 I already have a working database. The blank template is in the project's 'Assets' folder, if that is what the post is referring to. Not sure what else is missing.
|
|
|
Post by echo17 on Dec 8, 2021 14:40:53 GMT
Your query looks good. I tried testing against the demo tables included with SimpleSQL and it worked fine there, so I'm not sure what the issue is.
var sql = "ALTER TABLE Weapon RENAME COLUMN WeaponName TO WeaponName2";
SQLite3.Result res; string msg;
dbManager.ExecuteWithResult(out res, out msg, sql);
Debug.Log(res); Debug.Log(msg);
results in: I think I'll need to see an example project to be able to diagnose your issue. Please see this FAQ for more information: FAQ
|
|
|
Post by lotusdesignz on Dec 12, 2021 1:04:24 GMT
I was able to rename it, but for those wondering I had to create a temp table and made all the necessary changes and inserted a into the new table. I tried your rename column code on the demo table, and it works also. So it's probably my code, I have a lot written there so it's a huge mess. I'll just keep this in mind the next time I need to rename columns.
|
|