Illegal SQL when exporting view - duplicate DEFAULT CURRENT_TIMESTAMP

EJP's profile image EJP posted 12 years ago in General Permalink
If I export a view containing more than one TIMESTAMP column, the SQL for the temporary table gives all of them DEFAULT CURRENT_TIMESTAMP, which is not legal in MySQL. Only one such column may have this default.

View:

-- Dumping structure for view vsimlauncher.v_lab_progress_activity_report
DROP VIEW IF EXISTS `v_lab_progress_activity_report`;
-- Removing temporary table and create final VIEW structure
DROP TABLE IF EXISTS `v_lab_progress_activity_report`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_lab_progress_activity_report` AS select `products`.`vendor_id` AS `vendor_id`,`subscriptions`.`report_target_id` AS `report_target_id`,`report_targets`.`report_target_url` AS `report_target_url`,`lab_progress_user_summary`.`subscriber_id` AS `subscriber_id`,`lab_progress_user_summary`.`subscriber_uid` AS `subscriber_uid`,`product_commerce_codes`.`product_id` AS `product_id`,`report_targets`.`report_target_type` AS `report_target_type`,`products`.`smartlab_name` AS `smartlab_name`,`lab_progress_user_summary`.`status` AS `status`,`lab_progress_user_summary`.`percentage_progress` AS `percentage_progress`,`lab_progress_user_summary`.`status_evaluation_datetime` AS `status_evaluation_datetime`,`lab_progress_user_summary`.`pass_threshold_in_percent` AS `pass_threshold_in_percent`,`lab_progress_user_summary`.`no_of_visits` AS `no_of_visits`,`lab_progress_user_summary`.`result` AS `result`,`lab_progress_user_summary`.`total_number_steps` AS `total_number_steps`,`labs`.`pass_threshold` AS `pass_threshold`,`lab_progress_user_summary`.`access_datetime` AS `last_access_datetime`,`lab_progress_user_summary`.`raw_score` AS `obtained_score`,`lab_progress_user_summary`.`percentage_correct` AS `obtained_score_in_percent`,(`subscriptions`.`start_datetime` - interval (to_days(`lab_progress_user_summary`.`vsim_activity_datetime`) - to_days(`subscriptions`.`start_datetime`)) day) AS `time_spent`,100.0 AS `weightage`,(`subscriptions`.`start_datetime` + interval `product_commerce_codes`.`subscription_duration` day) AS `access_expires_on_datetime`,`lab_progress_user_summary`.`last_reported_datetime` AS `last_reported_datetime` from ((((((`lab_progress_user_summary` join `products` on((`lab_progress_user_summary`.`product_name` = `products`.`name`))) join `product_commerce_codes` on((`lab_progress_user_summary`.`product_name` = `product_commerce_codes`.`product_name`))) join `subscriptions` on(((`product_commerce_codes`.`product_id` = `subscriptions`.`product_id`) and (`lab_progress_user_summary`.`subscriber_uid` = `subscriptions`.`subscriber_uid`)))) join `labs` on((`products`.`smartlab_name` = `labs`.`smartlab_name`))) join `vendors` on((`products`.`vendor_id` = `vendors`.`vendor_id`))) join `report_targets` on((`subscriptions`.`report_target_id` = `report_targets`.`report_target_id`))) order by `lab_progress_user_summary`.`last_reported_datetime` desc,`subscriptions`.`report_target_id`,`lab_progress_user_summary`.`subscriber_uid`;

The joined tables are too numerous to post here but the result is that there are several TIMESTAMP columns in the view.

Temp table SQL:

-- Dumping structure for view vsimlauncher.v_lab_progress_activity_report
DROP VIEW IF EXISTS `v_lab_progress_activity_report`;
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `v_lab_progress_activity_report` (
`vendor_id` VARCHAR(45) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`report_target_id` VARCHAR(255) NOT NULL COLLATE 'utf8_general_ci',
`report_target_url` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`subscriber_id` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`subscriber_uid` VARCHAR(36) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`product_id` VARCHAR(45) NOT NULL COLLATE 'utf8_general_ci',
`report_target_type` ENUM('None','EMail','HTTP','HTTP_POST_Encode') NOT NULL DEFAULT 'None' COLLATE 'utf8_general_ci',
`smartlab_name` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`status` ENUM('Completed','InProgress','Incomplete','NotAttended') NOT NULL DEFAULT 'NotAttended' COLLATE 'utf8_general_ci',
`percentage_progress` DOUBLE NOT NULL DEFAULT '0',
`status_evaluation_datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`pass_threshold_in_percent` DOUBLE NOT NULL DEFAULT '0',
`no_of_visits` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`result` ENUM('Passed','Failed','InProgress','NotEvaluated') NOT NULL DEFAULT 'NotEvaluated' COLLATE 'utf8_general_ci',
`total_number_steps` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`pass_threshold` INT(10) UNSIGNED NOT NULL,
`last_access_datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`obtained_score` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`obtained_score_in_percent` DOUBLE NOT NULL DEFAULT '0',
`time_spent` DATETIME NULL DEFAULT NULL,
`weightage` DECIMAL(4,1) NOT NULL DEFAULT '0.0',
`access_expires_on_datetime` DATETIME NULL DEFAULT NULL,
`last_reported_datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=MyISAM;


Please login to leave a reply, or register at first.