代码之家  ›  专栏  ›  技术社区  ›  dthrasher

在Firebird存储过程中选择标量值

  •  0
  • dthrasher  · 技术社区  · 14 年前

    我想从Firebird 2.1存储过程中获取特定行的ID。我好像不记得语法了,这让我发疯了。

    这就是Microsoft SQL Server使用的TSQL中代码的外观。

        @ID = SELECT ID FROM ADDRESS WHERE 
          POBox = :POBOX AND
          ExtendedAddress = :EXTENDEDADDRESS AND
          StreetAddress = :STREETADDRESS AND
          Locality = :LOCALITY AND
          Region = :REGION AND
          PostalCode = :POSTALCODE AND
          CountryName = :COUNTRYNAME;
    

    火鸟相当于什么?

    更新 : Firebird SQL migration guide 建议这应该有效

        SELECT ID INTO :ID FROM ADDRESS WHERE 
          POBox = :POBOX AND
          ExtendedAddress = :EXTENDEDADDRESS AND
          StreetAddress = :STREETADDRESS AND
          Locality = :LOCALITY AND
          Region = :REGION AND
          PostalCode = :POSTALCODE AND
          CountryName = :COUNTRYNAME;
    

    但是,当我尝试创建存储过程时,“into”处会出现语法错误。

    1 回复  |  直到 14 年前
        1
  •  4
  •   dthrasher    14 年前

    显然,火鸟迁徙指南是错误的。这种语法对我很有用:

    SELECT ID FROM ADDRESS WHERE 
       POBox = :POBOX AND
       ExtendedAddress = :EXTENDEDADDRESS AND
       StreetAddress = :STREETADDRESS AND
       Locality = :LOCALITY AND
       Region = :REGION AND
       PostalCode = :POSTALCODE AND
       CountryName = :COUNTRYNAME
    INTO :ID;
    

    请注意 INTO 条款必须来 之后 这个 FROM WHERE 条款。