03.04.2016, 04:48
So I created a database but one of my columns cannot be assigned 'NOT NULL' for some reason, I have searched the entire internet, removing the 'NOT NULL' seems to fix the issue but then it makes the column null even if I change it using INSERT or UPDATE.
Here's the database
When I execute this in the database it says the constraint error.
Error itself
Here's the database
pawn Код:
LoadDatabase()
{
new Query[2000];
Database = db_open("scrp.db");
strcat(Query, "CREATE TABLE IF NOT EXISTS users (userid INTEGER PRIMARY KEY AUTOINCREMENT, username VARCHAR(24) COLLATE NOCASE, password VARCHAR(129), level INTEGER DEFAULT 1 NOT NULL, money INTEGER DEFAULT 5000 NOT NULL,", sizeof(Query));
strcat(Query, "faction INTEGER DEFAULT 0 NOT NULL, factionrank INTEGER DEFAULT 0 NOT NULL, bank INTEGER DEFAULT 10000 NOT NULL, savings INTEGER DEFAULT 0 NOT NULL, savingson INTEGER DEFAULT 0 NOT NULL, skin INTEGER DEFAULT 0 NOT NULL,", sizeof(Query));
strcat(Query, "toy1 INTEGER DEFAULT 0 NOT NULL, toy2 INTEGER DEFAULT 0 NOT NULL, toy3 INTEGER DEFAULT 0 NOT NULL, toy4 INTEGER DEFAULT 0 NOT NULL, toy5 INTEGER DEFAULT 0 NOT NULL, toy6 INTEGER DEFAULT 0 NOT NULL, toy7 INTEGER DEFAULT 0 NOT NULL,", sizeof(Query));
strcat(Query, "toy8 INTEGER DEFAULT 0 NOT NULL, toy9 INTEGER DEFAULT 0 NOT NULL, toy10 INTEGER DEFAULT 0 NOT NULL, weapon1 INTEGER DEFAULT 0 NOT NULL, ammo1 INTEGER DEFAULT 0 NOT NULL, weapon2 INTEGER DEFAULT 0 NOT NULL, ammo2 INTEGER DEFAULT 0 NOT NULL,", sizeof(Query));
strcat(Query, "marijuana INTEGER DEFAULT 0 NOT NULL, meth INTEGER DEFAULT 0 NOT NULL, crack INTEGER DEFAULT 0 NOT NULL, cocaine INTEGER DEFAULT 0 NOT NULL, heroin INTEGER DEFAULT 0 NOT NULL, shrooms INTEGER DEFAULT 0 NOT NULL, keys INTEGER DEFAULT 0 NOT NULL,", sizeof(Query));
strcat(Query, "job INTEGER DEFAULT 0 NOT NULL, hours INTEGER DEFAULT 0 NOT NULL, paycheck INTEGER DEFAULT 0 NOT NULL, interior INTEGER DEFAULT 0 NOT NULL, vw INTEGER DEFAULT 0 NOT NULL, posx FLOAT DEFAULT 0.0 NOT NULL, posy FLOAT DEFAULT 0.0 NOT NULL, posz FLOAT DEFAULT 0.0 NOT NULL,", sizeof(Query));
strcat(Query, "posa FLOAT DEFAULT 0.0 NOT NULL, admin INTEGER DEFAULT 0 NOT NULL, tester INTEGER DEFAULT 0 NOT NULL, upgradep INTEGER DEFAULT 0 NOT NULL, health FLOAT DEFAULT 100.0 NOT NULL, armor FLOAT DEFAULT 0.0 NOT NULL, duty INTEGER DEFAULT 0 NOT NULL, vip INTEGER DEFAULT 0 NOT NULL,", sizeof(Query));
strcat(Query, "isswat INTEGER DEFAULT 0 NOT NULL, isdetective INTEGER DEFAULT 0 NOT NULL, age INTEGER DEFAULT 0 NOT NULL, origloc VARCHAR(30) NOT NULL)", sizeof(Query));
db_query(Database, Query);
print(Query);
}
pawn Код:
INSERT INTO `users` (`username`,`password`) VALUES ('%s','%s')
pawn Код:
NOT NULL constraint failed: users.origloc: INSERT INTO `users` (`username`,`password`) VALUES ('%s','%s')