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

出自VFP Wiki

(修訂版本間差異)
跳轉到: 導航, 搜尋
(WHILE 條件使用的差異)
(revert)
 
(8個中途的修訂版本沒有顯示)
第1行: 第1行:
-
 
<nowiki>'''[[== 文章未翻譯完成,請等待.. ==]]'''</nowiki>
<nowiki>'''[[== 文章未翻譯完成,請等待.. ==]]'''</nowiki>
第26行: 第25行:
=== 變數使用上的差異 ===
=== 變數使用上的差異 ===
-
-----
+
<pre>
For example, compare the following code snippets.
For example, compare the following code snippets.
/* This is MS SQL syntax. */
/* This is MS SQL syntax. */
第41行: 第40行:
my_variable = 5;
my_variable = 5;
END
END
-
 
+
</pre>
=== 迴圈使用上的差異 ===
=== 迴圈使用上的差異 ===
-
------
+
<pre>
/* This is the original MS SQL statement, using the
/* This is the original MS SQL statement, using the
* traditional pubs database.*/
* traditional pubs database.*/
第90行: 第89行:
END
END
END
END
 +
</pre>
=== WHILE 條件使用的差異 ===
=== WHILE 條件使用的差異 ===
-----
-----
 +
<pre>
/* Firebird syntax. */ 
/* Firebird syntax. */ 
-
WHILE (i < 3) DO BEGIN 
+
WHILE (i < 3) DO BEGIN
-
i = i + 1; 
+
    i = i + 1; 
-
j = j * 2; 
+
    j = j * 2; 
END 
END 
/* MS SQL syntax. */ 
/* MS SQL syntax. */ 
WHILE (i < 3) BEGIN 
WHILE (i < 3) BEGIN 
-
SET @i = @i + 1 
+
    SET @i = @i + 1 
-
SET @j = @j * 2 
+
    SET @j = @j * 2 
END 
END 
 +
</pre>
===參考文章===
===參考文章===
-----
-----
*[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年4月7日 (四) 07:04的最新修訂版本

'''[[== 文章未翻譯完成,請等待.. ==]]'''


目錄

如何從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

WHILE 條件使用的差異


/* Firebird syntax. */ 
WHILE (i < 3) DO BEGIN
    i = i + 1; 
    j = j * 2; 
END 
/* MS SQL syntax. */ 
WHILE (i < 3) BEGIN 
    SET @i = @i + 1 
    SET @j = @j * 2 
END 

參考文章