Joining SQL statements Atrium Syntess Firebird DB

343 Views Asked by At

I'm trying to get (one or multiple) number lines (PROGCODE) that are attached to an OBJECT (i.e. a building) that is connected to a Relation which in turn has a GC_ID (relation unique ID). I need all the buildings & progcodes connected to a relation ID in a firebird 2.5 database generated by my companies ERP system.

I can look through all the tables in the firebird database and run select queries on them.I like to think I have the join statement syntax down and I know how to find the unique ID belonging to a relation, unfortunately I'm unsure how I can find the correct table that houses the information I seek.

The table I think this data is in has the following fields:

GC_ID, DEVICE_GC_ID, USER_GC_ID, CODE, DESCRIPTION. 

However when I query it using

select GC_ID, DEVICE_GC_ID, USER_GC_ID, CODE, DESCRIPTION 
from AT_PROGCODE A 

Then I get a description of the fields I'm trying to query.

i.e.

| GC_ ID : 100005 | DEVICE_GC_ID : 100174 | USER_GC_ID : 1000073 | DESCRIPTION: >description of what I'm trying to query< |

Can anyone shed some insight how I should handle this?


Update 7-09-2017

I spoke with the ERP consultant and was told the tables I needed (if anyone reading this is using syntess Atrium; the AT_BRENT table holds a description of all the tables.)

However, I've run into a new problem; the data I get from my sql query keeps streaming (it seems to never end with me stopping the script at 90 mil loops and the ERP program crashing if I ask for a count).

 select A.GC_OMSCHRIJVING Bedrijf, A.GC_CODE ,M.GC_OMSCHRIJVING Werktitel,  
        M.TELEFOON1, M.TELEFOON2, M.MOBIEL, M.EMAIL, 
        M.URL, M.DOORKIES_NR, M.WERKLOCATIE, M.EMAIL_INTERN 
from    AT_MEDEW M , AT_RELATIE A
JOIN    AT_MEDEW ON A.GC_ID = M.GC_ID
WHERE   M.TELEFOON1 <> '' OR  M.TELEFOON2 <> '' OR M.MOBIEL <> ''

Any ideas on what's the cause for my latest peril?

1

There are 1 best solutions below

2
On

First I had to find the AT_BRENT table which holds all the descriptions for tables in Syntess Atrium

Then I was using a CROSS JOIN (as pointed out by https://stackoverflow.com/users/696808/bacon-bits )

I ended up using

    select A.GC_OMSCHRIJVING Bedrijf, A.GC_CODE ,M.GC_OMSCHRIJVING Werktitel,  
    M.TELEFOON1, M.TELEFOON2, M.MOBIEL, M.EMAIL, 
    M.URL, M.DOORKIES_NR, M.WERKLOCATIE, M.EMAIL_INTERN 
    from    AT_MEDEW M
    JOIN  AT_RELATIE A ON A.GC_ID = M.GC_ID
    WHERE   M.TELEFOON1 <> '' OR  M.TELEFOON2 <> '' OR M.MOBIEL <> ''

Thank you all who helped.