Pulling data from SQL table in script

998 ? that one is bugged, you should use 999. Or did the hiveext.dll rewrite your request ?

ahh sry. wrong logentry. tried both 999 and 998. same error.

Okay, solved the error:
i need "?:[%1]:" %1 without questionmarksyntax throws the error.

Code:
diag_log ("executing Changeowner Mysqlcommand...");
//_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = %1 WHERE `unique_id` = %2",_survivorID,_objectUID];
 
//working, but replaces ALL ownerids in instances_deployable:
_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = ?:[%1]: WHERE `unique_id` = ?:[%2]:",_survivorID,_objectUID];
diag_log ("HIVE: WRITE: ChangedOwner "+ str(_key));
_result = _key call server_hiveReadWrite;
diag_log ("HIVE: WRITE: ChangedOwner result "+ str(_result));

But now it updates ALL items in instance_deployable.

LOG:
013-05-25 18:55:08 HiveExt: [Information] Method: 999 Params: UPDATE `instance_deployable` SET `owner_id` = ?:[101]:WHERE `unique_id` = ?:[98606189280335]:

2013-05-25 18:55:08 HiveExt: [Information] Result: ["CustomStreamStart",0]
 
Ive tested every syntax that comes in my mind. The Problme seems to be, that the unique ID is a String, not a number. But all i tried doesnt work. found on another thread that i have to use:

_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = ? WHERE `unique_id` = ?:[%1, ""%2""]:",_survivorID,_objectUID];
But than i get syntaxerror from HiveExt.dll.
if i user ""2%"" without "?" and brackets i get missing "]".

Ive tried to get it work with static values. Cant get it to work:

_key = "CHILD:999:UPDATE `instance_deployable` SET `owner_id` = ?:[101]: WHERE `unique_id` = ?:[98606189280335]:";

if i use
key = "CHILD:999:UPDATE `instance_deployable` SET `owner_id` = '101' WHERE `unique_id` = '98606189280335';

i get syntaxerror too.
 
couple of my examples that work:

Code:
    _key = format ["CHILD:999: select id from building WHERE class_name= '%1' AND id > ?:[0]:", _classname];

Code:
_key = format ["CHILD:999: INSERT INTO instance_building (building_id,instance_id,worldspace) VALUES (%1,1,'%2'):[]:", _tbl_bld_id,_worldspace];

Code:
_key = format ["CHILD:999:update `instance_building` set `worldspace` = '%1' where `id` = ?:[%2]:", _worldspace, _objectid];

Hope that helps

Sarge
 
couple of my examples that work:

Code:
    _key = format ["CHILD:999: select id from building WHERE class_name= '%1' AND id > ?:[0]:", _classname];

Code:
_key = format ["CHILD:999: INSERT INTO instance_building (building_id,instance_id,worldspace) VALUES (%1,1,'%2'):[]:", _tbl_bld_id,_worldspace];

Code:
_key = format ["CHILD:999:update `instance_building` set `worldspace` = '%1' where `id` = ?:[%2]:", _worldspace, _objectid];

Hope that helps

Sarge

Thank You Very much. compared the strings and found it:

_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = '%1' WHERE `unique_id` = ?:[%2]:",_survivorID,_objectUID];

btw.: how is the syntax when i need two "?" like ?:[%2]:" ?
 
I have been trying to update in the same fashion as listed here but the syntax on this just seems beyond me. Does anyone know where I might be going wrong?.
Here is my code.


_location = getPosATL _bomber;
_dir = getdir _bomber;

_worldspace = [_dir,_location];
_objectid = 2;

_key = format["CHILD:999:UPDATE `instance_deployable` SET `worldspace` = '%1' WHERE `id` = ?:['%2']:",_worldspace,_objectid];

_key call server_hiveWrite;


It will indeed update the database as intended then immediately crash the server with.



Exception code: C0000005 ACCESS_VIOLATION at 5B9AC778

Allocator: C:\Program Files (x86)\Steam\steamapps\common\Arma 2 Operation Arrowhead\dll\tbb4malloc_bi.dll

graphics: No

resolution: 160x120x32

Version 1.62.103419
Fault address: 5B9AC778 01:0001B778 C:\Program Files (x86)\Steam\steamapps\common\Arma 2 Operation Arrowhead\DatabaseMySql.dll
file: dayz_1
world: chernarus
Prev. code bytes: CC CC CC CC CC CC CC CC 53 56 8B 74 24 0C 33 DB
Fault code bytes: 39 5E 0C 0F 85 83 00 00 00 57 38 5E 50 75 4B 8B
Registers:
EAX:00000001 EBX:00000000
ECX:00000000 EDX:0D626420
ESI:00000000 EDI:00000001
CS:EIP:0023:5B9AC778
SS:ESP:002B:00DFC1B4 EBP:00DFC2B0
DS:002B ES:002B FS:0053 GS:002B
Flags:00010246
=======================================================
note: Minidump has been generated into the file @dayzcc_config\1\arma2oaserver_1.mdmp
 
to remove some of the confusion ... you can use:

Code:
_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = '%1' WHERE `unique_id` = '%2':[]:",_survivorID,_objectUID];

as well, assuming that unique_id is a string and not a number. If it's a number, remove the '' around %2.

Sarge
 
Sarge,
Thank you for the reply. That does indeed make it less confusing but I am still having the issue.
I tried this

Code:
_key = format["CHILD:999:UPDATE `instance_deployable` SET `worldspace` = '%1' WHERE 'id' = %2:[]:",_worldspace,_objectid];

Still no dice as it kills the server every time. I even tried it without the ' around the 'id'. Do you have any more idea's where I might look to solve this?
 
