如何查看 Oracle 中的 Clob 字段内容

Oracle 中的 Clob 字段可用来存储 N长 的字符串等内容(如 HTML文件 等),而若要在程序中正常显示其字段内容则需用上 to_char 函数――如否,则其内容很可能会被截取...
示例代码:

uses
  ShellAPI;

var
  FileTmp: string;
  sl: TStrings;
begin
  FileTmp:= '';
  with aqy_QryTmp do //aqy_QryTmp: TADOQuery;
  begin
    Screen.Cursor:= crHourGlass;
    try
      Close;
      SQL.Text:=
        'select to_char(Content) from Tab_Demo '
        'where ID=' + edt_ID.Text; //Content 即为 Clob 类型
      Open;
      if RecordCount > 0 then
      begin
        FileTmp:= 'FileTmp.htm'; //Set FILENAME here...

        sl:= TStringList.Create;
        with sl do
        try          
          Add(Fields[0].AsString);
          SaveToFile(ExtractFilePath(ParamStr(0)) + 'Tmp\' + FileTmp);
        finally
          FreeAndNil(sl);
        end;        
      end;      
    finally
      Close;
      Screen.Cursor:= crDefault;
    end;

    ShellExecute(
                        Handle,
                        'Open',
                        PChar(ExtractFilePath(ParamStr(0)) + 'Tmp\'+ FileTmp),
                        nil,
                        nil,
                        SW_SHOW
                      ) <= 32 then
    begin
      MessageBox(0, '打开文件失败! ', '错误', MB_OK + MB_ICONERROR);
    end;
  end;

end;

OK,Done![

你可能感兴趣的:(oracle,职场,休闲)