清單2. 測試過程 TRUNCATE_TABLE
/* create and insert some values into the table tab1 */
CREATE TABLE tab1 (col1 INTEGER NOT NULL PRIMARY KEY, col2 VARCHAR(15) )
DB20000I The SQL command completed successfully.
INSERT INTO tab1 VALUES ( 1, 'some data' ), ( 2, NULL )
DB20000I The SQL command completed successfully.
/* verify the current contents of table tab1 */
SELECT * FROM tab1
COL1 COL2
----------- ---------------
1 some data
2 -
2 record(s) selected.
/* Call the truncate stored procedure for the DB2INST1 schema, and the table tab1 */
CALL truncate('DB2INST1', 'tab1')
Return Status = 0
/* Verify that the table contents have been truncated. */
SELECT * FROM tab1
COL1 COL2
----------- ---------------
0 record(s) selected.
/* Insert some new values into the tab1 table */
INSERT INTO tab1 VALUES ( 2, 'some new data' ), ( 3, NULL )
DB20000I The SQL command completed successfully.
SELECT * FROM tab1
COL1 COL2
----------- ---------------
2 some new data
3 -
2 record(s) selected.
/* Call the truncate procedure with a NULL schema */
CALL truncate(NULL, 'tab1')
Return Status = 0
/* Verify that the table contents have been truncated. */
SELECT * FROM tab1
COL1 COL2
----------- ---------------
0 record(s) selected.
Sybase 的 host_name 函數
Sybase 數據庫中的 host_name( ) 函數返回的是 客戶機進程(非 Adaptive Server 進程)的當前主機名,也就是運行該應用程序的計算機的主機名而非數據庫服務器的主機名。
清單3 中展示了用戶定義函數 HOST_NAME 的簽名。