Home » U++ Library support » U++ SQL » Problem with SqlUpdate
Re: Problem with SqlUpdate [message #45728 is a reply to message #45725] |
Tue, 29 December 2015 20:05   |
|
nilrum wrote on Tue, 29 December 2015 17:48Quote:The problematic brackets come from SqlSet(). You actually want just a single value, not a set of values:
SqlUpdate(LINK)(ID_OTHER, SqlSet(Select(ID_TWO).From(TWO).Where(NAME_TWO == "Name"))).Where(ID_LINK == 1);
This should work as you intended.
So I tried to write, but I receive an error
error C2664: 'Upp::SqlUpdate &Upp::SqlUpdate::operator ()(const Upp::SqlId &,Upp::SqlVal)' : cannot convert argument 1 from 'Upp::SqlId' to 'const Upp::SqlSet &'
Reason: cannot convert from 'Upp::SqlId' to 'const Upp::SqlSet'
I'm sorry that I mislead you... I haven't actually check if the code compiles 
I had to check the code of SqlSelect and I finally figured out how this should be done properly:SqlUpdate(LINK)(ID_OTHER, Select(ID_TWO).From(TWO).Where(NAME_TWO == "Name").AsValue()).Where(ID_LINK == 1);
Notice the AsValue() method of SqlSelect. It turns the subquery into SqlVal, which can be then assigned to ID_OTHER column. There is also similar method AsTable(), which does similar job in case of subqueries in FROM clause.
Hope this will finally work 
Honza
|
|
|
Goto Forum:
Current Time: Mon Apr 28 19:42:18 CEST 2025
Total time taken to generate the page: 0.00724 seconds
|