Question

I am trying to execute this query to get some results in db-visualizer, but I keep getting the following response:

Response:

[Error Code: 907, SQL State: 42000] ORA-00907: missing right parenthesis

Edited Query:

SELECT * FROM (
    SELECT 
    e.*, clt_add_l1, clt_add_l2, clt_city, clt_prst_cd, clt_pszp_cd 
    FROM     Staging.db_&tablename_v._match e,  client.clt_address ca, client.clt_add_usg au 
    WHERE    substr(match_desc,1,2) = '00' 
    and e.clt_ofc_no=au.clt_ofc_no(+) 
    and e.clt_no=au.clt_no(+) 
    and au.clt_ofc_no=ca.clt_ofc_no(+) 
    and au.clt_add_key=ca.clt_add_key(+) 
    and au.clt_add_type(+)='PRI' 
    UNION ALL
    SELECT 
    e.*, clt_add_l1, clt_add_l2, clt_city, clt_prst_cd, clt_pszp_cd 
    FROM     Staging.db_&tablename_v._match e,  staging.clt_address_cp au 
    WHERE    substr(match_desc,1,2) in ('01','02') 
    and e.namadd_no = au.namadd_no(+) 
) foo ORDER BY match_desc, seq_no;
Was it helpful?

Solution 4

The problem was &tablename_v. needed to be removed and a table name (i.e. DATES) was supposed to be inserted in place. I tried it and it worked.

But thank you all for your help! It is greatly appreciated :)

OTHER TIPS

Use:

   SELECT e.*, clt_add_l1, clt_add_l2, clt_city, clt_prst_cd, clt_pszp_cd, match_desc, seq_no
     FROM Staging.db_&tablename_v._match e 
LEFT JOIN client.clt_add_usg au ON au.clt_ofc_no = e.clt_ofc_no
                               AND au.clt_no = e.clt_no 
                               AND au.clt_add_type = 'PRI' 
LEFT JOIN client.clt_address ca ON ca.clt_ofc_no = au.clt_ofc_no
                               AND ca.clt_add_key = au.clt_add_key 
    WHERE substr(match_desc,1,2) = '00'
    UNION ALL
   SELECT e.*, clt_add_l1, clt_add_l2, clt_city, clt_prst_cd, clt_pszp_cd, match_desc, seq_no
     FROM Staging.db_&tablename_v._match e
LEFT JOIN staging.clt_address_cp au ON au.namadd_no = e.namadd_no
    WHERE substr(match_desc,1,2) IN ('01','02') 
 ORDER BY match_desc, seq_no

There's no need for the derived table/inline view. But it's not clear if the columns being ordered by are already in the query (IE: e.*), so I explicitly added them to the end.

I re-wrote the query to use ANSI-92 join syntax -- your query uses a long since deprecated means for outer joins.

I don't have your database & tables. Easiest way for you to determine the issue is to trim back the query until it starts returning data. Then, add criteria (column, table, WHERE/etc clause) one-by-one to see where things are going wrong.

Use either:

substr(match_desc,1,2) in ('00') 

or

substr(match_desc,1,2) = '00' 

i would guess that your GUI is not replacing

Staging.db_&tablename_v._match

properly. try this:

select 'Staging.db_&tablename_v._match' from dual;

whats the result? i'll have a guess that its leaving the table name like

Staging.db_whatever._match

instead of the intended

Staging.db_whatever_match
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top