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

CREATE PROCEDURE Error #7

Open
Open

Description

@chsword

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 ;

Activity

  1. liangjeffchen commented on Mar 31, 2016

    @liangjeffchen
    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.

  2. chsword commented on Mar 31, 2016

    @chsword
    Author

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

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

    case.zip

  3. liangjeffchen commented on Apr 7, 2016

    @liangjeffchen
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions