Home » U++ Library support » U++ SQL » Sql .sch / Date (moved)
Sql .sch / Date (moved) [message #35379] |
Wed, 08 February 2012 15:42 |
|
ratah
Messages: 107 Registered: July 2010
|
Experienced Member |
|
|
Hello all,
I experiment with SQL schema / SqlId and apply it with MySQL database.
Here is my shema file
TABLE_(matable)
INT_ (ID) PRIMARY_KEY
STRING_ (SubscripDate, 20)
END_TABLE
and the CREATE statement in MySQL database
DROP TABLE IF EXISTS `mabase`.`matable`;
CREATE TABLE `mabase`.`matable`
(
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`SubscripDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
Here is a bit of my code where I use an instance of Time.
SQL * Select(SqlCountRows()).From(matable).Where(ID == id && SubscripDate == Time(2012,1,5));
My question is how to correctly write a schema file (TIME_?? DATE_??) with sqlid of type Date or Time?
Because when I query data from MySQL like this
SQL * Select(SubscripDate).From(matable).Where(ID == id)
if(SQL.Fetch())
{
Cout() << SQL[0];
}
that prints me 00/00/ 0 00:00:00 instead of 00/00/0000 00:00:00
I precise I use
SetDefaultCharset(CHARSET_UTF8);
SetLanguage( LNG_('F','R','F','R') );
in my MAIN function.
I know it is not supported by Sqlite but very usefull for other databases MySQL, Oracle,...
Thanks,
RAtah
|
|
|
Re: Sql .sch / Date (moved) [message #35666 is a reply to message #35379] |
Sun, 11 March 2012 19:30 |
jjacksonRIAB
Messages: 223 Registered: June 2011
|
Experienced Member |
|
|
To match them you should probably use:
TABLE_(matable)
INT_ (ID) PRIMARY_KEY
DATE (SubscripDate)
END_TABLE
or:
TABLE_(matable)
INT_ (ID) PRIMARY_KEY
DATETIME (SubscripDate)
END_TABLE
using _ depending on whether first use of column name or not.
Since your table creation uses TIMESTAMP, I'm not sure how this differs on MySql. I use MSSQL and in that system I don't think that TIMESTAMP can be converted to a date. Your mileage may vary.
[Updated on: Sun, 11 March 2012 19:31] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 04:08:36 CEST 2024
Total time taken to generate the page: 0.03407 seconds
|