Click here to Skip to main content
15,877,051 members
Home / Discussions / Database
   

Database

 
QuestionDatabase Planning Pin
Sea_Sharp10-Apr-14 6:03
Sea_Sharp10-Apr-14 6:03 
AnswerRe: Database Planning Pin
Eddy Vluggen10-Apr-14 7:17
professionalEddy Vluggen10-Apr-14 7:17 
GeneralRe: Database Planning Pin
Jörgen Andersson10-Apr-14 7:36
professionalJörgen Andersson10-Apr-14 7:36 
GeneralRe: Database Planning Pin
Sea_Sharp10-Apr-14 9:06
Sea_Sharp10-Apr-14 9:06 
AnswerRe: Database Planning Pin
Eddy Vluggen11-Apr-14 9:09
professionalEddy Vluggen11-Apr-14 9:09 
SuggestionRe: Database Planning Pin
Kornfeld Eliyahu Peter10-Apr-14 7:45
professionalKornfeld Eliyahu Peter10-Apr-14 7:45 
AnswerRe: Database Planning Pin
Mycroft Holmes10-Apr-14 13:05
professionalMycroft Holmes10-Apr-14 13:05 
QuestionMySQL Create every Sun for date = xx Pin
Jassim Rahma9-Apr-14 1:46
Jassim Rahma9-Apr-14 1:46 
Hi,

I am using below MySQL stored procedure to add a new job order into MySql table.

I would like to do the following modification in the code:

I want to add an additional parameter called param_max_auto_weekday

then I want to check the WeekDay of the param_job_order_date

and repeat the code until reaching param_max_auto_weekday

so if the WeekDay(param_job_order_date) = Sunday

then It should INSERT INTO job_orders for every Sunday in the week until param_max_auto_weekday

Here is the code... with Thanks:

SQL
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_add_new_job_order`(IN param_customer_id int, IN param_cleaner_id int, IN param_job_order_date date, IN param_job_order_date_to date, IN param_start_time time, IN param_end_time time, IN param_job_order_note text, IN param_is_contract bit, IN param_contract_id int, IN param_total_hours decimal(11, 6), IN param_created_user int, OUT param_record_identity int)
BEGIN
	INSERT INTO job_orders (customer_id, cleaner_id, job_order_date, job_order_date_to, start_time, end_time, job_order_note, is_contract, contract_id, total_hours, created_date, created_user) VALUES (param_customer_id, param_cleaner_id, param_job_order_date, param_job_order_date_to, param_start_time, param_end_time, param_job_order_note, param_is_contract, param_contract_id, param_total_hours, NOW(), param_created_user);
	SET param_record_identity = LAST_INSERT_ID();

	UPDATE customers SET allow_delete = FALSE WHERE customer_id = param_customer_id;

	IF (param_is_contract = TRUE) THEN
	BEGIN
		UPDATE job_orders SET job_order_status = 6 WHERE job_order_id = param_record_identity;
		UPDATE contracts SET remaining_hours = remaining_hours - param_total_hours WHERE contract_id = param_contract_id;
	END;
	END IF;

	-- add event log;
	CALL sp_add_event_log("JOBORDER", param_record_identity, param_created_user, "Job order was created.");
	CALL sp_add_event_log("CUSTOMER", param_customer_id, param_created_user, "Job order was created.");
END



Technology News @ www.JassimRahma.com

AnswerRe: MySQL Create every Sun for date = xx Pin
Eddy Vluggen9-Apr-14 3:00
professionalEddy Vluggen9-Apr-14 3:00 
GeneralRe: MySQL Create every Sun for date = xx Pin
Jassim Rahma10-Apr-14 1:09
Jassim Rahma10-Apr-14 1:09 
AnswerRe: MySQL Create every Sun for date = xx Pin
Mycroft Holmes9-Apr-14 13:01
professionalMycroft Holmes9-Apr-14 13:01 
Questioncan I trust Triggers? Pin
Jassim Rahma9-Apr-14 1:04
Jassim Rahma9-Apr-14 1:04 
AnswerRe: can I trust Triggers? Pin
thatraja9-Apr-14 2:16
professionalthatraja9-Apr-14 2:16 
GeneralRe: can I trust Triggers? Pin
Bernhard Hiller9-Apr-14 22:23
Bernhard Hiller9-Apr-14 22:23 
GeneralRe: can I trust Triggers? Pin
thatraja10-Apr-14 21:06
professionalthatraja10-Apr-14 21:06 
QuestionRe: can I trust Triggers? Pin
Eddy Vluggen9-Apr-14 3:00
professionalEddy Vluggen9-Apr-14 3:00 
AnswerRe: can I trust Triggers? Pin
jschell10-Apr-14 8:53
jschell10-Apr-14 8:53 
GeneralRe: can I trust Triggers? Pin
Jassim Rahma12-Apr-14 1:36
Jassim Rahma12-Apr-14 1:36 
QuestionTrigger on select Pin
Jassim Rahma9-Apr-14 1:00
Jassim Rahma9-Apr-14 1:00 
AnswerRe: Trigger on select Pin
thatraja9-Apr-14 2:13
professionalthatraja9-Apr-14 2:13 
AnswerRe: Trigger on select Pin
Eddy Vluggen9-Apr-14 3:00
professionalEddy Vluggen9-Apr-14 3:00 
QuestionMongoDB to Cache MariaDB? Pin
Marco Bertschi8-Apr-14 20:34
protectorMarco Bertschi8-Apr-14 20:34 
AnswerRe: MongoDB to Cache MariaDB? Pin
Jörgen Andersson8-Apr-14 22:27
professionalJörgen Andersson8-Apr-14 22:27 
GeneralRe: MongoDB to Cache MariaDB? Pin
Marco Bertschi8-Apr-14 22:48
protectorMarco Bertschi8-Apr-14 22:48 
GeneralRe: MongoDB to Cache MariaDB? Pin
Jörgen Andersson8-Apr-14 23:06
professionalJörgen Andersson8-Apr-14 23:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.