# MICRO= nombre de la base de datos.
sub conectar_DB
{
$MICRO=Nuevo GestorDatos('MICRO','username','password');
$MICRO->{Diario}=$diario;
$MICRO->{Simular}=$SIMULAR;
$MICRO->Conectar;
}
sub desconectar_DB
{
$MICRO->Desconectar;
$diario->Cerrar;
}
sub insertar_hibrid
{
print qq~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> HYBRIDIZATION </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="standard.css">
</HEAD>
<BODY>
<CENTER>
~;
$date_finish = param(DATE_FINISH);
$slide = param(SLIDE);
$array_type = param(ARRAY_TYPE);
$array_batch = param(ARRAY_BATCH);
$extract = param(EXTRACT);
$samples = param(SAMPLES);
$data_owner = param(DATA_OWNER);
$notebook_hibrid = param(NOTEBOOK_HIBRID);
$notebook_scanner = param(NOTEBOOK_SCANNER);
$protocol = param(PROTOCOL);
# parametros no obligatorios vacios => insertaremos NULL en la base de datos
if (defined(param(OBSERVATIONS))) { $observations = param(OBSERVATIONS); } else {$observations = '\'\''}
my $username=param(USERNAME);
my $password=param(PASSWORD);
my @ID_USER=$MICRO->Consultar("SELECT T.ID_USER FROM MICRO.TBL_USER T WHERE T.USERNAME = \'$username\' AND T.PASSWORD = \'$password\'");
my $id_user=$ID_USER[0];
if (defined $id_user)
{
my @ID_HIBRIDACION=$MICRO->Consultar("SELECT MAX(H.ID_HIBRIDACION) FROM MICRO.TBL_HIBRIDACION H");
$id_hibridacion=$ID_HIBRIDACION[0] + 1;
if (defined $id_hibridacion)
{
if ($MICRO->Ejecutar(\$id,"INSERT INTO MICRO.TBL_HIBRIDACION (ID_HIBRIDACION,ID_USER,DATE_FINISH,SLIDE,ARRAY_TYPE,ARRAY_BATCH,EXTRACT,SAMPLES,DATA_OWNER,NOTEBOOK_HIBRID,NOTEBOOK_SCANNER,ID_PROTOCOL,OBSERVATIONS) VALUES (?,?,TO_DATE(\'$date_finish\',\'DD/MM/YYYY\'),?,?, TO_DATE(\'$array_batch\',\'DD/MM/YYYY\'),?,?,?,?,?,?,?)",$id_hibridacion,$id_user,$slide,$array_type,$extract,$samples,$data_owner,$notebook_hibrid,$notebook_scanner,$protocol,$observations))
{
if ($MICRO->LeerCursor("SELECT U.ID_USER FROM MICRO.TBL_USER U WHERE (U.ID_USER < 100 AND U.ID_USER > 2) OR U.ID_USER = 0",'main::permitir_lectura'))
{
print "<BR><h2>Adding lab-users privileges.</h2>";
}
print "<BR><h1>Data Inserted Correctly.</h1>";
}
else
{
print "<BR><h2>Error: impossible to insert data, wrong data.</h2>";
}
}
else
{
print "<BR><h2>Error: the insertion could not have been prepared. id_hibridacion:[$id_hibridacion]</h2>";
}
}
else
{
print "<BR><h2>Error: user or password incorrect.</h2>";
}
}
############ MAIN ############
&conectar_DB;
if (defined (param())) #tenemos datos a tratar y mostrar
{
&inicializaciones;
&insertar_hibrid;
}
else #Formulario inicial, pedimos los datos
{
&inicializaciones;
&form_insertar;
}
&desconectar_DB;
exit(1);