473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Migration to Postgres

As a background task, I am migrating our back end from Access 2000
to PostgreSQL. It is important to me that the front end code runs on
both Access and PostgreSQL to ease the pain on the day we finally
switch over (And back and over and back)
Every language I have ever used has accepted the Implicit use of
Booleans in an If statement:
If ( rsEmployee("Active")) then

Postgres on the other hand seems to require the Explicit use:
If ( rsEmployee("Active") = True ) then

I realize this may be a Postgres question but because I know many
on the user group have made this transition, it seemed appropriate to
post it here. If you have any ideas, please comment.
Thanks,
Hank Reed

Nov 13 '05 #1
7 1592
I think most here who have used PostgreSQL have used it strictly as a server
database. I haven't used it at all, but had no idea that it had a front-end
UI capability, too.

But, just for the record, there are certain instances in Access where it is
either necessary or better to use the explicit form:

If SomeBoolVar = True Then

rather than

If SomeBoolVar Then

Larry Linson
Microsoft Access MVP

"Hank" <ha********@aol.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
As a background task, I am migrating our back end from Access 2000
to PostgreSQL. It is important to me that the front end code runs on
both Access and PostgreSQL to ease the pain on the day we finally
switch over (And back and over and back)
Every language I have ever used has accepted the Implicit use of
Booleans in an If statement:
If ( rsEmployee("Active")) then

Postgres on the other hand seems to require the Explicit use:
If ( rsEmployee("Active") = True ) then

I realize this may be a Postgres question but because I know many
on the user group have made this transition, it seemed appropriate to
post it here. If you have any ideas, please comment.
Thanks,
Hank Reed

Nov 13 '05 #2
Larry,

Thanks for the tip, I didn't mean that Postgres had a front
end but I do refer to table data from Access VBA. I have had a long
carreer spaning many languages and I always wrote and taught that IF
statements evaluated to True or False.

If ( 2 > 1 ) then True
If ( Age < 50 ) then Sadly False
If ( BoolVal ) then To me is already True or False

In all my programming, I have sought to be explicit in every
way, to make functions understandable down the road, and very verbose
in commenting, so I will no longer take the implicit shortcut.
Thanks again,
Hank

Nov 13 '05 #3
The problem is that some sql systems return a DIFFERENT TEXT value for true!

So, if you hit ctrl-g to jump to the debug window, you can test this:

? "true" = true
True
? -1 = true
True

Note how above I have a text string called "true" and I compare it to the
built in Boolean value. The fact of the matter, is that a string of "true"
is NOT equal to the Boolean value of true, but the above still returns a
true value.

? cint(true)
-1

So, what happens is the system "casts" the true variable into a string for
the compare BEFORE the condition.

? cstr(true)
True

So, for "true" = true, we get:

"true" = "true"

The two strings are equal, and the expression resolves to a Boolean

Note that if you convert a number in ms-access to Boolean, then , any NON
zero number is considered true

if 5 then
true!!!

if -5 then
true!!!

So, what ms-access is doing in the above, is CONVERTING the expression to a
Boolean.

eg:
if 2 then
true!!!

but-
? (2 = true)
False

? (cbool(2) = True)
True

? (-1 = true)
true

If "true" Then
true

If "test" then
execution error!!...that string can't resolve to true/false!!

So, check what the server database returns for true, and false (and, for
some sql systems, you can CHANGE what the value returned is).

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #4
There are differing opinions as to whether that is a "defect" or a "feature"
of Access. If you are feeling lucky, call it in to Microsoft Tech Support --
if they agree with you that it is a defect, they won't charge you for the
call. As for me, I'm perfectly happy to know a workaround for what I
consider just a "quirk".

There are, as Albert pointed out, differences in the way different databases
represent Yes/No or True/False values. Jet, the default database that
installs with Access, uses the integer value -1. Microsoft SQL Server uses
the value 1. I don't know what physical value PostgreSQL uses. It's not
surprising to me, under the circumstances, that VBA may not translate
exactly.

Larry Linson
Microsoft Access MVP

"Hank" <ha********@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Larry,

Thanks for the tip, I didn't mean that Postgres had a front
end but I do refer to table data from Access VBA. I have had a long
carreer spaning many languages and I always wrote and taught that IF
statements evaluated to True or False.

