|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have time in time_t, a C++ structure.
Is there a way that I can use this 'time_t' in a SQL query to update row? The functionality that I am looking is for some SQL function that takes time_t and converts the time to sql's date format before updating the row. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
asnowfall@gmail.com wrote:
> I have time in time_t, a C++ structure. > Is there a way that I can use this 'time_t' in a SQL query to update > row? > > The functionality that I am looking is for some SQL function that > takes time_t and converts the time to sql's date format before > updating the row. > > No. SQL knows nothing about C++ structures. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Nov 7, 6:14 pm, "asnowf...@gmail.com" <asnowf...@gmail.com> wrote:
> I have time in time_t, a C++ structure. > Is there a way that I can use this 'time_t' in a SQL query to update > row? > > The functionality that I am looking is for some SQL function that > takes time_t and converts the time to sql's date format before > updating the row. Jerry is right to say SQL knows nothing about C++ structures. That said, I would add two comments. 1) If you have a need to use data stored, within your C++ program in time_t, and you need to use it in your process of updating or manipulating data in your database back end, then write your own function to handle the conversion. It isn't that hard. Yes, you have to write code, but you can either work using the standard C/C++ libraries, or you can work from the definition of time_t from the standard headers. All you have to do is decide where best to do it: on the client side within your own code or on the server side, within a stored procedure. There is nothing magical about time_t. It is just a long integer, and it is the library functions that give it meaning. You can reproduce on the server side what the standard C functions give you on the client side, or you can send data in types the database understands and process them on the client side. 2) I spend most of my time on database programs developing the client side either in plain Java, using JDBC, or with PHP or Perl. But most of my other code is developed using C++. Therefore, as one C++ developer to another, if you are often developing the client of a database application in C++, then you will be wise to either source or develop a library of utilities to support basic communication between your application and whatever database you are using. You are not on your own in this. Go to http://www.mysql.com/products/connector/ and you'll find about half a dozen different options for database development on Windows using MySQL. Your options may be constrained if you're working on linux, but there too there's no dearth of options I am sure. Pick the option that best meets your need and then write code to use it in the most efficient manner possible. WRT writing what you need in to interact with MySQL, take a look at chapter 23 of the manual (in pdf form) for MySQL 5. In it I see you can write your code in C, PHP, Perl, C++, Python, Tcl, and Eiffel. They have gone the extra mile for you to work with MySQL in any of the most commonly used languages. So study what they say about the C API to MySQL, and your own documentation for whatever C++ development tools you're using, and all ought to be clear. In short, if you don't find what you're looking for, write it yourself. Good luck and happy coding Ted |
|
![]() |
| Outils de la discussion | |
|
|