List:MySQL++« Previous MessageNext Message »
From:Mike Naylor Date:June 1 2009 9:47am
Subject:Re: ssqls and now()
View as plain text  
Thanks for responding Warren.  Here are the MySQL and SSQLS  
declarations as requested...

CREATE TABLE t_events (
	event_id int auto_increment,
	event_date timestamp default current_timestamp,
	event_text varchar(255) NOT NULL default '',
	event_type int,
	event_source_id int,
	event_destination_id int,
	PRIMARY KEY (event_id)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8"

sql_create_6(t_events, 1, 6,
	mysqlpp::sql_int, event_id,
	mysqlpp::sql_timestamp, event_date,
	mysqlpp::sql_varchar, event_text,
	mysqlpp::sql_int, event_type,
	mysqlpp::sql_int, event_source_id,
	mysqlpp::sql_int, event_destination_id);

The question (rephrased)...

Assume I'm trying to avoid having multiple sub-SSQLS declarations on  
the one table,  I'd like to be able to set certain SSQLS fields so  
that they don't update the MySQL records on insert or update.  I can  
set the auto increment field to value zero and this will not cause the  
MySQL value to be over written.  I'm looking for a way to set the  
timestamp field so that too will allow MySQL to do it's own thing.

Here's my code that isn't doing what I' like...

	t_event row;
	row.event_id = 0;
	row.event_date = mysqlpp::sql_timestamp::now();
	row.event_text = new_event_text;
	row.event_type = new_event_type;
	row.event_source_id = new_event_source_id;
	row.event_destination_id = new_event_destination_id;
	mysqlpp::Query query = con.query();
	query.insert(row);
	query.execute();

The event_date field sets the MySQL field to "0000-00-00 00:00:00".   
I've tried all sought of other methods (that will compiler), but  
haven't been able to stumble on the right one yet.

My question is, how can this be achieved, or is it really necessary to  
define all possible permutations of an SSQLS declaration?

i.e. I'd like to code something like this...

	row.event_date = 0;

or even better...

	row.event_date = mysqlpp::IGNORE;

Regards
Mike

Thread
ssqls and now()Mike Naylor30 May
  • Re: ssqls and now()Warren Young30 May
    • Re: ssqls and now()Mike Naylor1 Jun
      • Re: ssqls and now()Warren Young1 Jun
        • Re: ssqls and now()Mike Naylor1 Jun
          • Re: ssqls and now()Warren Young1 Jun
            • Re: ssqls and now()Mike Naylor2 Jun
              • Re: ssqls and now()Mike Naylor2 Jun
              • Re: ssqls and now()Warren Young3 Jun
                • Re: ssqls and now()Mike Naylor3 Jun
                  • Re: ssqls and now()Warren Young3 Jun
                    • Re: ssqls and now()Mike Naylor1 Jul