FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ERROR FWMARIADB, Mr. Rao. URGENTE!
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Tue Aug 11, 2020 08:46 PM
Mr. Rao,
si hago esto :
Code (fw): Select all Collapse
             acTable[1]:= "temp10"              //+ALLTRIM(STR(INT(Seconds()),7))

    ::oServer:Execute( "DROP TABLE IF EXISTS "+acTable[1] )
          
    cQuery:= "CREATE TEMPORARY TABLE "+acTable[1]+" "+;
                     "(id int(11) NOT NULL auto_increment, "+;
                     "fecha date DEFAULT NULL, "+;
                     "comprobante varchar(20), "+;
                     "codcli double(6,0),  "+;
                     "lista double(2,0),   "+;
                     "cantid double(10,3), "+;
                     "kilos double(10,3),  "+;
                     "precio double(12,2), "+;
                     "bonifi double(6,2),  "+;
                     "importe double(12,2), "+;
                     "codven double(4,0), "+;
                     "codart varchar(20), "+;
                     "PRIMARY KEY  (`id`), "+;
                     "UNIQUE KEY `id` (`id`) ) "
    ::oServer:Execute( cQuery )


cuando hago un INSERT no me hace nada y es porque la tabla no existe.

Gracias.
Posts: 42
Joined: Thu Jul 13, 2006 12:20 AM
Re: ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Wed Aug 12, 2020 06:05 PM

Utilizo lo siguiente sin inconvenientes
::oServer:SqlQuery(cQuery )

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Thu Aug 13, 2020 06:23 AM

Please use
::oServer:Execute( "INSERT INTO ....." )

Regards



G. N. Rao.

Hyderabad, India
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Thu Aug 13, 2020 10:47 AM

Mr. RAo,
gracias por responder, pero NO puedo hacer un INSERT porque NO me crea la tabla temporal, ese es el problema que le panteo.
Gracias.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Fri Aug 14, 2020 04:05 PM
Your queries are working successfully when I tested here.
This is the test program. I used FWH Cloud server. You can build this sample on your computer and run it.

Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local acTable[ 1 ], cQuery, oRs, cSql
   local oServer

   SET DATE BRITISH
   SET CENTURY ON

   oServer  := FW_DemoDB( 6 )

   acTable[1]:= "temp10"              //+ALLTRIM(STR(INT(Seconds()),7))

   oServer:Execute( "DROP TABLE IF EXISTS "+acTable[1] )

   cQuery:= "CREATE TEMPORARY TABLE "+acTable[1]+" "+;
             "(id int(11) NOT NULL auto_increment, "+;
             "fecha date DEFAULT NULL, "+;
             "comprobante varchar(20), "+;
             "codcli double(6,0),  "+;
             "lista double(2,0),   "+;
             "cantid double(10,3), "+;
             "kilos double(10,3),  "+;
             "precio double(12,2), "+;
             "bonifi double(6,2),  "+;
             "importe double(12,2), "+;
             "codven double(4,0), "+;
             "codart varchar(20), "+;
             "PRIMARY KEY  (`id`), "+;
             "UNIQUE KEY `id` (`id`) ) "

   oServer:Execute( cQuery )

   cQuery   := "INSERT INTO " + acTable[ 1 ] + ;
               " ( fecha,comprobante,codcli,lista ) VALUES ( " + ;
               "'2000-10-20', 'first record', 65400, 6 )"

   oServer:Execute( cQuery )

   oRs   := oServer:RowSet( "select * from " + acTable[ 1 ] )

   oRs:Edit()
   oRs:Browse()

   oRs:Close()
   oServer:Close()

return nil




Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Fri Aug 14, 2020 04:10 PM
However, we recommend you taking full advantage of FWH Marialib methods.
Please try this sample to achieve the same results, but this approach removes the complexity of writing our own queries.

Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oCn, oRs, cSql, cTable

   SET DATE BRITISH
   SET CENTURY ON

   oCn      := FW_DemoDB( 6 )
   cTable   := "temp10"

   oCn:Execute( "DROP TABLE IF EXISTS " + cTable )
   oCn:CreateTable( "TEMPORARY " + cTable, ;
      {  { "fecha",        "D",  8,    0  } ;
      ,  { "comprobante",  "C", 20,    0  } ;
      ,  { "codcli",       "N",  6,    0  } ;
      ,  { "lista",        "N",  2,    0  } ;
      ,  { "candid",       "N", 10,    3  } ;
      ,  { "kilos",        "N", 10,    3  } ;
      ,  { "precio",       "N", 12,    2  } ;
      ,  { "bonifi",       "N",  6,    2  } ;
      ,  { "importe",      "N", 12,    2  } ;
      ,  { "codven",       "N",  4,    0  } ;
      ,  { "codart",       "C", 20,    0  } ;
      } )

   cSql  := oCn:InsertSQL( cTable, "fecha,comprobante,codcli", ;
                  { Date(), "First Record", 65400, 6 } ) // Array with Harbour variables/constants
   oCn:Execute( cSql )

   oRs   := oCn:RowSet( "select * from " + cTable )

   oRs:Edit()
   oRs:Browse()

   oRs:Close()
   oCn:Close()

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: ERROR FWMARIADB, Mr. Rao. URGENTE!
Posted: Sun Aug 16, 2020 11:50 AM

Mr. Rao,

muchas gracias, funcionó perfecto.

Saludos

Continue the discussion