Chinaunix首页 | 论坛 | 博客
  • 博客访问: 51772
  • 博文数量: 13
  • 博客积分: 1465
  • 博客等级: 上尉
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 10:15
文章分类

全部博文(13)

文章存档

2011年(2)

2008年(11)

我的朋友

分类: Sybase

2008-11-10 11:33:27

If you know that you are going to be using a text/insert column immediately, insert the row setting the column to a non-null value.

There's a noticeable performance gain.

Unfortunately, text and image datatypes cannot be passed as parameters to stored procedures. The address of the text or image location must be created and returned where it is then manipulated by the calling code. This means that transactions involving both text and image fields and stored procedures are not atomic. However, the datatypes can still be declared as not null in the table definition.

Given this example -

	create table key_n_text
	(
	    key 	int	not null,
	    notes	text	not null
	)

This stored procedure can be used -

	create procedure sp_insert_key_n_text
	    @key	int,
	    @textptr	varbinary(16)	output
	as

	/*
	** Generate a valid text pointer for WRITETEXT by inserting an
	** empty string in the text field.
	*/
	insert key_n_text
	(
	    key,
	    notes
	)
	values
	(
	    @key,
	    ""
	)

	select  @textptr = textptr(notes)
	from    key_n_text
	where   key	 = @key

	return 0
	go

The return parameter is then used by the calling code to update the text field, via the dbwritetext() function if using DB-Library for example.

阅读(912) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~