In PHP I use this code with a prepared statement to insert null in the field 
justif_emenda when
the value in the form is an empty string or a string with only spaces. I hope 
this will help you.

$sql = "INSERT INTO tbl_emenda ("
     . "id_emenda, subtipo_emenda, tipo_emenda, "
     . "nome_autor, titulo_autor, login_autor, "
     . "cod_acao_gov, nome_acao_gov, "
     . "texto_emenda, justif_emenda) "
     . "VALUES(?,?,?,?,?,?,?,?,?,nullif(trim(' ' from ?),''))";
$stmt = $conn->Prepare($sql);
if (!$conn->Execute($stmt, array(
      $id_emenda,
      'S',
      'Aditiva',
      $_SESSION['nome_autor'],
      $_SESSION['titulo_autor'],
      $_SESSION['login_autor'],
      $_REQUEST['selCodAcaoGov'],
      $_REQUEST['txtNomeAcaoGov'],
      $_REQUEST['txtTexto'],
      $_REQUEST['txtJustif']
   ))) {
   erroSQL($conn, $sql);
   die("Erro..");
}



        
        
                
_______________________________________________________ 
Yahoo! Acesso Grátis - Internet rápida e grátis. 
Instale o discador agora! http://br.acesso.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to