[SOLVED] MSS U5.0 driver producing a CAST error

Author: p.lovati@pokerspa.it (PaoloLovati)

Hi all, a table has its primary key defined as numeric so it has NOT NULL in the database. The key has to be filled by a db SEQUENCE, so it is left empty in the component. When the WRITE applies the MSS drivers tries to store spaces instead of NULL in the field, producing a CAST error. The ORA driver handles this correctly. It looks like a bug (BUG 29424) solved for DB2 driver...   Uniface : [MSW] 9.6.08.02, X801 SQLServer System Information : ------------------------------------------------ Driver : sqlncli11.dll 11.00.3000 ODBC Version : 03.80.0000 Driver ODBC Version : 03.80 SQLServer2 Database Information : ------------------------------------------------ DBMS name : Microsoft SQL Server DBMS Version : 11.00.3156   Thanks for any reply. Paolo

3 Comments

  1. Hi, do you execute your SEQUENCE in the write-trigger before write? If thats your scenario, then the trick is to set the length of the field to 0, eg. Syntax: NED,NPR,LEN(0-0) or as it works, you will probably set the syntax to Syntax: HID,LEN(0-0) Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)
  2. Hi RogerW, thanks for your reply. I tried to set the syntax of the field to HID,LEN(0-0) but the result was the same (CAST error). The only way to make it work seems to set a value in the field before the activation of the write trigger. Since the right value has to be set by the SEQUENCE, at db level, I set the initial value of the field to '0' (avoiding, in this way, the CAST error). A trigger INSTEAD OF, at db level, will then set the value from the SEQUENCE. The same result can be reached, in Oracle, using a BEFORE INSERT trigger, but there is no need to force an initial value to the field, so it can be left to NULL. Anyway... with the workaround, the problem is solved. Regards Paolo L.


    Author: PaoloLovati (p.lovati@pokerspa.it)
  3. Ok,  from your question I somehow understood that your key was set at db level.  I have successfully built one application where the key is always instantiated (eg. by a sequence if Sql-server version is new enough) before the write in the write-triggers. But I understand the advantage of doing it outside Uniface and any other programming-language or sql.   Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)