Q:

Single quote not inserting in oracle table/view from magento's custom code

I am trying to insert data in oracle table from magento's custom plugin/code. Below code is working for me but I am not able to insert single quote with values.
<?php
   $headerSql = "INSERT INTO MAGE_ORDER_INTF_HEADERS_DV (HEADER_REC_ID, IMPORT_SOURCE, IMPORT_SOURCE_INSTANCE)VALUES (".$header_rec_id.",'".$is."','".$isi."')";
   $q = $writeResourceOracle->prepare($headerSql);
   if($q->execute()) {
      echo 'success';
   }else{
      echo 'fail';
   }
?>

if I have plain data like john, shan, google it gets into db table but if the data is like mac's or anything which has single quote than oracle through error. Please help me out in this case.

A:

in SQL text which has single quote can not be inserted directly, we have to use one extra quote before any single quote in a text.
like mac's should be represented as mac''s.
so lets prepare variables before putting them into SQL like this
//$value = "mac's";
$value = str_replace("'", "''", $value);

