Convert to Varchar Problem

Ivan Smahin ivan_smahin at paradigmasoft.com
Thu Jun 23 06:21:35 CDT 2011


On 6/23/2011 1:10 PM, Beatrix Willius wrote:
> Hi,
>
> got another problem. In a new version of my application I'm converting some fields to VarChar. For one field a user sent me an error message:
>
> 2011-06-21, 16:38:37                             An error happened:
> 2011-06-21, 16:38:37                             Class/Method: getDatabase.ConvertToVarchar
> 2011-06-21, 16:38:37                             Time: Tuesday, 21 June 2011 16:38:37 27361688
> 2011-06-21, 16:38:37                             Type of Error: VException 144643 Attempt to insert duplicate key row in object "Mailbox.MailboxPath" with unique index "U_Mailbox_MailboxPath".
> 2011-06-21, 16:38:37                             --------------------------
> 2011-06-21, 16:38:37                             Stack:
> 2011-06-21, 16:38:37
> Sub VField.IsUnique.Set( int32, boolean )
> Sub getDatabase.ConvertToVarchar()
> Function getDatabase.openDB( int32 ) as boolean
> Function getDatabase.get( FolderItem, boolean, int32, VDatabase, boolean, AddMailboxDataInterface ) as VDatabase
>
> The code is as follows:
>
>    dim MailboxTable as VTable = ValentinaDB.Table("Mailbox")
>    if MailboxTable<>  nil then
>      dim MailboxPath as VString = MailboxTable.StringField("MailboxPath")
>      if MailboxPath<>  nil then
>        dim newMailboxPath as VField = MailboxTable.ChangeType(MailboxPath, EVFieldType.kTypeText, 256)
>        newMailboxPath.IsUnique = true
>      end if
>
>    end if
>
You are writing about converting to VarChar, but actually you are 
converting to the Text.
Which statement is true?

> The old definition of the field MailboxPath is:
>
>    dim MailboxPath as VString = new VString("MailboxPath",  1000)
>    MailboxPath.IsUnique = true
>
The old field was String(1000), the new field is Text(256) - actually 
any length with segment size  == 256.
Probably some really not unique values there?
BTW - you should not set unique flag in the loop.
One more point - unique string field is not a best idea, but unique text 
field ... would you consider to redesign db?

> Where could the error message come from?
Update record, add record._______________________________________________

-- 
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list