Home » U++ Library support » U++ SQL » Call external funcions in SQL
Call external funcions in SQL [message #40745] |
Thu, 12 September 2013 18:37  |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
I wanted to ask you how to call an external function from SQL.
For example, doing:
SQL & ::Select(SqlAll()).From(TABLE).Where(DATE < GetSysTime()));
in the SQL it will always appear the origonal time, so if I call the query one hour later, the time will remain.
What I would need is that GetSysTime() were called every time the query is called.
Best regards
Iñaki
|
|
|
Re: Call external funcions in SQL [message #40747 is a reply to message #40745] |
Thu, 12 September 2013 19:23   |
|
koldo wrote on Thu, 12 September 2013 18:37 | Hello all
I wanted to ask you how to call an external function from SQL.
For example, doing:
SQL & ::Select(SqlAll()).From(TABLE).Where(DATE < GetSysTime()));
in the SQL it will always appear the origonal time, so if I call the query one hour later, the time will remain.
What I would need is that GetSysTime() were called every time the query is called.
|
Hi Koldo,
If you use the query as you posted it should evaluate the GetSysTime() each time you call it. The only problem might be if you stored the query for later or multiple execution. I mean something like:SqlSelect sel = Select(SqlAll()).From(TABLE).Where(DATE < GetSysTime());
// .. and one hour later or in some function
SQL & sel;
SQL.Fetch();
If you do that, than the easiest way would be to either create the query each time just before executing.
If I misunderstood something about the problem, please post bit more of the code, so I can get better idea what is the problem.
Also, if you really need what the title says, I'm not aware how to call user defined C++ functions in Sql, unless it is SQLite. If you are interested in that, I can post couple examples But it should not be necessary for you, judging by the example code you posted.
Best regards,
Honza
|
|
|
|
|
|
|
|
Re: Call external funcions in SQL [message #40889 is a reply to message #40761] |
Mon, 30 September 2013 12:49  |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
A detail to add
If you use local time, it is necessary to add 'localtime'. For example:
(DATE_TIME < (SqlTxt("(datetime('now','localtime','+5 day'))"))
Best regards
Iñaki
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:52:38 CEST 2025
Total time taken to generate the page: 0.02835 seconds
|