buzzcutbuddha has asked for the wisdom of the Perl Monks concerning the following question:

Alright, this is really bending my brain. I have the following code:
my $crconn = Win32::OLE->new('ADODB.Connection'); my $crrs = Win32::OLE->new('ADODB.Recordset'); $crconn->open("Credentialing"); my $lastname = $rs->Fields("LastName")->{'Value'}; $lastname =~ m/^\b([A-Za-z]+)\b(.*)$/gi if ($lastname); my $rsID = $rs->Fields("ID")->{'Value'}; my $sql = "SELECT * FROM [PHYSICIAN TABLE] WHERE "; $sql .= "[PHYSICIAN TABLE]\.[LAST NAME] LIKE \'\*$1\*\ +';"; print SQLLOG $sql, "\n"; $crrs = $crconn->execute($sql); print LOGFILE "Foo!\n Win32::OLE->LastError()\n" if (Win32::OL +E->LastError()); if ($crrs->eof) { # start matching based on the last name # now would be a good time to use the misspelling module f +rom CPAN # this will be done at a later time $finalmatch{$rsID} = "No Match By Last Name"; }
whose sole purpose is to take the last name from the first recordset $rs and grab the first
'wordish' chunk and build a SQL statement around said chunk and query an Access database for any matches.
if it doesn't find a match, then it throws the ID field from $rs into a hash, with the appropriate message.

Now, I have the SQL print out to a file, and when I physically test the queries right in Access, they return values,
here in the program, it doesn't seem to return any values. Is this a problem with my code? Or should I look elsewhere?


Thanks in advance,
Maurice

Replies are listed 'Best First'.
There are different LIKE wildcards between SQL implementations
by Corion (Patriarch) on Jun 02, 2000 at 18:41 UTC
    If I remember right, MS Access uses * for wildcard matches while the rest of the SQL world uses % for wildcard matches. So your Perl bindings might be smart and convert that query for you or they might be dumb and not convert them - simply try replacing \* in your query with % ...
      All known SQL databases that i know of use % for wildcard matching. The difference in SQL on Access compared to the rest of the world is, that Access uses # around date and time types e.g. #03/14/2000#. Not like the rest of the known SQL world and treat them as strings like this '03/14/2000'.

        From what I've heard about SQL dates, there is no rule as to how a date should be formatted (at least from my personal SQL guru, I've only heard different rantings about how different SQL servers (at different shops) interpret different strings as dates).

        Most notably, MS/Sybase SQL server seems to change the interpretation on what makes a string a date based on the locale settings for the server it is running on, but that might be the remains of some nightmare I've had :)

        It gets even worse if you use both SQL Server and Access in the same shop, and you start
        linking tables, and you have to remember to modify your queries depending on where the
        table originates. Sometimes you get funky results if you don't.

        Can't wait to get out of here and into some consistency.
      Corion!
      You solved it. I removed those pesky \* altogether, and the program works again!

      Thank you so much. If I could vote for your node again I would!
      M