CREATE PROCEDURE Error
chsword opened this issue · 3 comments
chsword commented
I have a procedure.
When I create it, will throw a error:
CREATE PROCEDURE AddTrade
@buyerId nvarchar(50),
@platform INT,
@mobile varchar(20),
@telephone varchar(20),
@orderId varchar(50),
@fullname nvarchar(20)
AS
BEGIN
if not exists(select 1 from [Account] where id=@buyerId)
begin
INSERT INTO [Account](id) VALUES(@buyerId)
end
if not exists(select 1 from [Mobile] where id=@mobile)
begin
INSERT INTO [Mobile](id) VALUES(@mobile)
end
if @telephone <> @mobile and not exists(select 1 from [Mobile] where id=@telephone)
begin
INSERT INTO [Mobile](id) VALUES(@telephone)
end
if not exists(select 1 from [Trade] where orderId=@orderId)
begin
INSERT INTO [Trade](orderId,[platform],fullname) VALUES(@orderId,@platform,@fullname)
end
INSERT EDGE INTO Account.HasTrade
SELECT a,t FROM Account a , Trade t
WHERE a.id = @buyerId AND t.orderId = @orderId ;
INSERT EDGE INTO Account.UseMobile
SELECT a,t FROM Account a , Mobile t
WHERE a.id = @buyerId AND t.id = @mobile ;
INSERT EDGE INTO Mobile.HasTrade
SELECT a,t FROM Mobile a , Trade t
WHERE a.id = @mobile AND t.orderId = @orderId ;
INSERT EDGE INTO Mobile.HasAccount
SELECT a,t FROM Mobile a , Account t
WHERE a.id = @mobile AND t.id = @buyerId ;
INSERT EDGE INTO Trade.UseAccount
SELECT t,a FROM Account a , Trade t
WHERE a.id = @buyerId AND t.orderId = @orderId ;
INSERT EDGE INTO Trade.UseSecMobile
SELECT t,a FROM Mobile a , Trade t
WHERE a.id = @telephone AND t.orderId = @orderId ;
INSERT EDGE INTO Trade.UseMainMobile
SELECT t,a FROM Mobile a , Trade t
WHERE a.id = @mobile AND t.orderId = @orderId ;
if not (@telephone=@mobile) -- the same as @telephone<>@mobile
begin
INSERT EDGE INTO Account.UseMobile
SELECT a,t FROM Account a , Mobile t
WHERE a.id = @buyerId AND t.id = @telephone ;
INSERT EDGE INTO Mobile.HasTrade
SELECT a,t FROM Mobile a , Trade t
WHERE a.id = @telephone AND t.orderId = @orderId ;
INSERT EDGE INTO Mobile.HasAccount
SELECT a,t FROM Mobile a , Account t
WHERE a.id = @telephone AND t.id = @buyerId ;
end
END"
And the if block diff position in code ,the error is different.
I resolve this by the code:
if (@telephone=@mobile)
begin
return
end
INSERT EDGE INTO Account.UseMobile
SELECT a,t FROM Account a , Mobile t
WHERE a.id = @buyerId AND t.id = @telephone ;
INSERT EDGE INTO Mobile.HasTrade
SELECT a,t FROM Mobile a , Trade t
WHERE a.id = @telephone AND t.orderId = @orderId ;
INSERT EDGE INTO Mobile.HasAccount
SELECT a,t FROM Mobile a , Account t
WHERE a.id = @telephone AND t.id = @buyerId ;
liangjeffchen commented
Hi chsword,
Thanks for posting the issue. Could you please post the exception message(s) you received?
Or even better, is it possible to share your graph schema, by including the CREAET TABLE statements that specify the graph structure? Without this info, we had a little difficulty in identifying the problem.
chsword commented
liangjeffchen commented
Hi chsword, we've identified and fixed the issue. You can find the latest fix in the master branch. thanks for helping us improve.