PDA

View Full Version : Restructuring a Query in Perl


chief_wpd
02-05-03, 22:48
i have written some queries in SQL that work fine on my Access2002 Database, but when i transfer them to my Perl script I have to make some changes to them in order to get them to accept the user input values for the query.

For Instance, on my Front end DB the Query for a person by Last Name, Last Initial, Partial Last naem, First Name, First initial, part of first name, or a combination of any of the first and last inputs is simply made by this part of the query:

Where (([Persons.Lname] Like [Enter Last Name] & "*") AND ([Persons.Fname] Like [Enter First Name] & "*"))

However, in Perl, i have to chage it to this:

Where (([Persons.Lname] Like '$Lname') AND ([Persons.Fname] Like '$Fname'))

it won't accept the part with the & "*", and I don't know how to make it do that so that it can use an initial to find any name starting with that initial...... Therefore if the user doesn't know both names, and spell them as they are spelled in the DB, no returns are found.

Can anyone help me make the "wildcard" entries I want?

Thanks,

Mac

Bernd Dulfer
02-06-03, 06:28
Where (([Persons.Lname] Like [Enter Last Name] & "*") AND ([Persons.Fname] Like [Enter First Name] & "*"))

However, in Perl, i have to chage it to this:

Where (([Persons.Lname] Like '$Lname') AND ([Persons.Fname] Like '$Fname'))


I think the & "*" part appends a '*' to the entered value so that it looks like 'Jo*' and the engine would find 'Joe', 'John', 'Jonathan' aso.

You can just append a '*' to the variable in your Perl program:
Where (([Persons.Lname] Like '$Lname*') AND ([Persons.Fname] Like '$Fname*'))

Regards

Bernd