build join query without PK-FK relationship

Posts   
 
    
bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 20-Nov-2008 19:04:26   

llblgen v2.6 dotnet 2.0

Hi In database it is possible to write a sql query joining the 2 tables together without having to have PK-FK relationship.

For instance:

Employee Name DOB

Visitor Name DateOfVisit select employee.name, employee.dob from employee join visitor on employee.name = visitor.name where DateOfVisit='01/01/2008'

I cannot build this using RelationPredicateBucket because there's no Visitor-to-Employee-relationship since there's no PK/FK relationship exists in the table. I also cannot create a custom relations because there's no PK nor FK defined in the employee and visitor tables

QUESTION: How to I achieve such query using llblgen. I don't want to do 2 queries, 1 is to query the visitor to get the name then query the employee to get the employee info.

Thanks

BZ

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 20-Nov-2008 21:22:52   

Yep, perfectly possible simple_smile Please see this thread

bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 20-Nov-2008 21:40:31   

MTrinder

The link you gave is the home page of the forum. Could you please give the correct link.

Thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 20-Nov-2008 21:43:41   

Interesting - it works fine for me disappointed

It's pointing here

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=14721

arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 20-Nov-2008 22:07:20   

Neither link works for me.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 20-Nov-2008 22:17:07   

Sorry, my fault - it's in the secure help desk so only the thread starter can see it.

You have two options.

You can specify the relation in the designer, even if the tables do not have a PK-FK relationship in the database

http://www.llblgen.com/documentation/2.6/Using%20the%20designer/designer_customrelations.htm

or you can specify them in code at run time

http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/gencode_derivedtabledynamicrelation.htm

Matt

bunzee
User
Posts: 84
Joined: 20-Mar-2007
# Posted on: 20-Nov-2008 22:22:39   

MTrinder

I already looked at the first approach and using the designer approach you mentioned would not work because there is NO PK defined in any of the tables at all.

The second approach is in program. I will take a look at it and let's see how that works out.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Nov-2008 22:23:26   

If there's no PK, the only option you have is through a dynamicrelation created in code.

Frans Bouma | Lead developer LLBLGen Pro