UNIDAD 7: INTRODUCION A LAS BASES DE DATOS

TEMA LINUX GCC 12: BAJA O ELIMINACION

Eliminación es otro proceso simple y comun con las bases de datos el modelo MYSQL que estamos usando hace este tipo de operaciones muy faciles:

La instrucción sql a usar es: DELETE FROM TABLA WHERE CONDICION

Prog42.html


<HTML>

<FORM ACTION=http://192.168.1.251/~tusitio/cgi-bin/prog42.cgi METHOD=POST>

CLAVE A ELIMINAR :<INPUT TYPE=text NAME=CLAVE><BR>

<INPUT TYPE=submit VALUE=ELIMINAR>

</FORM></HTML>

corrida prog42.html

image129.jpg

prog42.cpp


#include <stdio.h>

#include <stdlib.h>

#include <string>

#include <iostream>

#include <lcnet.h>

#include <mysql.h>

using namespace std;

int main()

{

// crando variables globales

MYSQL coneccion;

// construyendo pagina

cout << "Content-type: text/html\n\n";

cout << "<html>" << endl;

// inicializando y conectando

if ( mysql_init(&coneccion) == NULL)

cout << "error inicializando" << endl;

if ( mysql_real_connect(&coneccion,"localhost","USUARIO","PASSWORD","mibase",0,NULL,0) == NULL )

cout << "error conectando" <<endl;

// construyendo delete query

char q[200];

strcpy(q,"delete from mitabla where clave = ") ;

// observar ahora se captura y convierte directamente

strcat(q,getstring("CLAVE").c_str() );

if ( mysql_query(&coneccion,q) !=0)

{cout << "error en insert " <<endl;

} else cout << "registro eliminado " << endl;

mysql_close(&coneccion);

cout << "</html>" << endl;

exit(0);

}

Corra prog42.cgi

image130.jpg

bye, bye pobre elefantito y si no creen usen prog37.cgi para ver la tabla

TAREAS PROGRAMACION LINUX GCC PROGRAMACION LINUX GCC :

1.- construir este proceso para las tablas y bases de datos que tengan construidas.

 




Google
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Politica de Privacidad