digitalmars.D.learn - How to concat UUID into a SQL query string to MariaDB
- Anders S (18/18) Aug 27 2019 Hi guys,
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
Aug 27 2019
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";
Aug 27 2019
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: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] ~ ";";Any ideas?+ is not a string concatenation. Try ~ instead: auto x = "aa" ~ "bb" ~ "cc";
Aug 27 2019
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:Hi again, the auto declaration worked as I expected my catenations should with the string So thanksAny ideas?+ is not a string concatenation. Try ~ instead: auto x = "aa" ~ "bb" ~ "cc";
Aug 27 2019
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 stringGreat 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.
Aug 27 2019