FirebirdSQL/最後篇 Firebird 綜合篇/FireBird&SQLServer

出自VFP Wiki

(修訂版本間差異)
跳轉到: 導航, 搜尋
(變數的差異)
第39行: 第39行:
my_variable = 5;
my_variable = 5;
END
END
 +
 +
 +
=== 迴圈使用上的差異 ===
 +
/* This is the original MS SQL statement, using the
 +
* traditional pubs database.*/
 +
CREATE PROCEDURE list_states
 +
AS
 +
SELECT
 +
CASE state
 +
WHEN 'CA' THEN 'California'
 +
WHEN 'UT' THEN 'Utah'
 +
ELSE 'unknown'
 +
END
 +
FROM authors
 +
 +
/* This is how it can be converted to Firebird. */
 +
/* Isolate the CASE statement. */
 +
CREATE PROCEDURE get_state_name (
 +
state_code char(2)
 +
) RETURNS (
 +
state_name varchar(64)
 +
)
 +
AS
 +
BEGIN
 +
IF (state_code = 'CA') THEN
 +
state_name = 'California';
 +
ELSE IF (state_code = 'UT') THEN
 +
state_name = 'Utah';
 +
ELSE
 +
state_name = 'unknown';
 +
END
 +
 +
/* This is the selectable stored procedure. */
 +
CREATE PROCEDURE list_states
 +
RETURNS (state varchar(64))
 +
AS
 +
DECLARE VARIABLE short_state CHAR(2);
 +
BEGIN
 +
FOR
 +
SELECT state
 +
FROM authors
 +
INTO :short_state
 +
DO BEGIN
 +
EXECUTE PROCEDURE get_state_name :short_state
 +
RETURNING_VALUES :state;
 +
SUSPEND;
 +
END
 +
END
 +
===參考文章===
===參考文章===
-----
-----
*[http://vfp.sunyear.com.tw/viewtopic.php?t=1604 Firebird-從SQL Server轉換到FirebirdSQL]
*[http://vfp.sunyear.com.tw/viewtopic.php?t=1604 Firebird-從SQL Server轉換到FirebirdSQL]

在2005年1月26日 (三) 11:35所做的修訂版本

目錄

如何從Microsoft SQL Server轉換到FirebirdSQL


Microsoft SQL Server適用的版本:MS SQL 6.5, MS SQL 7 and MS SQL 2000.

原文來自Marcelo Lopez Ruiz marcelo.lopezruiz@xlnet.com.ar


欄位型態對照表


MSSQL版本 Data Type Firebird MSSQL definition and comments
6.5 bigint INT64 8-byte integer type.


變數使用上的差異


For example, compare the following code snippets. /* This is MS SQL syntax. */ CREATE PROCEDURE my_procedure AS DECLARE @my_variable int SET @my_variable = 5

/* This is FireBird syntax. */ CREATE PROCEDURE my_procedure AS DECLARE VARIABLE my_variable int BEGIN my_variable = 5; END


迴圈使用上的差異

/* This is the original MS SQL statement, using the

  • traditional pubs database.*/

CREATE PROCEDURE list_states AS SELECT CASE state WHEN 'CA' THEN 'California' WHEN 'UT' THEN 'Utah' ELSE 'unknown' END FROM authors

/* This is how it can be converted to Firebird. */ /* Isolate the CASE statement. */ CREATE PROCEDURE get_state_name ( state_code char(2) ) RETURNS ( state_name varchar(64) ) AS BEGIN IF (state_code = 'CA') THEN state_name = 'California'; ELSE IF (state_code = 'UT') THEN state_name = 'Utah'; ELSE state_name = 'unknown'; END

/* This is the selectable stored procedure. */ CREATE PROCEDURE list_states RETURNS (state varchar(64)) AS DECLARE VARIABLE short_state CHAR(2); BEGIN FOR SELECT state FROM authors INTO :short_state DO BEGIN EXECUTE PROCEDURE get_state_name :short_state RETURNING_VALUES :state; SUSPEND; END END


參考文章