Error inserting data that has single quotes between them

I have an application that saves clob data to a database. Suppose when I put text in a text box and then click Save. It will call a procedure that will insert this text (clob) into the database table.

Suppose I have the following text:

Hi I'm gaurav soni's

Now my procedure accepts clob data as:

insert into rtf_clob(1,'Hi i am gaurav soni's');

However, this generates an error.

How to process this single quote in dynamic data coming from the front panel?
I am using oracle as an RDBMS.

0
source share
2 answers

, . , , , - .

INSERT, , . SQL- , , . Oracle , , .

, , PL/SQL, . , , -

CREATE PROCEDURE insert_rtf_clob( p_clob IN NOCOPY CLOB )
AS
BEGIN
  INSERT INTO rtf_clob( rtf_clob_id, rtf_clob_value )
    VALUES( seq_rtf_clob_id.nextval, p_clob );
END;

. , Java JDBC, PreparedStatement, setXXX, ..

PreparedStatement stmt = conn.prepareStatement( "INSERT INTO rtf_clob VALUES( ?, ? )" );
stmt.setInt( 1, 1 ); // Set column 1 to a value of 1
stmt.setString( 2, someStringVariable ); // Set column 2 to someStringVariable
stmt.executeUpdate();
+3

':    rtf_clob (1, ', gaurav' soni ''s');

+1

All Articles