Re: SV: NULL vs Empty String
Patrick Hoeffel <[email protected]> Thu, 15 Aug 2002 15:22:16 -0600
| Newsgroups | gmane.comp.windows.devel.oledb.devel |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C244A1.D44E2630
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Alan,=20
Kim is exactly correct. This is what we do commonly in our code, as it =
would
look in your class:=20
class CAccRecType=20
{=20
public:=20
CAccRecType() { Clear() };=20
=20
LONG lKey;=20
TCHAR tcVal[10];=20
int iMoreData;=20
// Status variables (so we can pass nulls and defaults)=20
DBSTATUS m_statId;=20
=20
BEGIN_COLUMN_MAP(CAccRecType)=20
COLUMN_ENTRY_STATUS(1, tcVal, m_statId)=20
COLUMN_ENTRY( 2, lKey)=20
COLUMN_ENTRY( 3, iMoreData)=20
END_COLUMN_MAP()=20
void Clear() { memset(this,0,sizeof(*this) );=20
}=20
=20
usage:=20
=20
CAccRecType rec;=20
rec.lKey =3D 100L;=20
rec.iMoreData =3D 50;=20
m_statId =3D DBSTATUS_S_ISNULL;=20
[ add record to database ]=20
Patrick Hoeffel=20
Research and Development=20
Configuresoft, Inc.=20
http://www.configuresoft.com=20
-----Original Message-----
From: Kim Gr=E4sman [mailto:[email protected]]
Sent: Thursday, August 15, 2002 2:53 PM
To: [email protected]
Subject: [OLEDB_DEV] SV: NULL vs Empty String
Hi Alan,
=20
Definitely NULL, but a SQL-NULL, not a C++-NULL.
You need a status member (DBSTATUS tcVal_status) of your accessor to =
signify
that the member (tcVal) should be nulled in the DB.
=20
Does that help?
=20
Kim
-----Ursprungligt meddelande-----=20
Fr=E5n: Alan Gamboa [mailto:[email protected]]=20
Skickat: to 2002-08-15 22:34=20
Till: [email protected]=20
Kopia:=20
=C4mne: NULL vs Empty String
=09
=09
Hello all, a question on best practices...
=20
Which is the accepted practice in database storage for varchar =
type
fields...
=20
record is defined as below:
=20
class CAccRecType
{
public:
CAccRecType() { Clear() };
=20
LONG lKey;
TCHAR tcVal[10];
int iMoreData;
=20
void Clear() { memset(this,0,sizeof(*this) );
}
=20
usage:
=20
CAccRecType rec;
rec.lKey =3D 100L;
rec.iMoreData =3D 50;
[ add record to database ]
=20
if the field is not "used" in a record, what should be stored =
on the
database - NULL or "an empty string" ?
=20
tia
=20
Alan Gamboa
CCG Systems, Inc.
=20
You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.
You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV,
or subscribe to other DevelopMentor lists at =
http://discuss.develop.com.
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
------_=_NextPart_001_01C244A1.D44E2630
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [OLEDB_DEV] SV: NULL vs Empty String</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>Alan, </FONT>
</P>
<P><FONT SIZE=3D2>Kim is exactly correct. This is what we do commonly =
in our code, as it would look in your class: </FONT>
</P>
<P><FONT SIZE=3D2> class =
CAccRecType </FONT>
<BR><FONT SIZE=3D2> { </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; public: </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; CAccRecType() { Clear() }; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; LONG lKey; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; TCHAR tcVal[10]; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; int iMoreData; </FONT>
</P>
<P><FONT =
SIZE=3D2> &nb=
sp; // Status variables (so we can pass nulls and defaults) </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; DBSTATUS m_statId; </FONT>
<BR><FONT =
SIZE=3D2> =
</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; BEGIN_COLUMN_MAP(CAccRecType) </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; COLUMN_ENTRY_STATUS(1, tcVal, m_statId) =
</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; =
COLUMN_ENTRY(  =
; 2, lKey) </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; =
COLUMN_ENTRY(  =
; 3, iMoreData) </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; END_COLUMN_MAP() </FONT>
</P>
<P><FONT =
SIZE=3D2> &nb=
sp; void Clear() { memset(this,0,sizeof(*this) ); </FONT>
<BR><FONT SIZE=3D2> } </FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> usage: =
</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; CAccRecType rec; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; rec.lKey =3D 100L; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; rec.iMoreData =3D 50; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; m_statId =3D DBSTATUS_S_ISNULL; </FONT>
</P>
<P><FONT =
SIZE=3D2> &nb=
sp; [ add record to database ] </FONT>
</P>
<P><FONT SIZE=3D2>Patrick Hoeffel </FONT>
<BR><FONT SIZE=3D2>Research and Development </FONT>
<BR><FONT SIZE=3D2>Configuresoft, Inc. </FONT>
<BR><FONT SIZE=3D2><A HREF=3D"http://www.configuresoft.com" =
TARGET=3D"_blank">http://www.configuresoft.com</A> </FONT>
</P>
<BR>
<BR>
<BR>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Kim Gr=E4sman [<A =
HREF=3D"mailto:[email protected]">mailto:[email protected]</A>]<=
/FONT>
<BR><FONT SIZE=3D2>Sent: Thursday, August 15, 2002 2:53 PM</FONT>
<BR><FONT SIZE=3D2>To: [email protected]</FONT>
<BR><FONT SIZE=3D2>Subject: [OLEDB_DEV] SV: NULL vs Empty String</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>Hi Alan,</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2>Definitely NULL, but a SQL-NULL, not a =
C++-NULL.</FONT>
<BR><FONT SIZE=3D2>You need a status member (DBSTATUS tcVal_status) of =
your accessor to signify that the member (tcVal) should be nulled in =
the DB.</FONT></P>
<P><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2>Does that help?</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2>Kim</FONT>
</P>
<P><FONT SIZE=3D2> =
-----Ursprungligt meddelande----- </FONT>
<BR><FONT SIZE=3D2> Fr=E5n: =
Alan Gamboa [<A =
HREF=3D"mailto:[email protected]">mailto:[email protected]</A>] =
</FONT>
<BR><FONT SIZE=3D2> Skickat: =
to 2002-08-15 22:34 </FONT>
<BR><FONT SIZE=3D2> Till: =
[email protected] </FONT>
<BR><FONT SIZE=3D2> Kopia: =
</FONT>
<BR><FONT SIZE=3D2> =C4mne: =
NULL vs Empty String</FONT>
<BR> =20
<BR> =20
<BR><FONT SIZE=3D2> Hello =
all, a question on best practices...</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> Which is =
the accepted practice in database storage for varchar type =
fields...</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> record is =
defined as below:</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> class =
CAccRecType</FONT>
<BR><FONT SIZE=3D2> {</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; public:</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; CAccRecType() { Clear() };</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; </FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; LONG lKey;</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; TCHAR tcVal[10];</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; =
int =
iMoreData;</FONT>
<BR><FONT =
SIZE=3D2> =
</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; void Clear() { memset(this,0,sizeof(*this) );</FONT>
<BR><FONT SIZE=3D2> }</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> =
usage:</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; CAccRecType rec;</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; rec.lKey =3D 100L;</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; rec.iMoreData =3D 50;</FONT>
<BR><FONT =
SIZE=3D2> &nb=
sp; [ add record to database ]</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> if the =
field is not "used" in a record, what should be stored on the =
database - NULL or "an empty string" ?</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> =
tia</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
<BR><FONT SIZE=3D2> Alan =
Gamboa</FONT>
<BR><FONT SIZE=3D2> CCG =
Systems, Inc.</FONT>
<BR><FONT SIZE=3D2> =
</FONT>
</P>
<P><FONT SIZE=3D2>You can read messages from the OLEDB_DEV archive, =
unsubscribe from OLEDB_DEV, or subscribe to other DevelopMentor lists =
at <A HREF=3D"http://discuss.develop.com" =
TARGET=3D"_blank">http://discuss.develop.com</A>.</FONT></P>
<P><FONT SIZE=3D2>You can read messages from the OLEDB_DEV archive, =
unsubscribe from OLEDB_DEV,</FONT>
<BR><FONT SIZE=3D2>or subscribe to other DevelopMentor lists at <A =
HREF=3D"http://discuss.develop.com" =
TARGET=3D"_blank">http://discuss.develop.com</A>.</FONT>
</P>
</BODY>
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
</HTML>
------_=_NextPart_001_01C244A1.D44E2630--