简体   繁体   中英

When i try to insert into the table which blob data type I am getting an error

Create TABLE long_claw
(
    "name" varchar2(10),
    phno number(10),
    clg_docs blob
)
partition by hash(phno);

insert into pepe.long_claw("name",phno,clg_docs)
values('Satyajit',9176788770,to_lob('ceb'));

When I tried to execute the insert statement I got the following error:

Error starting at line : 9 in command -

 insert into pepe.long_claw("name",phno,clg_docs) values('Satyajit',9176788770,to_lob('ceb')) 

Error at Command Line : 10 Column : 30

Error report -

SQL Error: ORA-00932: inconsistent datatypes: expected - got CHAR 00932. 00000 - "inconsistent datatypes: expected %s got %s"

*Cause:

*Action:

I need some help here.

TO_LOB converts LONG or LONG RAW values to LOB values. So you cannot directly use a string to convert it to LOB . Instead use hextoraw() OR utl_raw.cast_to_raw()

INSERT INTO long_claw("name",phno,clg_docs)
VALUES('Satyajit',9176788770,hextoraw('ceb'));


INSERT  INTO  long_claw("name",phno,clg_docs)
VALUES('Satyajit',9176788770,utl_raw.cast_to_raw('ceb'));

you need create procedure

create or replace procedure proc_name(na in varchar2, ph in number, clg_doc in blob)
begin 
inser into pepe.long_claw("name",phno,clg_docs) values 
(na, ph, clg_doc);
end;

and call it procedure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM