Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Sql .sch / Date (moved)
Sql .sch / Date (moved) [message #35379] Wed, 08 February 2012 15:42 Go to next message
ratah is currently offline  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 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 221
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

Re: Sql .sch / Date (moved) [message #35709 is a reply to message #35666] Wed, 14 March 2012 07:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
jjacksonRIAB wrote on Sun, 11 March 2012 14:30


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.


U++ always allows fetching timestamp->Date or date->Time. It is feature of Value, actually.

AFAIK, all SQL databases also provide silent conversion of these types.
Re: Sql .sch / Date (moved) [message #36284 is a reply to message #35709] Fri, 18 May 2012 10:53 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hello all,

Thank you for your reply. I experiment with that
Quote:

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


but it seems it not works.

I use TIME_ instead of DATETIME as defined in Sqlite3Shema.h
Here is an example.
Re: Sql .sch / Date (moved) [message #36296 is a reply to message #36284] Fri, 18 May 2012 19:38 Go to previous message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Ratah,

Did you try something as follows ?

FormatDate((Date)SQL[SubscriptDate],"dddd,mmmm,yyyy",GetSystemLNG());


or something approaching as I am not really sure of the syntax.

Regards

Biobytes

[Updated on: Fri, 18 May 2012 19:39]

Report message to a moderator

Previous Topic: Filling same SqlArray with different tables from database
Next Topic: Access to S_* Structure of TABLE crash Application.
Goto Forum:
  


Current Time: Sat Jun 15 04:31:24 CEST 2024

Total time taken to generate the page: 0.01699 seconds