Page 1 of 1

STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Thu Feb 03, 2022 2:52 pm
by Willi Quintana
Mr. Rao

oProd := oCn:Call( "proc001" ) // does not work in remote server, only in local mode
///-----------
oProd := oCn:Execute( "CALL proc001" ) // works, but the dates of the returns in array

I´m use MariaDb and Harbour
Thanks

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Wed Feb 09, 2022 3:22 am
by Willi Quintana
Any Idea???

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Sun Feb 13, 2022 9:12 am
by nageswaragunupudi
Please see my response in your other thread.

Even for normal queries like "SELECT ..."
oCn:RowSet(..) or oCn:Query(...) returns a RowSet object

oCn:Execute( query ) returns an array of the same data
if you immediately follow with another call oCn:Execute() without parameters, it returns the structure of the previous query as an array

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Sun Feb 13, 2022 4:13 pm
by nageswaragunupudi
Please let me know your FWH version.
Is the cloud server MySql or MariaDB?

Please help me to find a soluton.

Please run this code and let me know the results:
Code: Select all  Expand view

oCn := maria_Connect( ......... )
oCn:lShowErrors := .t.

? oCn:cServerInfo
? oCn:OS
? oCn:IsProcedure( "proc001" )
xbrowser oCn:ListProcedures()

oProd := oCn:Call( "proc001" )
oProd := oCn:CallSP( "proc001" )
aProd := oCn:Execute( "CALL proc001" )
aProd := oCn:Execute( "CALL proc001()" )
 

Please let me know the results.
If you get any errors, let me know the errors.

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Sun Feb 13, 2022 4:13 pm
by nageswaragunupudi
Please let me know your FWH version.
Is the cloud server MySql or MariaDB?

Please help me to find a soluton.

Please run this code and let me know the results:
Code: Select all  Expand view

oCn := maria_Connect( ......... )
oCn:lShowErrors := .t.

? oCn:cServerInfo
? oCn:OS
? oCn:IsProcedure( "proc001" )
xbrowser oCn:ListProcedures()

oProd := oCn:Call( "proc001" )
oProd := oCn:CallSP( "proc001" )
aProd := oCn:Execute( "CALL proc001" )
aProd := oCn:Execute( "CALL proc001()" )
 

Please let me know the results.
If you get any errors, let me know the errors.

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Mon Feb 14, 2022 1:40 am
by Willi Quintana
Mr Rao, heloo.. Is Ok in local mode

Code: Select all  Expand view

? oCn:cServerInfo                            5.5.5.-10.5.6. MariaDb
? oCn:OS                                         Win64
? oCn:IsProcedure( "proc001" )        .t.
xbrowser oCn:ListProcedures()       ok

oProd := oCn:Call( "proc001" )
?, VALTYPE(oProd)                        0
? oProd:producto                          PRUEBA DE DATOS

oProd := oCn:CallSP( "proc001" )
? VALTYPE(oProd)                        0
? oProd:producto                        PRUEBA DE DATOS

aProd := oCn:Execute( "CALL proc001" )
? VALTYPE(oProd)                        0
? oProd:producto                        PRUEBA DE DATOS

aProd := oCn:Execute( "CALL proc001()" )
? VALTYPE(oProd)                        O
? oProd:producto                        PRUEBA DE DATOS

*******************************************************

Function CargaStoreProc(oCn)
local cProc, oDatos

cProc  := "SELECT specific_name FROM information_schema.routines WHERE specific_name = 'proc001'"
oDatos := oCn:Query(cProc)

? oDatos:RecCount()

If oDatos:RecCount() = 0                 // no existe el procedure  y lo creamos

  cProc := "CREATE PROCEDURE inversiones2bhs.proc001() "
  cProc += "SELECT productos.cod_producto, productos.producto, productos.precio_venta1, productos.unidad, productos.saldo, productos.cod_proveedor, productos.cod_marca, productos.cod_grupo, productos.codbar1,
                            productos.codbar2, productos.observaciones, proveedor.razon_social, marca.detalle AS marca, grupo.detalle AS grupo "

  cProc += "FROM productos "
  cProc += "LEFT JOIN proveedor ON productos.cod_proveedor = proveedor.ruc_dni "
  cProc += "LEFT JOIN marca ON productos.cod_marca = marca.codigo "
  cProc += "LEFT JOIN grupo ON productos.cod_grupo = grupo.codigo "
  cProc += "ORDER BY productos.producto"

  oCn:Execute(cProc)
  if oCn:nError != 0    //     //     //
    Return(.f.)
  EndIf

Endif

