Using

This is a discussion on Using within the MySQL Database forums, part of the Database Forums category; I have time in time_t, a C++ structure. Is there a way that I can use this 'time_t' in a ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-07-2007
asnowfall@gmail.com
 
Posts: n/a
Default Using

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.

Reply With Quote
  #2 (permalink)  
Old 11-07-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Using

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
==================

Reply With Quote
  #3 (permalink)  
Old 11-10-2007
Ted
 
Posts: n/a
Default Re: Using

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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:55 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0