0

I have in SQL Anywhere following table:

CREATE TABLE "documents" (
    "doc_id" uniqueidentifier NOT NULL DEFAULT NEWID(*),
    "doc_description" varchar(50) NOT NULL,
    ...
    PRIMARY KEY("doc_id")
)

I created a Datawindow.

(SQL Statement:

SELECT
"documents"."doc_id",      
"documents"."doc_description"
FROM "documents"   
WHERE "documents"."doc_id" = :ruid_doc )

I added ruid_doc as a retrieval argument and type = string.

When i try to save, I get the following error:

SQLSTATE = 07006 [Sybase][ODBC Driver] Cannot convert 0 to uniqueidentifier.

I have tried to use convert and cast.

fyi it is possible to do this via edit source.

Seki
  • 11,135
  • 7
  • 46
  • 70
klgr
  • 191
  • 1
  • 1
  • 12

1 Answers1

0

This post describing how to use an autoincremented column in a datawindow may help.

In short:

  • in the DW you declare the column as numeric
  • in the update properties of the DW, select the correct column for the the "identity column"
  • depending on the DBMS used, you need to tell in the PBODBxxx.ini (xxx being the version number) how an identity column is retrieved after insert. As it seems that you are using a Sybase driver, it can be

    [Sybase SQL Server]
    PBSyntax='SYBASE_SYNTAX'
    

    and

    [SYBASE_SYNTAX]
    GetIdentity='Select @@identity'
    ; GetIdentity='Select max(IDENTCOL) from &TableName'
    ; Alternative technique if table has insert trigger associated with it.
    

The post explains it in full details.

Seki
  • 11,135
  • 7
  • 46
  • 70
  • fyi: UNIQUEIDENTIFIER values generated using NEWID can therefore be used as keys in a **synchronization environment**. Your post is describing how to retrieve autoincremented column data in pb environment. – klgr Jan 28 '13 at 13:46
  • @KostasL: So? I am afraid I that I do not see difference between the two. Beware that the pbodb.ini file is used both during design time with the PB IDE and with the final application. – Seki Jan 28 '13 at 13:58
  • :My problem consists in how to create a datawindow when I have as primary key value an UNIQUEIDENTIFIER and when I want to retrieve a specific column, but what you are describing is something else entirely. – klgr Jan 28 '13 at 14:15