Determining if a field has been updated

Determining if a field has been updated

Post by jpd4.. » Thu, 02 Sep 1993 00:34:32



Hi netters...

I was wondering how I can find out if a field (specifally a numeric field)
has ever been updated.  By default, the field in the database is blank.
If I make a comparison:

? field1 = 0.00

I get the answer .T.

If I make the comparison

? field1 = SPACE(0)    <-- The only 'Null' I could think of

I get the answer Operator/Operand type mismatch or something...

I want to be able to distinguis between a value of 0 (zero) and no value
at all.  Any ideas?

Thanks,
Jason

 
 
 

Determining if a field has been updated

Post by Keyuan Jia » Thu, 02 Sep 1993 02:53:27




>I was wondering how I can find out if a field (specifally a numeric field)
>has ever been updated.  By default, the field in the database is blank.
>If I make a comparison:

the default value for a numeric field is ZERO not a BLANK. one solution to
the problem is to use character field, and do some conversion back and forth
using VAL() and STR().

hope this message helps.



 
 
 

Determining if a field has been updated

Post by Gv Fragan » Fri, 03 Sep 1993 08:57:28



>I was wondering how I can find out if a field (specifally a numeric field)
>has ever been updated.  By default, the field in the database is blank.

Use the EMPTY() function. It works properly for all data types including
numeric.

Look up the function in the docs - pretty easy to use.

 
 
 

Determining if a field has been updated

Post by Doug Lind » Fri, 03 Sep 1993 10:27:48


: Use the EMPTY() function. It works properly for all data types including
: numeric.
: Look up the function in the docs - pretty easy to use.

Yeah - Fox had it for a long time and never mentioned it.  When I found
out, I thought "Oh, neat - that's a useful function.  Yet another place
dBase falls down" - and never thought of it again (except when I used it!). I
practically laughed out loud when, a year later, I saw it touted as one of
the big, new improvements in dBase: "NOW SUPPORTS
EMPTY FIELD CHECKING!!!," the ad shouted, like it was just as important as all
the other changes.  Guess they hadn't really made all *that* many
improvements to crow about after all.

-------------------------------------------------------------------------
Doug Linder    "Professional Angry Young Man and Tilter-at-Windmills."

 
 
 

Determining if a field has been updated

Post by Brian Jeps » Fri, 03 Sep 1993 10:41:01



>Hi netters...

>I was wondering how I can find out if a field (specifally a numeric field)
>has ever been updated.  By default, the field in the database is blank.
>If I make a comparison:

[stuff deleted]
>Thanks,
>Jason

You would need to save the value to a public variable in the WHEN clause
of the field, and in the valid, compare the public variable to the
variable's value:

PUBLIC borkBorkBork

     WHEN onWhen(m.bork) ;
     VALID onValid(m.bork)

READ CYCLE

RETURN

PROC onWhen
PARA val

     borkBorkBork = m.val

RETURN

PROC onValid
PARA val

     IF m.borkBorkBork != m.val
           WAIT WINDOW "You borked!"
     ELSE
           WAIT WINDOW "No bork!"
     ENDIF

RETURN

Or something like that....

--
* "The Martians are *always* coming" - Philip Kindred*
*


 
 
 

Determining if a field has been updated

Post by Gv Fragan » Sat, 04 Sep 1993 02:03:17



Quote:>Yeah - Fox had it for a long time and never mentioned it.  When I found
>out, I thought "Oh, neat - that's a useful function.  Yet another place
>dBase falls down" - and never thought of it again (except when I used it!). I
>practically laughed out loud when, a year later, I saw it touted as one of
>the big, new improvements in dBase: "NOW SUPPORTS
>EMPTY FIELD CHECKING!!!," the ad shouted, like it was just as important as all
>the other changes.  Guess they hadn't really made all *that* many
>improvements to crow about after all.

On the other end, I guess the counter-part of EMPTY() is the SCATTER MEMVAR
BLANK command. The nice thing about this is that it empties all fields to
null regardless of datatype (logical becomes .F., though). So rather than
making a routine called MAKEMPTY(myvar) that will first test the datatype of
myvar and then traverse through a set of do/case statements depending on the
tested datatype, I just use SCATTER MEMVAR BLANK FIELDS myvar, if I am emptying
a memory field (ie. M.myvar). If myvar is a database field (ie. MyDBF.MyVar)
then I issue GATHER FIELDS myvar right after the SCATTER command.

Hope this helps.

 
 
 

Determining if a field has been updated

Post by rowlan » Wed, 08 Sep 1993 07:28:48




>Subject: Re: Determining if a field has been updated
>Date: 1 Sep 93 23:57:28 GMT

>>I was wondering how I can find out if a field (specifally a numeric field)
>>has ever been updated.  By default, the field in the database is blank.
>Use the EMPTY() function. It works properly for all data types including
>numeric.
>Look up the function in the docs - pretty easy to use.

Empty() is only good for determining wheither a field contains an actual
value or not. i.e. Spaces.  It does not tell you weither the field has
been updated unless the data has been initialised to spaces, zeroes first.

The best way to check wheither data has changed in get fields is to place
the fields into memory variables and GET the memory variables.

e.g.
use dbfname
m.mem1 = dbfname.field1
m.mem2 = dbfname.field2

read

if  m.mem1 = dbfname.field1 ;
and m.mem2 = dbfname.field2
    * no update
else
    * update
    replace dbfname.field1 with m.mem1, ;
            dbfname.field2 with m.mem2
endif

I always get the memory variables instead of the database fields as it
gives better control of the data which gets stored to the database. If
you append blank records to the database everytime the user selects add
new record, the database would get filled with blank records as
occasionally, the uses aborts an append half-way through.  It is better
to do the append once the data to add has been validated.

Just my 2 bits.

Dave

 
 
 

1. Having problems updating a date field from asp

Hi,

I have a problem adding data to a date field. I am trying
to update the database thru asp code. But SQL server
automatically puts 01/01/1900 as date value if I don't
supply any values to the date field. There is no default
values assigned to date fields. This is happening on all
date fields in the entire database. Here is a sample sql
code on the design of the table that SQl server
generated .

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[DEMO1]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[DEMO1]
GO

CREATE TABLE [dbo].[DEMO1] (
        [FAXED] [datetime] NULL ,
        [CONFIRMED] [datetime] NULL ,
        [RECEIVED] [varchar] (255) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
        [COMMENTS] [text] COLLATE
SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

2. -Linked Server--Richard Waymire Seminar--Cannot use Integrated Security with Linked Server with SQL7 and Win2k--

3. PL/SQL: To determine which field was update

4. Auto Incrementing "TEXT" fields

5. I am having a problem with a hard disk drive or floppy disk drive

6. Using BLOBS with ADO

7. i also am having problems connecting with MS JDBC driver for sql2k

8. Visual Studio 6.0 Enterprise Edition

9. I am having a problem with the following SQL statements:

10. i am having a brainfreeze right now.

11. I am having problems with addnew

12. I am having a multi-step problem...

13. I am having trouble with calling a stored proc within a trigger