Click here to Skip to main content
15,902,866 members
Home / Discussions / Database
   

Database

 
GeneralRe: The conversion of the nvarchar value overflowed an int column. Pin
chdboy3-Sep-13 6:13
chdboy3-Sep-13 6:13 
AnswerRe: [solved]The conversion of the nvarchar value overflowed an int column. PinPopular
Bernhard Hiller3-Sep-13 23:28
Bernhard Hiller3-Sep-13 23:28 
GeneralRe: [solved]The conversion of the nvarchar value overflowed an int column. Pin
Eddy Vluggen3-Sep-13 23:52
professionalEddy Vluggen3-Sep-13 23:52 
GeneralRe: [solved]The conversion of the nvarchar value overflowed an int column. Pin
GuyThiebaut4-Sep-13 0:15
professionalGuyThiebaut4-Sep-13 0:15 
GeneralRe: [solved]The conversion of the nvarchar value overflowed an int column. Pin
chdboy4-Sep-13 17:35
chdboy4-Sep-13 17:35 
GeneralRe: [solved]The conversion of the nvarchar value overflowed an int column. Pin
Richard Deeming5-Sep-13 1:25
mveRichard Deeming5-Sep-13 1:25 
GeneralRe: [solved]The conversion of the nvarchar value overflowed an int column. Pin
jschell5-Sep-13 9:34
jschell5-Sep-13 9:34 
QuestionMySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 4:01
Jassim Rahma2-Sep-13 4:01 
Hi,

I am getting the following error on MySQL stored procedure but I can't understand the reason! can any help please..

here is the error followed by full code:

[SQL] 

	IF EXISTS(SELECT visit_id FROM visits WHERE file_no = param_file_no) THEN
	BEGIN
		SET @param_days_since_last_visit = (DATEDIFF(DATE(NOW()), (SELECT DATE(created_date) FROM visits where file_no = param_file_noorder by created_date DESC LIMIT 1)));
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS(SELECT visit_id FROM visits WHERE file_no = param_file_no) THEN
	BEGIN
		SET' at line 1


full code:

SQL
BEGIN
	DECLARE param_item_id_v1 int;
	DECLARE param_item_id_v2 int;
	DECLARE param_file_cutoff_days int;
	DECLARE param_days_since_last_visit int;

	DECLARE param_account_number BIGINT;
	DECLARE param_price_list_id INT;

	DECLARE param_v1_fees DOUBLE(11, 5);
	DECLARE param_v2_fees DOUBLE(11, 5);

	DECLARE param_item_description_v1 VARCHAR(255);
	DECLARE param_item_description_v2 VARCHAR(255);

	SET param_account_number = (SELECT account_number FROM visits WHERE visit_id = param_visit_id);
	SET param_price_list_id = (SELECT price_list_id FROM visits WHERE visit_id = param_visit_id);

	SET param_item_id_v1 = (SELECT item_id FROM price_list_items WHERE item_code = param_v1);
	SET param_item_description_v1 = (SELECT item_name FROM price_list_items WHERE item_id  = param_item_id_v1);
	SET param_v1_fees = (SELECT price_list_item_prices.item_price FROM price_list_item_prices INNER JOIN price_list_items ON price_list_item_prices.item_id = price_list_items.item_id WHERE price_list_items.item_code = param_v1 AND price_list_item_prices.price_list_id = param_price_list_id);

	SET param_item_id_v2 = (SELECT item_id FROM price_list_items WHERE item_code = param_v2);
	SET param_item_description_v2 = (SELECT item_name FROM price_list_items WHERE item_id  = param_item_id_v2);
	SET param_v2_fees = (SELECT price_list_item_prices.item_price FROM price_list_item_prices INNER JOIN price_list_items ON price_list_item_prices.item_id = price_list_items.item_id WHERE price_list_items.item_code = param_v2 AND price_list_item_prices.price_list_id = param_price_list_id);

	SET param_file_cutoff_days = (SELECT system_param_value FROM system_param WHERE system_param_name = 'FILE_CUTOFF_DAYS');

	IF EXISTS(SELECT visit_id FROM visits WHERE file_no = param_file_no) THEN
	BEGIN
		SET param_days_since_last_visit = DATEDIFF(DATE(NOW()), (SELECT DATE(created_date) FROM visits where file_no = param_file_no order by created_date DESC LIMIT 1));
	
		IF (param_days_since_last_visit > param_file_cutoff_days) THEN
		BEGIN
			INSERT INTO visit_items (file_no, visit_id, account_number, item_id, item_code, item_description, item_amount, created_user) VALUES (param_file_no, param_visit_id, param_account_number, param_item_id_v1, param_v1, param_item_description_v1, param_v1_fees, param_created_user);
		END;
		ELSE
		BEGIN
			INSERT INTO visit_items (file_no, visit_id, account_number, item_id, item_code, item_description, item_amount, created_user) VALUES (param_file_no, param_visit_id, param_account_number, param_item_id_v2, param_v2, param_item_description_v2, param_v2_fees, param_created_user);
		END;
		END IF;		
	END;
	ELSE
	BEGIN
		INSERT INTO visit_items (file_no, visit_id, account_number, item_id, item_code, item_description, item_amount, created_user) VALUES (param_file_no, param_visit_id, param_account_number, param_item_id_v1, param_v1, param_item_description_v1, param_v1_fees, param_created_user);
	END;
	END IF;

	UPDATE visits SET is_received = TRUE, recieved_user = param_created_user, recieved_date = NOW() WHERE visit_id = param_visit_id;
END




Thanks,
Jassim[^]


Technology News @ www.JassimRahma.com

AnswerRe: MySQL syntax error.. Please help... Pin
Mycroft Holmes2-Sep-13 12:53
professionalMycroft Holmes2-Sep-13 12:53 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 21:44
Jassim Rahma2-Sep-13 21:44 
AnswerRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 22:04
professionalGuyThiebaut2-Sep-13 22:04 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 22:53
Jassim Rahma2-Sep-13 22:53 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:10
professionalGuyThiebaut2-Sep-13 23:10 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:13
Jassim Rahma2-Sep-13 23:13 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:16
professionalGuyThiebaut2-Sep-13 23:16 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:19
Jassim Rahma2-Sep-13 23:19 
GeneralRe: MySQL syntax error.. Please help... Pin
GuyThiebaut2-Sep-13 23:32
professionalGuyThiebaut2-Sep-13 23:32 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma2-Sep-13 23:56
Jassim Rahma2-Sep-13 23:56 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma3-Sep-13 0:22
Jassim Rahma3-Sep-13 0:22 
GeneralRe: MySQL syntax error.. Please help... Pin
Jassim Rahma3-Sep-13 1:43
Jassim Rahma3-Sep-13 1:43 
QuestionPL/Mysql - can't run procedure with sql security invoker Pin
noislude1-Sep-13 15:59
noislude1-Sep-13 15:59 
QuestionPL/MySQL - can't load file Pin
noislude1-Sep-13 4:22
noislude1-Sep-13 4:22 
QuestionCan't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:15
ThetaClear1-Sep-13 3:15 
AnswerRe: Can't create table - SQL 2008 R2 Pin
PIEBALDconsult1-Sep-13 3:35
mvePIEBALDconsult1-Sep-13 3:35 
GeneralRe: Can't create table - SQL 2008 R2 Pin
ThetaClear1-Sep-13 3:40
ThetaClear1-Sep-13 3:40 

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.