Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

CREATE PROCEDURE Error #7

Open
chsword opened this issue Mar 30, 2016 · 3 comments
Open

CREATE PROCEDURE Error #7

chsword opened this issue Mar 30, 2016 · 3 comments

Comments

@chsword
Copy link

chsword commented Mar 30, 2016

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
Copy link
Contributor

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
Copy link
Author

chsword commented Mar 31, 2016

文件 error case.cs 是发生错误的用例
pass case.cs 是可以通过的用例

错误提示会提示 “x表不存在y EDGE”,实际上也真实不存在

case.zip

@liangjeffchen
Copy link
Contributor

Hi chsword, we've identified and fixed the issue. You can find the latest fix in the master branch. thanks for helping us improve.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants