我想从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的等价物是什么?
更新: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”中收到语法错误。
答案 0 :(得分:4)
显然,Firebird迁移指南是错误的。这种语法对我有用:
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
子句之后