Re: 'ORA-01756: quoted string not properly terminated'



On 16 Jun, 16:49, sanjeev.atvan...@xxxxxxxxx wrote:
Hi Gurus,

I have table as follows

create table T1
(
id number,
name varchar2(30)
)

I have written the Code as follows

decalre
emp_rec emp%rowtype;
cursor c1 is select empno,ename from emp;
begin

open c1;
fetch c1 into emp_rec;
while c1%found
loop
insert into T1 (id,name) values(emp_rec.id,emp_rec.name);
end loop;

commit;
end;

I have following data in emp table

empno ename
------------------------------
1 Sanjeev
2 Smith
3 Scott
4 D'Costa

empno 1,2 and 3 are inserted properly.

But when I tried to insert empno 4 it gives me the following error.
'ORA-01756: quoted string not properly terminated'
i.e. when Cursor (emp_rec.name=D'Costa) contains the value as D'Costa.

If it is manually then I can insert as D''Costa but How would i do
this when dynamically.

Thanking in Advance
Sanjeev
sanjeev.atvan...@xxxxxxxxx


Look into using the CHR() function.

HTH

-g

.



Relevant Pages

  • Re: ORA-01756: quoted string not properly terminated
    ... end loop; ... I have following data in emp table ... empno 1,2 and 3 are inserted properly. ...
    (comp.databases.oracle.server)
  • Re: ORA-01756: quoted string not properly terminated
    ... end loop; ... empno 1,2 and 3 are inserted properly. ... i.e. when Cursor contains the value as D'Costa. ... your insert can't work because you reference record fields, ...
    (comp.databases.oracle.server)
  • ORA-01756: quoted string not properly terminated
    ... end loop; ... I have following data in emp table ... empno 1,2 and 3 are inserted properly. ... i.e. when Cursor contains the value as D'Costa. ...
    (comp.databases.oracle.server)
  • cursor for loop
    ... cursor c is select * from emp; ... for emp_rec IN c loop ... Similar to cursor for loop in oracle is there any corresponding for loop in SQL Server ...
    (microsoft.public.sqlserver.programming)
  • Re: Generating SQL
    ... insert into emp (empno, ename) ... application developers have to rewrite any sql statements whenever db ...
    (comp.object)