Class to manager MYSQL for Harbour/xHarbour
Custom Search

lunes, 5 de julio de 2010

Incluir a la Tabla / Insert table

Para añadir registrios a nuestras tablas usamos la sentecia INSERT INTO
To add rows inside tables we use  INSERT INTO

En Dolphin se puede usar un string con la sentecia INSERT o usar el METHOD Insert de la clase TDolphinSrv

cQuery = "INSERT INTO student VALUES ('Megan','F',NULL),('Joseph','M',NULL),"+;
                 "('Kyle','M',NULL),('Katie','F',NULL),('Abby','F',NULL),('Nathan','M',NULL),"+;
                 "('Liesl','F',NULL),('Ian','M',NULL),('Colin','M',NULL),('Peter','M',NULL),"+;
                 "('Michael','M',NULL),('Thomas','M',NULL),('Devri','F',NULL),('Ben','M',NULL),"+;
                 "('Aubrey','F',NULL),('Rebecca','F',NULL),('Will','M',NULL),('Max','M',NULL),"+;
                 "('Rianne','F',NULL),('Avery','F',NULL),('Lauren','F',NULL),('Becca','F',NULL),"+;
                 "('Gregory','M',NULL),('Sarah','F',NULL),('Robbie','M',NULL),('Keaton','M',NULL),"+;
                 "('Carter','M',NULL),('Teddy','M',NULL),('Gabrielle','F',NULL),('Grace','F',NULL),"+;
                 "('Emily','F',NULL)"

oServer:Execute( cQuery )

Se puede leer la informacion de un archivo usando la funcion D_ReadFile( filename )
we can read query from file using function  D_ReadFile( filename )
cQuery =  D_ReadFile( "insert_member.txt" )
oServer:Execute( cQuery )

METHOD Insert( cTable, aColumns, aValues )
cTable Table name
aColumns Array with field names
aValues Array with values, should contain same total item like aColumns array

No preocuparse pro el formato de la data, Dolphin la convierte automaticamente en formato valido de Mysql
we dont worried about value format, Dolphin convert automatically all data to MySql format
   cTable = "grade_event"

   aColumns = { "date", "category", "event_id" } // 3 items
   aValues = { CToD( '09-03-2008' ), 'Q', NIL }  // 3 values
   oServer:Insert( cTable, aColumns, aValues )

===================================
sample
Download here

screen shoot

No hay comentarios:

Publicar un comentario