This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 145191 - Value from INSERT script isn't valid for "Insert Record" dialog
Summary: Value from INSERT script isn't valid for "Insert Record" dialog
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: _ ahimanikya
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-26 16:55 UTC by Roman Mostyka
Modified: 2008-08-30 05:29 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of a exception message. (111.54 KB, image/png)
2008-08-26 16:56 UTC, Roman Mostyka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Mostyka 2008-08-26 16:55:53 UTC
1. Connect to MS SQL Server.
2. Rightclick "person" table and choose "View Data...".
3. Press "Insert a record." buuton.
4. Specify all parameters and enter for "lastupdated" field (data type binary)
'0000000000000000000000000000000000000000000000000001000000001000' (I took this value from INSERT script for another row).
5. Click "Show SQL". Script is shown and no error is shown.
6. Press OK.

Result: Exception message appears and nothing is inserted. Look at message in attach.
Comment 1 Roman Mostyka 2008-08-26 16:56:45 UTC
Created attachment 68357 [details]
Screenshot of a exception message.
Comment 2 _ ahimanikya 2008-08-28 08:40:27 UTC
Can you send me create script for person table with some sample data. 

BTW, why lastupdated is binary?
Comment 3 Roman Mostyka 2008-08-28 12:13:56 UTC
Ahi, I've sent you an email.
Comment 4 _ ahimanikya 2008-08-28 13:33:29 UTC
Here is what SQL Server Books Online says about it:

The SQL Server timestamp data type has nothing to do with times or dates. SQL Server timestamps are binary numbers that
indicate the relative sequence in which data modifications took place in a database. The timestamp data type was
originally implemented to support the SQL Server recovery algorithms. ... Never use timestamp columns in keys,
especially primary keys, because the timestamp value changes every time the row is modified.

How did you create the table? anyway we need to handle this somehow.
Comment 5 _ ahimanikya 2008-08-28 13:41:48 UTC
A Transact-SQL timestamp != an ANSI SQL-92 timestamp. If its a SQL style timestamp you are after use a datetime data
type. A T-SQL timestamp are just auto generated binary numbers guarenteed to be unique in the context of a database and
are typically used for versioning, not storing dates.

The SQL Server timestamp type is a JDBC BINARY type with the fixed length of 8 bytes.

Given this, I think I can mark the as auto_generated if its binary and the size is 8.
Comment 6 Roman Mostyka 2008-08-28 13:45:37 UTC
This DB was created much time ago and actually I don't remember how it was created. I think script for MySQL or Java DB
was used and in it TIMESTAMP was used (which were converted by MS SQL Server to BINARY).
Comment 7 _ ahimanikya 2008-08-28 13:49:00 UTC
One should use datetime instead of timestamp for SQL Server.
Comment 8 _ ahimanikya 2008-08-28 18:23:01 UTC
http://hg.netbeans.org/main/rev/e034aa6ae5df

Since the SQL SERVER TimeStamp value is generated, I have marking as generated.

Displaying the binary data as 0s and 1s has a diff issues, I will look into them separately. The INSERT should work now.

As I said earlier, if you would like to store a date, then use SQL SERVER DateTime datatype, not timestamp.

Comment 9 Roman Mostyka 2008-08-29 12:27:17 UTC
Verified with build 080829.
Comment 10 Quality Engineering 2008-08-30 05:29:58 UTC
Integrated into 'main-golden', available in build *200808300201* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/e034aa6ae5df
User: ahimanikya@netbeans.org
Log: #145191 Value from INSERT script isn't valid for "Insert Record" dialog