🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.vdbase.data.sql
Article #1232

Re: Translation of Dbase Boolean to SQL Server 6.5

#1232
From: Jorge Matos
Date: Wed, 11 Mar 1998 00:00
62 lines
2593 bytes
Jorge Matos wrote in message <6e6j9o$ah414@forums.borland.com>...
>Hello,
>
>    I exported a dbf table that has a boolean field to SQL Server 6.5 and I
>noticed that it converted the DBASE Logical type to a SQL Server Bit field
>type.  The problem I have is that I have a query object in VDB 7 that looks
>like this "select * from table where mylogicalfield  = true"  this works if
>the table is a DBASE table but when I try it against the SQL Server version
>of the table, I get a BDE error message "Database Engine Error: Could not
>find object".  If I change my query to be "select * from table where
>mylogicalfield = 1" then it works.
>
>I could write code that checked the "driverName" property of my database
>object and then I could chose the appropriate query sql string , for
example
>
>    d = new database()
>    d.databaseName = "BDE ALIAS FOR DBASE TABLE"
>    d.active = true
>
>    q = new query()
>    q.database = d
>
>    if d.driverName = "DBASE"
>        q.sql = "select * from table where field  = true"
>    else
>        q.sql = "select * from table where field  = 1"
>    endif
>
>    q.active = true
>
>
>The above code would still work when I change the databaseName property to
a
>BDE alias for SQL Server, but I think this is a kludge and I wonder if
>theres a better solution to this problem.  I also can't believe I would be
>the only one to encounter this problem and I hope someone else has a better
>solution to this.  I'm hoping there is a better way to phrase my sql
>statement so that it would work regardless of which BDE alias my database
>object is using.
>
>Thanks in Advance
>Jorge Matos
>
>
>

I figured it out, I used a parameterized query!

    d = new database()
    d.databaseName = "BDE ALIAS FOR DBASE TABLE"
    d.active = true

    q = new query()
    q.database = d
    q.sql =  "select * from table where myLogicalField  = :boolval"
    q.params["boolval"] = true
    q.active = true

    The above example works regardless if the BDE ALIAS is for DBASE or SQL
Server.
Technical Details
Message-ID: <6e6rt1$b0812@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6e6j9o$ah414@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,cfa2dced4e9ffd54
X-Google-Attributes: gidff5a1,public
From: "Jorge Matos" <matosj@dmac.com>
Subject: Re: Translation of Dbase Boolean to SQL Server 6.5
Date: 1998/03/11
Message-ID: <6e6rt1$b0812@forums.borland.com>
X-Deja-AN: 333085352
References: <6e6j9o$ah414@forums.borland.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.vdbase.data.sql