to remove some of the confusion ... you can use:

Code:
_key = format["CHILD:999:UPDATE `instance_deployable` SET `owner_id` = '%1' WHERE `unique_id` = '%2':[]:",_survivorID,_objectUID];

as well, assuming that unique_id is a string and not a number. If it's a number, remove the '' around %2.

Sarge



Can you explain what '%2':[]: is doing ? Is this sqlsyntax or hiveext syntax ? What does the :[]: stand for ? can i place it avfter every %x ?

Sry for so many question, i want to understand instead of just copy it :)
 
Can you explain what '%2':[]: is doing ? Is this sqlsyntax or hiveext syntax ? What does the :[]: stand for ? can i place it avfter every %x ?

Sry for so many question, i want to understand instead of just copy it :)

The %1 %2 ect are just a way of saying hey I want to put something here and I will tell you what that is later in the statement. in this case the later is after the second " and comma. %1=first variable after comma %2 = second one after comma and so on.

I would guess this is to keep the sql syntax but I don't really know. Everything from the update through the %2 is sql. buuuuut the sql is encapsulated in the hive whatever code so I am confused my self about what proper hive syntax is.
 
Sarge,
Thank you for the reply. That does indeed make it less confusing but I am still having the issue.
I tried this

Code:
_key = format["CHILD:999:UPDATE `instance_deployable` SET `worldspace` = '%1' WHERE 'id' = %2:[]:",_worldspace,_objectid];

Still no dice as it kills the server every time. I even tried it without the ' around the 'id'. Do you have any more idea's where I might look to solve this?

Did you increase your loglevel for the hive, and check what happens there ?

Sarge
 
Hmm not sure what to make of that but it would appear it does not like the format of worldspace

2013-05-28 03:28:57 HiveExt: [Debug] Original params: |CHILD:999:UPDATE `instance_deployable` SET `worldspace` = `[1,[13987.6,10755.2,104.37]]` WHERE id = 2:[]:|

2013-05-28 03:28:57 HiveExt: [Information] Method: 999 Params: UPDATE `instance_deployable` SET `worldspace` = `[1,[13987.6,10755.2,104.37]]` WHERE id = 2:[]:

2013-05-28 03:28:57 Database: [Error] Error 1054 (Unknown column '[1,[13987.6,10755.2,104.37]]' in 'field list') in MySQLQuery SQL: 'UPDATE `instance_deployable` SET `worldspace` = `[1,[13987.6,10755.2,104.37]]` WHERE id = 2'
 
use single quotes ' around your parameter for worldspace, and if that doesnt work, try that query in an sql console until it works.

Sarge
 
I have altered my code to this

Code:
_key = format["CHILD:999:UPDATE `dayz_chernarus`.`instance_deployable` SET `worldspace`='%1' WHERE `id`=%2:[]:",_worldspace,_objectid];

Still getting the access violation but the hive log now shows no issue even though it still kills the server and the sql works on its own in mysqlworkbench. although to make the code work I do have to remove the ' from the outside of the code as written in the 3rd log entry starting from UPDATE.



2013-05-28 03:59:35 HiveExt: [Debug] Original params: |CHILD:999:UPDATE `dayz_chernarus`.`instance_deployable` SET `worldspace`='[0,[13987.6,10755.2,105.059]]' WHERE `id`=2:[]:|

2013-05-28 03:59:35 HiveExt: [Information] Method: 999 Params: UPDATE `dayz_chernarus`.`instance_deployable` SET `worldspace`='[0,[13987.6,10755.2,105.059]]' WHERE `id`=2:[]:

2013-05-28 03:59:35 Database: [Trace] Query [1 ms] SQL: 'UPDATE `dayz_chernarus`.`instance_deployable` SET `worldspace`='[0,[13987.6,10755.2,105.059]]' WHERE `id`=2'
 
One really odd thing about all of this is that when the syntax is correct a write does indeed occur then it immediately crashes the server with


Exception code: C0000005 ACCESS_VIOLATION at 57ECC778

Allocator: C:\Program Files (x86)\Steam\steamapps\common\Arma 2 Operation Arrowhead\dll\tbb4malloc_bi.dll

graphics: No

resolution: 160x120x32
 
all the other hive calls work ? So the standard Dayz ones ?

Cant think of what crashes your hive, what you could try if you are familiar with it is to try out different hive versions with their corresponding dlls ...

Sarge
 
Dont mean to hijack this thread but Im also trying the 999 method and being foiled to the point of asking for help....

On the server side, in server_updateObject.sqf Im playing with this code:
Code:
_char_id = 10;
_key = format ["CHILD:999: SELECT PlayerUID FROM character_data WHERE CharacterID=%1:[]:", _char_id];
_result = _key call server_hiveReadWrite;
diag_log(format["Char_id:%1\nkey:%2\nResult from hive:%3", _char_id, _key, _result]);
_status = _result select 0;

The return value is <null> and HiveExt.log says this:
Code:
2013-08-12 20:08:12 HiveExt: [Error] Invalid method id: 999

this is using Pwn0z0rs server, and HiveExt.dll version 0.9.6.14 (seems that is the latest?).

Any pointers as to what Im doing wrong?
 
Pwn0z0rs HiveEXT.dll dont know this method. I have asked for an alternative in the forum, but i dont got any answer.
 
Thanks for the reply ... that leaves a problem.
What Im trying to achieve is to check who created a doorway, and only let the creator open the door.
The creator would be found using the characterid from object_data, then see if that belongs to the same playeruid as the creator.
If i only checked directly on characterid, ownership would cease at death which is not desirable.
 
Back
Top