Creación de tablas MYSQL

Creación de tablas MYSQL

Postby Laurel » Thu Jul 02, 2009 12:55 am

Hola a todos!!
Estoy tratando de crear una tabla por programa con el siguiente código

Code: Select all  Expand view

oComando:= "DROP TABLE IF EXISTS `mitabla` "

oComando2:=     "CREATE TABLE  `pruebas`.`mitabla` (       "+;
          "`EM_CODICIA` float default '0' COMMENT 'CLAVE DE LA EMPRESA',"+;
          "`MP_CODPROC` float default '0' COMMENT 'CODIGO DE PROCESO',  "+;
          "`MT_CODTRAB` float default '0' COMMENT 'CODIGO DE COLABORADOR',"+;
          "`CC_CODCONC` float default '0' COMMENT 'CODIGO DE CONCEPTO', "+;
          "`CL_PERIODO` float NOT NULL default '0' COMMENT 'PERIODO',   "+;
          "`CL_CLAVREG` float default '0' COMMENT 'CLAVE DE REGISTRO',  "+;
          "`CL_CTACARG` char(6) default '' COMMENT 'CUENTA DE CARGO',   "+;
          "`CL_UNIDADE` float(8,2) default '0.00' COMMENT 'UNIDADES DEL CONCEPTO', "+;
          "`CL_IMPORTE` float(16,2) default '0.00' COMMENT 'IMPORTE', "+;
          "`CL_METCALC` float default '0' COMMENT 'METODO DE CALCULO',"+;
          "`CL_TURNOTR` float default '0' COMMENT 'TURNO DEL COLABORADOR', "+;
          "`CL_NOM_LGO` char(48) default '' COMMENT 'NOMBRE DEL COLABORADOR', "+;
          "`CL_SWPROEX` char(2) default '' COMMENT 'SWITCH DE PROCESO DE EXCEPCION',"+;
          "`CL_FORPAGO` char(1) default '' COMMENT 'FORMA DE PAGO',"+;
          "`CL_FECHMOV` date default '0000-00-00' COMMENT 'FECHA DE MOVIMIENTO', "+;
          "`CL_SECUENC` float default '0' COMMENT 'SECUENCIA', "+;
          "`CL_TIPOCON` float default '0' COMMENT 'TIPO DE CONCEPTO', "+;
          "`DD_DIVDPTO` float default '0' COMMENT 'CLAVE DEL DEPARTAMENTO', "+;
          "`CL_LLAVE` float NOT NULL auto_increment COMMENT 'LLAVE',"+;
          "PRIMARY KEY  (`CL_LLAVE`),"+;
          "UNIQUE KEY `CL_LLAVE` (`CL_LLAVE`)"+;
          ")       ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1 COMMENT='AGRUPACION DE CONCEPTOS';"
   

      TRY
        oApp := oComando:Execute()
        CATCH oErr
        MsgInfo("No se puede borrar la tabla", oErr:Description )
      END TRY

      TRY
        oApp := oComando2:Execute()
        CATCH oErr
        MsgInfo("No se puede crear la tabla", oErr:Description )
      END TRY
 


Y en ambos casos me manda el siguiente error:

Class: 'CHARACTER' has not exported method

¿Alquien puede ayudarme?

Mil gracias de antemano

Laurel.
Code: Select all  Expand view
 
Laurel
Laurel
 
Posts: 65
Joined: Fri Oct 21, 2005 8:07 pm
Location: México

Re: Creación de tablas MYSQL

Postby Armando » Thu Jul 02, 2009 2:09 am

Laurel:

Dále una mirada a mi blog, si es que aún no lo haz hecho, ahí tienes muchos ejemplos de lo que necesitas.

http://sqlcmd.blogspot.com/

Saludos
Last edited by Armando on Thu Jul 02, 2009 11:30 am, edited 1 time in total.
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Creación de tablas MYSQL

Postby wmormar » Thu Jul 02, 2009 3:00 am

Laurel,

Homogeniza primero que nada si usas (') apostrofos o los acentos para encerrar cadenas, en mi caso uso los apostrofos.

Después de eso ejecuta y veras cambios.


Hay servidores que no permiten los acentos y forzosamente deberas usar apostrofos o comillas.
William, Morales
Saludos

méxico.sureste
User avatar
wmormar
 
Posts: 1073
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Re: Creación de tablas MYSQL

Postby carlos vargas » Thu Jul 02, 2009 5:05 pm

Me parece que tienes errores:
1-tanto oComando y oComando2 son variables que contiene una cadena caracter.
2-por tanto te fallara la expresion siguiente:
TRY
oApp := oComando:Execute()
CATCH oErr
MsgInfo("No se puede borrar la tabla", oErr:Description )
END TRY
por que oComando no es un variable que contenga un objeto ADO y es por ello el error
diferete fuera que hicieras por ejemplo:

cSQL := " DROP TABLE IF EXISTS 'mitabla' "
oADO := CreateObjet("....aca define el objeto ado....") //oAdo contrendra un objeto ado
TRY
oObj := oAdo:Execute( cSQL )
CATCH oErr
MsgInfo("No se puede borrar la tabla", oErr:Description )
END TRY

creo que te puden ayudar las indicaciones en el blog que te indican anteriormente.
tambien hace poco The Full dejo el codigo de una clase que te pude ser util.

salu2
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Creación de tablas MYSQL

Postby Laurel » Thu Jul 02, 2009 7:23 pm

Hola de nuevo!!
Gracias por sus comentarios que me ayudaron a solucionarlo me faltaba indicarle al objeto que le estaba enviando un texto... quedo asi:

oComando:CommandText:= "DROP TABLE IF EXISTS `MITABLA` "

TRY
oApp := oComando:Execute()
CATCH oErr
MsgInfo("No se puede borrar",oErr:Description )
END TRY


Y lo mismo hice para crear la tabla y funcionó perfecto!!

Saludos
Laurel :D
Laurel
Laurel
 
Posts: 65
Joined: Fri Oct 21, 2005 8:07 pm
Location: México


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests