国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

如何將圖片存到數據庫中?

2024-07-21 02:10:53
字體:
來源:轉載
供稿:網友
如果你用的是sql server數據庫!你不想用后臺操作你可以看看這個
下面是對text的操作你可以看看
1. 寫操作(writetext)
這里一般要用到的函數有textptr獲得文本字段的指針,和textvaild檢驗指針的有效性,@@rowcount判斷返回記錄的條數。
其基本方法是:用textptr函數得到指針,判斷其有效性,用writetext寫數據
函數說明:textptr(字段名)。writetext   tablename。fieldname   @textptr(指針) [with log]  data(數據)
例如:
begin tran
declare  @mytextptr   varbinary(16)   
select   @mytextptr=textptr(pr_info)
from  pub_info (updlock)
where  pud_id=’9999’
if  @mytextptr is not null
writetext  pub_info.pr_info   @mytextptr   with log  ‘data’
commit  tran
2. 讀操作
常用函數
patindex(‘%exp%’,var|fieldname。。)
datalength()
@@textsize 文本大小
settextsize  n 設置文本大小
readtext  {tablename。fieldname}  {@textptr}  offet  size   [holdlock]
例如:
begin tran
declare  @mytextptr  varbinary(16),@totalsize   int,@readsize  int,@lastread  int
set textsize 100
select  @mytextptr=textptr(pr_info), @totalsize=datalength(pr_info)
@lastread=0,
@readsize= case  when  (textsize<datalength(pr_info) then  textsize
eles datalength(pr_info)
end
from  pub_info
where  pub_id=’1622’
if  @mytextptr is  not null  and @readsize>0
while (@lastread<@totalsize)
readtext  pub_info.pr_info   @mytextptr   @lastread   @readsize  holdlock
if (@@error<>0)
  break
select @[email protected][email protected]
if ((@[email protected])>@totalsize)
select @[email protected]@lastread
end
commit  tran
3.數據更新updatetext
更新數據代替了寫操作,其基本語法是:
updatetext  table_name.col_name  text_ptr  offest(偏移量)   deleted_length
[with log] [inserted_data|table_name.scr_column_name   str_text_ptr]
說明:
offest:0說明從開頭開始,null表示你向當前內容追加數據。
deleted_length:0表示不刪除任何內容,null表示刪除所有內容。
例如1(完全代替):
declare  @mytextptr varbinary(16)
begin tran
select  @mytextptr=textptr(pr_infro)  from  pub_info(uplock)  where  pub_id=’9999’
if  @mytextptr is not null
updatetext  pub_info.pr_infro  @mytextptr  0  null  with  log  “you are right”
commit
例如2:
declare  @mytextptr  varbinary(16) ,@offest  int
begin  tran
select @mytextptr=textptr(pr_infro),@offest=patindex(‘%d.c%’,pr_infro)-1+4
/*減一是因為有一個矯正的偏移量,加4是因為d.c.是4*/
from  pub_info(unlock)  where  pub_id=’0877’
if  @mytextptr is  not  null  and  @offest>=0
   updatetext  pub_info.pr_infro  @mytextptr  @offest  null  with  log
commit  tran
例如3:
文本追加的問題
將出版商pub_id=9952的內容追加到出版商pub_id=0877d的文本中。
delcare  @source_textptr  varbinary(16),@target_textptr  varbinary(16)
begin  tran
select  @source_textptr=textptr(pr_infro)  from  pub_info(uplock)  where  pub_id=’0877’
select  @target_textptr=textptr(pr_infro)  from  pub_info(uplock)  where  pub_id=’9952’
if  @source_textptr is not null  and  @target  i s  not null
updatetext  pub_info.pr_infro  @target_textptr  null  null  
with  log   pub_info.pr_infro  @source_textptr

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泰和县| 德令哈市| 钟山县| 奈曼旗| 平果县| 安庆市| 唐海县| 博爱县| 化州市| 贵德县| 双辽市| 花垣县| 泰兴市| 海口市| 兴安县| 聊城市| 霞浦县| 香港 | 绥中县| 门头沟区| 邮箱| 江北区| 万年县| 玉环县| 民乐县| 卫辉市| 古蔺县| 普宁市| 朔州市| 密山市| 莱芜市| 西畴县| 永平县| 个旧市| 京山县| 绥化市| 玉林市| 黄平县| 白银市| 衢州市| 蒙阴县|