MySQL Forums
Forum List  »  MySQL Workbench

Syntax problems with mysql
Posted by: Doug Barger
Date: April 07, 2020 10:51AM

What is wrong with this mysql stored procedure.
1. declare - Error(declare in not at this position for this server)
2. both if statements - error(if is not valid at this position)

create procedure autowise.AdjustMapping (IN
Rid bigint,
in pkId bigint
)
begin

declare @unmappedname varchar(50) default '';

if pkid = 0 then

update autowise.custommap set (dbaseto='',table_nameto='',field_nameto='',full_nameto='',noreferance=1) where ident = @rid;

delete from autowise.custommap where parentident=rid;

end if;

if pkid > 0 then

select @unmappedname = (select field_namefrom from autowise.custommap where ident=rid)
update autowise.custommap a,
(select dbase,table_name,Field_name from xmltemplate where ident = pkid ) b
set a.dbaseto = b.dbase,a.table_nameto = b.table_name,a.field_nameto = b.field_name,
noreferance=0,a.Full_nameto = b.full_name
where rid=a.ident;

insert into autowise.custommap (dbasefrom,table_namefrom,field_namefrom,full_nameFrom,Full_nameto,
dbaseto,table_nameto,field_nameto,noreferance,donotuse,parentident)
select 'map',@unmappedname,field_name,concat('map.',@unmappedfieldname,'.',field_name),b.full_name,
b.dbase,b.table_name,b.field_name,0,0,rid
from autowise.xmltemplate a inner join autowise.xmltemplate b on
a.table_name=b.table_name and a.dbase=b.dbase where a.ident =pkid and b.field_name <> b.keyfield;

end if;

end

Options: ReplyQuote


Subject
Views
Written By
Posted
Syntax problems with mysql
214
April 07, 2020 10:51AM
80
April 07, 2020 10:55AM
71
April 07, 2020 11:28AM
69
April 07, 2020 02:34PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.