If ( 2 > 1 ) then True
If ( Age < 50 ) then Sadly False
If ( BoolVal ) then To me is already True or False

In all my programming, I have sought to be explicit in every
way, to make functions understandable down the road, and very verbose
in commenting, so I will no longer take the implicit shortcut.
Thanks again,
Hank

Nov 13 '05 #5
"Larry Linson" <bo*****@localhost.not> wrote in
news:w%OQe.21927$yv2.13247@trnddc04:
But, just for the record, there are certain instances in Access
where it is either necessary or better to use the explicit form:

If SomeBoolVar = True Then

rather than

If SomeBoolVar Then


I don't know of any.

Boolean tests on controls are completely different than Boolean
tests on variables. With variables, you don't need an explicit
comparison at all, ever, though you may choose to do so for code
clarity.

So far as I know, it's only the checking of controls that requires
either explicit comparison, or parantheses to force evaluation. In
other words:

If Me!chkChecktBox = True THen

OR

If (Me!chkChecktBox) THen

But other than controls, I know of no pitfalls with Boolean tests.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
"Albert D. Kallal" <ka****@msn.com> wrote in
news:GyYQe.337721$s54.316290@pd7tw2no:
So, check what the server database returns for true, and false
(and, for some sql systems, you can CHANGE what the value returned
is).


This is surely the explanation. When you compare explicitly to True,
then VBA uses the definition of True that is the real one: True is
NOT FALSE. THat is, evern non-zero value is True.

So, if PostgreSQL uses 1 for True and your ODBC driver doesn't
transparently handle this, you're asking:

If 1 Then

And 1 doesn't evaluate as True in that context.

But if you do:

If 1 = True Then

you get the correct example, because 1 evaluates as not being false.

If you instead test:

If Not (Not (rsEmployee("Active"))) then

you should get the correct result, because everyone uses 0 for
False.

If the value is True, it would effectively be:

If Not (Not (1)) then

Not 1 should be False, then when you negate that, you get True in
VBA (instead of PostgreSQL's value for True).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
On 29 Aug 2005 05:09:13 -0700, "Hank" <ha********@aol.com> wrote:
As a background task, I am migrating our back end from Access 2000
to PostgreSQL. It is important to me that the front end code runs on
both Access and PostgreSQL to ease the pain on the day we finally
switch over (And back and over and back)
Every language I have ever used has accepted the Implicit use of
Booleans in an If statement:
If ( rsEmployee("Active")) then

Postgres on the other hand seems to require the Explicit use:
If ( rsEmployee("Active") = True ) then

I realize this may be a Postgres question but because I know many
on the user group have made this transition, it seemed appropriate to
post it here. If you have any ideas, please comment.
Thanks,
Hank Reed


There is a PostgreSQL driver setting called Bools As Char that is turned on by
default. You probably need to turn it off. If you don't you can never bind a
booleand field to a check box.
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paddy McCarthy | last post by:
Frustrated at being prevented from using Python at work I went gunning for Perl. Time to roll out some useless Google statistics to make me feel better Google Phrase count...
1
by: rob | last post by:
Dear All, I have a very small test project to convert asp to asp.net using the Microsoft/Artisan ASP to ASP.NET Migration Assistant...
3
by: warwick.poole | last post by:
I am interested in finding out about Enterprise scale Postgres installations and clustering, especially on Linux. Essentially I would like to know the possibility that Postgres can store the...
4
by: Christophe Musielak | last post by:
Hello, First let me introduce myself as i'm posting for the first time. I'm a project manager working for a french e-crm company, that is dealing with packaged email managing solutions, both...
2
by: phantom | last post by:
Hi all. We have a production data source running postgres for reporting/DSS we are thinking on building a warehouse, wherein data would be transferred from postgres to the warehouse. The...
5
by: Christophe Musielak | last post by:
Hi everyone at the list, Some months ago i asked you some questions about 7.2 - 7.4.3 migration. Then i switched to the performance list to complain about postgres 7.2 poor performance and...
18
by: Joe Lester | last post by:
This thread was renamed. It used to be: "shared_buffers Question". The old thread kind of died out. I'm hoping to get some more direction by rephrasing the problem, along with some extra...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
3
Frinavale
by: Frinavale | last post by:
I have been researching the best approach to migrating a VB6 application into a VB.NET application. There is a lot of information out there but most of it recommends that you "train in the migration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.