Thread overview |
---|
August 27, 2019 How to concat UUID into a SQL query string to MariaDB | ||||
---|---|---|---|---|
| ||||
Hi guys, Using MariaDB to communicate between appz via FIFO pipe Now I stumbled on the next problem, how to extract UUID from database into an UPDATE query that is a string ( the sql variable ). Got in a loop: char [16][10] hash; for(i =0; i < count; i++){ auto hash1 = row[0]; hash[i] = hash1.get!(string); ... do some FIFO Pipe work sql = "UPDATE guirequest SET done_request = SYSDATE() WHERE request_id=" + hash[i] + ";"; Get this error :Error: invalid array operation "UPDATE guirequest SET done_request = SYSDATE() WHERE request_id=" + hash[cast(uint)i] (possible missing []) Any ideas? /a |
August 27, 2019 Re: How to concat UUID into a SQL query string to MariaDB | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders S | On Tuesday, 27 August 2019 at 08:08:05 UTC, Anders S wrote:
> Any ideas?
+ is not a string concatenation. Try ~ instead:
auto x = "aa" ~ "bb" ~ "cc";
|
August 27, 2019 Re: How to concat UUID into a SQL query string to MariaDB | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jani Hur | On Tuesday, 27 August 2019 at 08:30:50 UTC, Jani Hur wrote: > On Tuesday, 27 August 2019 at 08:08:05 UTC, Anders S wrote: >> Any ideas? > > + is not a string concatenation. Try ~ instead: > > auto x = "aa" ~ "bb" ~ "cc"; Hi thanks for answer, but didn't help. Got this error instead : Error: cannot implicitly convert expression "UPDATE guirequest SET done_request = SYSDATE() WHERE request_id=" ~ cast(const(char)[])hash[cast(uint)i] ~ ";" of type char[] to string Notice you use auto x .... Am I better of using something like auto sql_respons ="UPDATE guirequest SET done_request = SYSDATE() WHERE request_id=" ~ hash[i] ~ ";"; |
August 27, 2019 Re: How to concat UUID into a SQL query string to MariaDB | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jani Hur | On Tuesday, 27 August 2019 at 08:30:50 UTC, Jani Hur wrote:
> On Tuesday, 27 August 2019 at 08:08:05 UTC, Anders S wrote:
>> Any ideas?
>
> + is not a string concatenation. Try ~ instead:
>
> auto x = "aa" ~ "bb" ~ "cc";
Hi again, the auto declaration worked as I expected my catenations should with the string
So thanks
|
August 27, 2019 Re: How to concat UUID into a SQL query string to MariaDB | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders S | On Tuesday, 27 August 2019 at 08:54:21 UTC, Anders S wrote: > Hi again, the auto declaration worked as I expected my catenations should with the string Great to hear that ! Strings are a bit "different" in D. Please help yourself and read the following that IMO is the best introduction to the topic: http://ddili.org/ders/d.en/strings.html Also see http://ddili.org/ders/d.en/auto_and_typeof.html for auto keyword. |
Copyright © 1999-2021 by the D Language Foundation