在ORACLE中,怎么在字段中保存图片~~~~~急~~~送分50

lingaiguo 2003-10-09 05:25:29
在ORACLE中,怎么在字段中保存图片~~~~~急~~~送分50
数据库中有一个字段,必须保存为图片,加急~~~
还有就是在保存的字段中,把图片取出来,谢谢
谢谢
谢谢
送分~~~
...全文
566 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
boy002 2003-10-11
  • 打赏
  • 举报
回复
关注
lingaiguo 2003-10-11
  • 打赏
  • 举报
回复
在JAVA中怎么写呀?
chanet 2003-10-09
  • 打赏
  • 举报
回复
在delphi中的处理
对于lob字段而言,个人认为其使用比long类型有很大的灵活性,而且lob字段可以保存各类的数据,可以保存图片,大量的文字,现就clob跟blob两种类型加以说明,其中blob保存图片信息,clob保存大量文字。
exmple 6.
Create table test_table
(c_no number(1) not null,
c_blob blob,
c_clob clob,
constraint pk_test_table primary key (c_no));

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, Grids, DBGrids, DB, DBTables, ExtDlgs;

type
TForm1 = class(TForm)
Database1: TDatabase; //用于连接数据库
Table1: TTable; //获取表信息
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBMemo1: TDBMemo; //显示c_clob字段内容
DBImage1: TDBImage; //显示c_blob字段内容
Button1: TButton; //插入按钮
Button2: TButton; //保存按钮
Table1C_NO: TFloatField; //Tfiled
Table1C_BLOB: TBlobField;
Table1C_CLOB: TMemoField;
OpenPictureDialog1: TOpenPictureDialog; //从文件获取图片
OpenDialog1: TOpenDialog; //从文件获取文字
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin //插入操作
with Table1 do
begin
Insert; //将表状态置为插入状态
if OpenPictureDialog1.Execute then //获得图片信息
Table1C_BLOB.LoadFromFile(OpenPictureDialog1.FileName);
if OpenDialog1.Execute then //获得文字信息
Table1C_CLOB.LoadFromFile(OpenDialog1.FileName);
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin //提交插入内容
try
Table1.Post;
except
Application.MessageBox('错误发生','警告',0);
end;
end;

end.
lingaiguo 2003-10-09
  • 打赏
  • 举报
回复
一定要存图片到字段中,
上面的代码可以写一个注释吗?
上面的是ORACLE代码吗?
最好是用JAVA代码存取图片~~~
谢谢
LGQDUCKY 2003-10-09
  • 打赏
  • 举报
回复
这里有一个以前人家做的例子:
//--------------ORACLE 保存图片
grant create any directory to scott;
grant create any library to scott;
create or replace directory utllobdir as 'd:\oracle';
create table bfile_tab (bfile_column BFILE);
create table utl_lob_test (blob_column BLOB);

set serveroutput on

然后执行下面语句就将d:\oracle目录下的a.jpg存入到utl_lob_test
表中的blob_column字段中了。
declare
a_blob BLOB;
a_bfile BFILE := BFILENAME('UTLLOBDIR','A.jpg');
begin
insert into bfile_tab values (a_bfile)
returning bfile_column into a_bfile;
insert into utl_lob_test values (empty_blob())
returning blob_column into a_blob;
dbms_lob.fileopen(a_bfile);
dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
dbms_lob.fileclose(a_bfile);
commit;
end;
/
LGQDUCKY 2003-10-09
  • 打赏
  • 举报
回复
保存图片的路径不是一个方法吗?
你一定要存二进制的DD吗?

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