Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Date problem
Thu, Jul 15 2021 12:36 PMPermanent Link

Michael Saunders

I have an EDB table that includes  a Date field that can be null and am trying to insert a new record into the table from a server program but get the error Status code 500 every time I try to Commit

What is wrong with this

    TestTable.Columns['Date'].asdatetime := Date;

Also how do I set the field to null

Many thanks
 
Thu, Jul 15 2021 12:39 PMPermanent Link

Michael Saunders

This also the same issue

    TestTable.Columns['Date'].asdate := Date;

 
Thu, Jul 15 2021 3:36 PMPermanent Link

Walter Matte

Tactical Business Corporation



How to set to null:

    TestTable.Columns['Date'].Clear;

 
Thu, Jul 15 2021 4:11 PMPermanent Link

Michael Saunders

Thanks but I still get an error   Should this work for Inserting or just  amending  existing values
Thu, Jul 15 2021 4:22 PMPermanent Link

Walter Matte

Tactical Business Corporation

It should work!  Did you call Insert on the dataset first?  Or is the Dataset configured for AutoEdit?

Walter
Thu, Jul 15 2021 4:44 PMPermanent Link

Michael Saunders

Here is my code  (  TestTable.Columns['Date']. in my first post was a typo)

  Database.StartTransaction;
  try
     TestTable.Insert;
     TestTable.Columns['TestField1'].AsString := 'AADDA';
     TestTable.Columns['TestField2'].AsString := 'TEST';
     TestTable.Columns['TestInt'].AsInteger := 23;
     TestTable.Columns['TestDate'].clear;
     TestTable.save;
     Database.Commit;
  except
    if Database.InTransaction then
       Database.Rollback;
    raise;
  end;
Thu, Jul 15 2021 4:46 PMPermanent Link

Michael Saunders

Here is the EDB Table definition

CREATE TABLE "TestTable"
(
"TestField1" VARCHAR(20) COLLATE "UNI",
"TestField2" VARCHAR(20) COLLATE "UNI",
"TestInt" INTEGER NOT NULL,
"TestDate" DATE
)
VERSION 1.00
READWRITE
UNENCRYPTED
INDEX PAGE SIZE 8192
BLOB BLOCK SIZE 1024
PUBLISH BLOCK SIZE 1024
PUBLISH COMPRESSION 0
MAX ROW BUFFER SIZE 32768
MAX INDEX BUFFER SIZE 65536
MAX BLOB BUFFER SIZE 32768
MAX PUBLISH BUFFER SIZE 32768!
Fri, Jul 16 2021 5:13 AMPermanent Link

Michael Saunders


TestTable.Columns['TestDate'].clear  fails but it does work OK provided  that Testdate is a different field type eg String
Tue, Jul 20 2021 5:13 AMPermanent Link

Michael Saunders

TestTable.Columns['TestDate'].clear   was a bug and has been fixed in build 3
Image