Return(.t.)
 

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Mon Feb 14, 2022 2:10 am
by nageswaragunupudi
Please run the same queries on cloud server.
Is the user database name on cloud server also is `inversiones2bhs` ?

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Mon Feb 14, 2022 2:33 am
by nageswaragunupudi
Recommended:
Code: Select all  Expand view

function CargaStoreProc( oCn )

   local cSql
   local lRet  := .t.
   
   if !oCn:IsProcedure( "proc001" )
     
TEXT INTO cSql
CREATE PROCEDURE proc001()
 BEGIN
  SELECT productos.cod_producto, productos.producto, productos.precio_venta1,
         productos.unidad, productos.saldo, productos.cod_proveedor,
         productos.cod_marca, productos.cod_grupo, productos.codbar1,
         productos.codbar2, productos.observaciones, proveedor.razon_social,
         marca.detalle AS marca, grupo.detalle AS grupo "
  FROM productos
  LEFT JOIN proveedor ON productos.cod_proveedor = proveedor.ruc_dni
  LEFT JOIN marca ON productos.cod_marca = marca.codigo
  LEFT JOIN grupo ON productos.cod_grupo = grupo.codigo
  ORDER BY productos.producto
 END
ENDTEXT

     oCn:Execute( cSql )
     lRet   := ( oCn:nError == 0 )

   endif

return lRet


Note the key words "BEGIN" and "END" at the beginning and end of the procedure.

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Mon Feb 14, 2022 2:33 am
by nageswaragunupudi
Recommended:
Code: Select all  Expand view

function CargaStoreProc( oCn )

   local cSql
   local lRet  := .t.
   
   if !oCn:IsProcedure( "proc001" )
     
TEXT INTO cSql
CREATE PROCEDURE proc001()
 BEGIN
  SELECT productos.cod_producto, productos.producto, productos.precio_venta1,
         productos.unidad, productos.saldo, productos.cod_proveedor,
         productos.cod_marca, productos.cod_grupo, productos.codbar1,
         productos.codbar2, productos.observaciones, proveedor.razon_social,
         marca.detalle AS marca, grupo.detalle AS grupo
  FROM productos
  LEFT JOIN proveedor ON productos.cod_proveedor = proveedor.ruc_dni
  LEFT JOIN marca ON productos.cod_marca = marca.codigo
  LEFT JOIN grupo ON productos.cod_grupo = grupo.codigo
  ORDER BY productos.producto
 END
ENDTEXT

     oCn:Execute( cSql )
     lRet   := ( oCn:nError == 0 )

   endif

return lRet
 


Note the key words "BEGIN" and "END" at the beginning and end of the procedure.

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Mon Feb 14, 2022 2:47 am
by Willi Quintana
Mr. Rao, Thanks
Code: Select all  Expand view

//local mode.   local lan    

CargaStoreProc(oCn)

? oCn:cServerInfo                      5.5.5-10.5.6-MariaDB
? oCn:OS                               Win64
? oCn:IsProcedure( "proc001" )         .t.

xbrowser oCn:ListProcedures()          LIst View with "proc001" in register        

oProd := oCn:Call( "proc001" )        
? VALTYPE(oProd)                       O
? oProd:producto                       ACEITE VEGETAL

oProd := oCn:CallSP( "proc001" )
? VALTYPE(oProd)                       O
? oProd:producto                       ACEITE VEGETAL

aProd := oCn:Execute( "CALL proc001" )
? VALTYPE(oProd)                       O
? oProd:producto                       ACEITE VEGETAL

aProd := oCn:Execute( "CALL proc001()" )
? VALTYPE(oProd)                       O            
? oProd:producto                       ACEITE VEGETAL    

all OK

//remote mode.   in cloud    // cpanel

CargaStoreProc(oCn)

? oCn:cServerInfo                      5.6.41-84.1
? oCn:OS                               Linux
? oCn:IsProcedure( "proc001" )         .f.

xbrowser oCn:ListProcedures()          empty        

oProd := oCn:Call( "proc001" )        
? VALTYPE(oProd)                       U
? oProd:producto                       error
 

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Thu Feb 17, 2022 2:18 pm
by nageswaragunupudi
That means the procedure could not be created on the cloud server.
Please check if your cloud server permits you to create procedures,triggers,etc on the server.
Some cloud servers do not permit.

Please also check this.
You are creating procedures with databasename included. Please check if that name is correct.
Recommended to create without including database name, so that the procedure is created in the current db.

Re: STORE PROCEDIRE Return Array Mr. Rao

PostPosted: Thu Feb 17, 2022 3:27 pm
by Willi Quintana
Thanks for your advice Mr. Rao