Sybase ASA中几个非常有用的存储过程
Sybase ASA中几个非常有用的存储过程
以下过程非常实用: www.zzzyk.com
1. Send UDP包到指定地址:
sa_send_udp
CALL sa_send_udp( '10.25.99.196', 2345', 'This is a test' );
2. 获取当前系统中活跃的事务列表:
call sa_transactions( )
3. 有用的tsql 环境设置
CREATE PROCEDURE dbo.sp_tsql_environment()
BEGIN
IF db_property( 'IQStore' ) = 'Off' THEN
-- SQL Anywhere datastore
SET TEMPORARY OPTION close_on_endtrans='OFF';
END IF;
SET TEMPORARY OPTION ansinull='OFF';
SET TEMPORARY OPTION tsql_variables='ON';
SET TEMPORARY OPTION ansi_blanks='ON';
SET TEMPORARY OPTION chained='OFF';
SET TEMPORARY OPTION quoted_identifier='OFF';
SET TEMPORARY OPTION allow_nulls_by_default='OFF';
SET TEMPORARY OPTION on_tsql_error='CONTINUE';
SET TEMPORARY OPTION isolation_level='1';
SET TEMPORARY OPTION date_format='YYYY-MM-DD';
SET TEMPORARY OPTION timestamp_format='YYYY-MM-DD HH:NN:SS.SSS';
SET TEMPORARY OPTION time_format='HH:NN:SS.SSS';
SET TEMPORARY OPTION date_order='MDY';
SET TEMPORARY OPTION escape_character='OFF';
END
4. 执行操作系统命令
xp_cmdshell system procedure
Carries out an operating system command from a procedure.
xp_cmdshell( 'dir > c:\\temp.txt', 'no_output' )
5. 读取写入文件
xp_read_file
xp_write_file
6. 获取某一个表的 DDL语句
sa_get_table_definition system procedure
select row_value from sa_split_list( sa_get_table_definition('DBA', 'ttt'), char(10));
row_value
CREATE TABLE "DBA"."ttt" (
"abc" timestamp NULL
)
;
7. 发送邮件
CALL xp_startsmtp( smtp_sender = 'xxx@163.com', smtp_server='smtp.163.com', smtp_port='25',
timeout=240, smtp_auth_username='iihero', smtp_auth_password='***');
CALL xp_sendmail( recipient='xxxx@gmail.com',
subject='New Pricing');
call xp_stopmail();