If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > why the error with looping chain of synonyms...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-27-10, 15:53
MIKELALA MIKELALA is offline
Registered User
 
Join Date: Nov 2009
Posts: 45
why the error with looping chain of synonyms...

Hello all

am using sql developer ..am getting the error when i run the given query " looping chain of synonyms"

SELECT RELATION ,
FIELD_NAME ,
ATTRIBUTE ,
FIELD_DESCRIPTION,
SOURCE
FROM VARIABLE_INFO
WHERE RELATION NOT IN ( "CHAI" ,"ITAB", "ITB2", "ITB3", "MINI", "NOTE", "MINC", "FINI", "FTIM", "FWTG", "FMLY", "FMIS", "FSUM", "MEMB" ,"FINC", "FASO")
AND FIELD_NAME IN ( SELECT FIELD_NAME FROM VARIABLE_INFO WHERE SUBSTR(FIELD_NAME,-2)
in ('X1', 'X2' ,'X3', 'X4', 'X5', 'X0', 'XA', 'XB', 'XM' ,'XP' ,'CM','MT')
OR substr(FIELD_NAME,-1) in ('X') OR substr(FIELD_NAME,1) in ('J') )
AND ATTRIBUTE LIKE "NUM%" OR ATTRIBUTE = '-' ;

--> the error is looping chain in synonyms
line 6 col 5

I am not able to understand the eror ..

thanks/mike
Reply With Quote
  #2 (permalink)  
Old 05-27-10, 16:33
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
The SQL engine is grumping that it doesn't like VARIABLE_INFO used twice without using a synonym for it. Being a purist, I'd use two different synonyms:
Code:
SELECT A.RELATION, A.FIELD_NAME, A.ATTRIBUTE
,  A.FIELD_DESCRIPTION, A.SOURCE 
   FROM VARIABLE_INFO AS A
   WHERE A.RELATION NOT IN ('CHAI' ,'ITAB', 'ITB2'
,     'ITB3', 'MINI', 'NOTE'
,     'MINC', 'FINI', 'FTIM'
,     'FWTG', 'FMLY', 'FMIS'
,     'FSUM', 'MEMB' ,'FINC'
,     'FASO') 
      AND FIELD_NAME IN (SELECT B.FIELD_NAME
         FROM VARIABLE_INFO AS B
         WHERE SubStr(B.FIELD_NAME, -2) in ('X1', 'X2' ,'X3'
,           'X4', 'X5', 'X0'
,           'XA', 'XB', 'XM' 
,           'XP' ,'CM','MT')
            OR SubStr(B.FIELD_NAME, -1) in ('X') 
            OR SubStr(B.FIELD_NAME,  1) in ('J') ) 
      AND A.ATTRIBUTE LIKE 'NUM%' 
      OR  A.ATTRIBUTE = '-' ;
Note that there are probably more problems to be solved than just this!

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On