CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Español

 MENSAJE DE ERROR CUSTOMIZADO

Print topic Send  topic

Author Message
ROBERTO MEJIA
Posted: 07/29/2006, 10:42 AM

Mi consulta es la siguiente:
Deseo borrar un registro en una tabla PADRE que pueda que tenga dependientes o no, si tiene dependientes que muestre un mensaje de error en el cual le diga al usuario que no puede borrar porque tiene registros HIJOS y así evitar el mensaje de la BD.
Tengo un código en el cual evalúa si el registro de la tabla que deseo borrar, tiene registros dependientes, en el caso de tener dependientes, les mando el código:
/* --------------------------------------------------------- *
NOMBRE : BeforeExecuteDelete
FECHA : JULIO 2006
PROPOSITO : ENVIAR MENSAJE DE ERROR AL TENER REGISTROS DEPENDIENTES
* -------------------------------------------------------- */
String sql="";
String xAlum="";
DbRow row;
JDBCConnection conn = JDBCConnectionFactory.getJDBCConnection("Connection1");
xAlum=String.valueOf(e.getRecord().getControl("CODIGO_ALUMNO").getValue());
// EXTRAE DATOS DE LA TABLA DE NIVEL DEL ALUMNO
sql = "SELECT CODIGO_ALUMNO FROM ALUMNO_NIVEL WHERE TRIM(CODIGO_ALUMNO)='"+xAlum+"'";
row = conn.getOneRow(sql);
conn.closeConnection();
if(row!=null)
{
e.getRecord().addError("NO PUEDE ELIMINAR ESTE REGISTRO, ANTES DEBE BORRAR LOS DEPENDIENTES DE LA TABLA DE NIVEL Y NOTAS");
}
conn.closeConnection();

Lo he puesto en:
BEFORE DELETE(ocurre al comienzo de la operación de borrado),
También lo puse en el BEFORE BUILD DELETE(ocurre después de la operaciones de validación Standard, pero antes de cualquier operación de la BD).
También lo puse en el BEFORE EXECUTE DELETE
En el ONCLICK del botón de borrado (lado del Servidor), me muestra el mensaje que yo le pongo, pero también el mensaje de error de la BD
NO PUEDE ELIMINAR ESTE REGISTRO, ANTES DEBE BORRAR LOS DEPENDIENTES DE LA TABLA DE NIVEL Y NOTAS
[Oracle][ODBC][Ora]ORA-02292: integrity constraint (ADULTOS.FK_ALUMNO_NIVEL_ALUMNO) violated - child record found

La pregunta es: donde pongo el codigo para poder mostrar mi mensaje y no el de la base de datos?

Gracias
lvalverdeb

Posts: 299
Posted: 07/30/2006, 8:59 AM

Prueba modificando tu código a:
  
if(row!=null)  
{  
e.getRecord().addError("NO PUEDE ELIMINAR ESTE REGISTRO, ANTES DEBE BORRAR LOS DEPENDIENTES DE LA TABLA DE NIVEL Y NOTAS");  
e.setSQL("#");  
}  

Luis

_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
ROBERTO MEJIA
Posted: 08/07/2006, 8:20 AM

Me da el siguiente error:
symbol : method setSQL (java.lang.String)
location: class com.codecharge.events.DataObjectEvent
e.setSQL("#");
^
1 error

Al parecer no reconoce este comando, o que es lo que hago mal?

Gracias
matheus

Posts: 386
Posted: 08/09/2006, 4:31 AM

  
e.getCommand().setSql("#");  

_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.