From: Thomas M. <tm...@bs...> - 2004-06-09 18:09:08
|
Is this easier to read? I tried to use as few lines as possible to make it easy to parse into a statement per Jim's code. With Delphi, you have a TStringList property to store it, so you can format it pretty. SELECT RDB$INDEX_SEGMENTS.RDB$FIELD_NAME, RDB$INDICES.RDB$SEGMENT_COUNT FROM RDB$INDICES JOIN RDB$INDEX_SEGMENTS ON RDB$INDICES.RDB$INDEX_NAME = RDB$INDEX_SEGMENTS.RDB$INDEX_NAME JOIN RDB$RELATION_CONSTRAINTS ON RDB$INDEX_SEGMENTS.RDB$INDEX_NAME = RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME WHERE RDB$RELATION_CONSTRAINTS.RDB$RELATION_NAME = ? AND RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION Arno Brinkman wrote: >Hi, > > > >>SELECT >> RDB$INDEX_SEGMENTS.RDB$FIELD_NAME, RDB$INDICES.RDB$SEGMENT_COUNT >>FROM >> RDB$INDICES JOIN RDB$INDEX_SEGMENTS >> ON RDB$INDICES.RDB$INDEX_NAME = RDB$INDEX_SEGMENTS.RDB$INDEX_NAME >> JOIN RDB$RELATION_CONSTRAINTS >> ON RDB$INDEX_SEGMENTS.RDB$INDEX_NAME = >>RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME >>WHERE >> RDB$RELATION_CONSTRAINTS.RDB$RELATION_NAME = ? AND >> RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' >>ORDER BY >> RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION >> >> > > > >>why use aliases at all >> >> > >Readability (if choosen proper aliasses ofcourse) and better extensible IMO. >I need to search for the JOIN clauses in your query for example. > >SELECT > ixs.RDB$FIELD_NAME, > i.RDB$SEGMENT_COUNT >FROM > RDB$RELATION_CONSTRAINTS rc > JOIN RDB$INDEX_SEGMENTS ixs ON > (ixs.RDB$INDEX_NAME = rc.RDB$INDEX_NAME) > JOIN RDB$INDICES i ON (i.RDB$INDEX_NAME = ixs.RDB$INDEX_NAME) >WHERE > rc.RDB$RELATION_NAME = ? AND > rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' >ORDER BY > ixs.RDB$FIELD_POSITION > >The thing i in fact don't like in this query is the hardly coded constant >'PRIMARY KEY', but were i'm talking about :-) Jim brings SQL into the engine >and that's a great improvement. > >Regards, >Arno Brinkman >ABVisie > >-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- >Firebird open source database (based on IB-OE) with many SQL-99 features : > http://www.firebirdsql.org > http://www.firebirdsql.info > http://www.fingerbird.de/ > http://www.comunidade-firebird.org/ > >Support list for Interbase and Firebird users : >fir...@ya... > >Nederlandse firebird nieuwsgroep : >news://80.126.130.81 > > > > > > >------------------------------------------------------- >This SF.Net email is sponsored by: GNOME Foundation >Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. >GNOME Users and Developers European Conference, 28-30th June in Norway >http://2004/guadec.org >Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel > > > -- Thomas Miller Delphi Client/Server Certified Developer BSS Accounting & Distribution Software BSS Enterprise Accounting FrameWork http://www.bss-software.com http://sourceforge.net/projects/dbexpressplus |