Home » Community » U++ community news and announcements » Sql: New 'Of' 'syntax'
Sql: New 'Of' 'syntax' [message #34611] |
Fri, 02 December 2011 00:20  |
 |
mirek
Messages: 14255 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   |
|
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  |
 |
mirek
Messages: 14255 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
|
|
|
Goto Forum:
Current Time: Tue Apr 29 08:18:26 CEST 2025
Total time taken to generate the page: 0.01068 seconds
|