Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Sql: New 'Of' 'syntax'
Sql: New 'Of' 'syntax' [message #34611] Fri, 02 December 2011 00:20 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Recently I have found I am doing a lot of joins in SQL, which leats to pretty verbose 'syntax' to get columns in Select list:

Select(ID.Of(FOO), NAME.Of(FOO), SURNAME.Of(FOO),
       ID.Of(BAR), CODE.Of(BAR)).From(FOO).InnerJoin(BAR)...


after some thinking, I have introduced 'group synonym' for Of via function call, so now we can write:

Select(FOO(ID, NAME, SURNAME), BAR(ID, CODE)).From(FOO).InnerJoin(BAR)...

Re: Sql: New 'Of' 'syntax' [message #34639 is a reply to message #34611] Fri, 02 December 2011 20:21 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

mirek wrote on Thu, 01 December 2011 18:20

Recently I have found I am doing a lot of joins in SQL, which leats to pretty verbose 'syntax' to get columns in Select list:

Select(ID.Of(FOO), NAME.Of(FOO), SURNAME.Of(FOO),
       ID.Of(BAR), CODE.Of(BAR)).From(FOO).InnerJoin(BAR)...


after some thinking, I have introduced 'group synonym' for Of via function call, so now we can write:

Select(FOO(ID, NAME, SURNAME), BAR(ID, CODE)).From(FOO).InnerJoin(BAR)...



That's really cool. In one of my apps I simply generated ids that started with table shortcut. For PERSON table I've got:
PE_NAME, PE_AGE and so on. Disadvantage was too many global id objects.
Re: Sql: New 'Of' 'syntax' [message #34645 is a reply to message #34639] Sat, 03 December 2011 09:34 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
unodgs wrote on Fri, 02 December 2011 14:21

mirek wrote on Thu, 01 December 2011 18:20

Recently I have found I am doing a lot of joins in SQL, which leats to pretty verbose 'syntax' to get columns in Select list:

Select(ID.Of(FOO), NAME.Of(FOO), SURNAME.Of(FOO),
       ID.Of(BAR), CODE.Of(BAR)).From(FOO).InnerJoin(BAR)...


after some thinking, I have introduced 'group synonym' for Of via function call, so now we can write:

Select(FOO(ID, NAME, SURNAME), BAR(ID, CODE)).From(FOO).InnerJoin(BAR)...



That's really cool. In one of my apps I simply generated ids that started with table shortcut. For PERSON table I've got:
PE_NAME, PE_AGE and so on. Disadvantage was too many global id objects.


BTW, I have two more plans in this area:

InnerJoinRef(TABLE) will automatically create On condition based on .sch file foreign key.

And I consider creating some predefined SqlIds to be used as As ids (like aA ... aZ, aA1 ... aZ1, aA2 ... aA2). And maybe use ^ as As synonym:

Select(aF(ID, NAME, SURNAME), aB(ID, CODE)).From(FOO^aF).InnerJoinRef(BAR^aB).Where(...)


Mirek
Previous Topic: String & strlen optimization, force_inline in defs.h
Next Topic: CParser::GetSpacePtr
Goto Forum:
  


Current Time: Fri Mar 29 08:23:01 CET 2024

Total time taken to generate the page: 0.01428 seconds