SA-MP Forums Archive
SQLite Multy Insert - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SQLite Multy Insert (/showthread.php?tid=502844)



SQLite Multy Insert - Ph0eniX - 26.03.2014

Hi all , i want to make 1 stock who create Houses ... now i have 2 stocks:

Code:
stock CreateHouses()
{
	AH(1, -2792.0032,218.5457,7.8594, 235.508994,1189.169897,1080.339966, 4312, 1 , 0, 0);
	AH(2, -2791.8650,212.2090,10.0547, 225.756989,1240.000000,1082.149902, 123, 2 , 0, 0);
	AH(3, -2791.6953,200.5145,7.8594, 235.508994,1189.169897,1080.339966, 2341, 6 , 0, 0);
}
and

Code:
stock AH(hi,Float:iconX,Float:iconY,Float:iconZ,Float:interiorX,Float:interiorY,Float:interiorZ,BuyCoins,BuyCash,Interior,HouseTime)
{
    new CQuery[200];
    //--------------------------------------------------------------------------
    for(new i = 0; i <= MAX_HOUSES; i++)
    {
        //--------------------------------------------------------------------------
		format(CQuery, 400, "INSERT INTO `Houses`(`hi`, `iconX`, `iconY`, `iconZ`, `intX`, `intY`, `intZ`, `BuyCoins`, `BuyCash`, `Interior`, `OwnerName`, `HouseTime`) VALUES('%d', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%d', '%d', '%d', ForSale, '%d')", hi,Float:iconX,Float:iconY,Float:iconZ,Float:interiorX,Float:interiorY,Float:interiorZ,BuyCoins,BuyCash,Interior,HouseTime);
		Result = db_query(Database, CQuery);
        printf(" House Created: Nr. %d BuyCoins. %d BuyCash. %d Interior.%d",hi,BuyCoins,BuyCash,Interior);
        db_free_result(Result);
    }
	return CQuery;
}
But , it don't work how i can make to insert in my database all what i have at Stock CreateHouse?

PS: I am not to good with SQLite when i create somethink like that...


Re: SQLite Multy Insert - Ph0eniX - 26.03.2014

Up..


Re: SQLite Multy Insert - Misiur - 26.03.2014

1. Use https://sampforum.blast.hk/showthread.php?tid=303682 to obtain error messages from queries.
2. When executing large quantities of queries one after another, use transactions to speed up your code n-fold.