Quantcast
Channel: SCN : Popular Discussions - SAP SQL Anywhere
Viewing all articles
Browse latest Browse all 1302

Updating rows from a proxy table where key includes DATETIMEs

$
0
0

Hi,

 

I need to copy rows from a proxy table (SQL Server) into my SQLAnywhere database.  Both tables are quite similar, but not identical.   Here is the UPDATE statement I'm using to test:

 

BEGIN

 

  DECLARE pCia INT;

   DECLARE pFecha DATE;

   DECLARE pTienda INT;

 

  SET pCia = 11;

   SET pFecha = '2013-11-04';

   SET pTienda = 4;

 

   UPDATE v_ERP_Trans

              JOIN v_Trans

                     ON  v_ERP_Trans.Cia           = v_Trans.Cia

                       AND v_ERP_Trans.Fecha         = v_Trans.Fecha

                       AND v_ERP_Trans.idTienda      = v_Trans.idTienda

                      AND v_ERP_Trans.idCaja        = v_Trans.idCaja

                      AND v_ERP_Trans.idTransaccion = v_Trans.idTransaccion

    SET   v_ERP_Trans.idCajera = v_Trans.idCajera

   WHERE  v_Trans.Cia      = pCia

      AND v_Trans.Fecha    = pFecha

      AND v_Trans.idTienda = pTienda;

 

END

 

The only mismatch is that v_ERP_Trans.Fecha is a DATE column (on ASA), and v_Trans.Fecha is a DATETIME column (on the MS SQLServer).

 

If I run the above I get an error:  "Error: Cannot convert 11 to a date"

 

However, if I change the "pFecha" constraint to the following:

   UPDATE v_ERP_Trans

              JOIN v_Trans

                     ON  v_ERP_Trans.Cia           = v_Trans.Cia

                       AND v_ERP_Trans.Fecha         = v_Trans.Fecha

                       AND v_ERP_Trans.idTienda      = v_Trans.idTienda

                      AND v_ERP_Trans.idCaja        = v_Trans.idCaja

                      AND v_ERP_Trans.idTransaccion = v_Trans.idTransaccion

    SET   v_ERP_Trans.idCajera = v_Trans.idCajera

   WHERE  v_Trans.Cia      = pCia

      AND v_Trans.Fecha    = '2013-11-04'

      AND v_Trans.idTienda = pTienda;

 

IT WORKS!    However, that is not what I need.....

 

Any ideas as to what could be happening?   BTW, I also tried DATETIME(pFecha), but get the same error message...

 

Best regards,

Edgard


Viewing all articles
Browse latest Browse all 1302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>