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

出自VFP Wiki

(修訂版本間差異)
跳轉到: 導航, 搜尋
(revert)
 
(29個中途的修訂版本沒有顯示)
第1行: 第1行:
 +
<nowiki>'''[[== 文章未翻譯完成,請等待.. ==]]'''</nowiki>
 +
 +
=== 如何從Microsoft SQL Server轉換到FirebirdSQL===
=== 如何從Microsoft SQL Server轉換到FirebirdSQL===
 +
-----
Microsoft SQL Server適用的版本:MS SQL 6.5, MS SQL 7 and MS SQL 2000.
Microsoft SQL Server適用的版本:MS SQL 6.5, MS SQL 7 and MS SQL 2000.
-
原文來自Marcelo Lopez Ruiz marcelo.lopezruiz@xlnet.com.ar  
+
原文來自Marcelo Lopez Ruiz marcelo.lopezruiz@xlnet.com.ar
-
 
+
-
===章節、段落,列表及線條===
+
 +
===欄位型態對照表===
 +
-----
{| border="1" cellpadding="2" cellspacing="0"
{| border="1" cellpadding="2" cellspacing="0"
-
變量!!解釋!!結果
 
|-
|-
-
|<nowiki>{{CURRENTMONTH}}</nowiki>||當前月份||{{CURRENTMONTH}}
+
! MSSQL版本
-
 
+
! Data Type
 +
! Firebird
 +
! MSSQL definition and comments
 +
|-
 +
| 6.5
 +
| bigint
 +
| INT64
 +
| 8-byte integer type.
|}
|}
-
==參考文章==
+
=== 變數使用上的差異 ===
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
=== 迴圈使用上的差異 ===
 +
<pre>
 +
/* 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
 +
</pre>
 +
 
 +
=== WHILE 條件使用的差異 ===
 +
-----
 +
<pre>
 +
/* 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 
 +
</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 

參考文章