As (query directive)

From WandoraWiki
(Difference between revisions)
Jump to: navigation, search
 
Line 11: Line 11:
 
== Notes ==
 
== Notes ==
  
Generally you have to feed rows to As directive from some other directive through a From directive. All this is best done using the as method present in every directive. Calling A.as("role") will change the active column role name of the results of A. This will resolve to new As("role").from(A) which resolves to new From(new As("role"),A)'. The as method can also be given two parameters corresponding to the As directive constructor with two parameters.  
+
Generally you have to feed rows to ''As'' directive from some other directive through a ''From'' directive. All this is best done using the ''as'' method present in every directive. Calling ''A.as("role")'' will change the active column role name of the results of A. This will resolve to ''new As("role").from(A)'' which resolves to ''new From(new As("role"),A)''. The ''as'' method can also be given two parameters corresponding to the ''As'' directive constructor with two parameters.  
 +
 
 +
== Exmaples ==
 +
 
 +
importPackage(org.wandora.query2);
 +
new Instances().as("#instance")
 +
 
 +
Above example changes the default column role of ''Instances'' directive to "#instances". Note that using the ''as'' method is much more readable than creating same query using constructors only. Above example would be equal to
 +
 
 +
importPackage(org.wandora.query2);
 +
new From(new As("#instance"),new Instances())
 +
 
  
 
[[Category:Query directives]]
 
[[Category:Query directives]]

Revision as of 10:46, 20 August 2009

Contents

Description

Changes the role name of the active column or the specified column.

Constructor

As(String newRole) - Change the role name of the active column.

As(String original, String newRole) - Change the role name of the specified column.

Notes

Generally you have to feed rows to As directive from some other directive through a From directive. All this is best done using the as method present in every directive. Calling A.as("role") will change the active column role name of the results of A. This will resolve to new As("role").from(A) which resolves to new From(new As("role"),A). The as method can also be given two parameters corresponding to the As directive constructor with two parameters.

Exmaples

importPackage(org.wandora.query2);
new Instances().as("#instance")

Above example changes the default column role of Instances directive to "#instances". Note that using the as method is much more readable than creating same query using constructors only. Above example would be equal to

importPackage(org.wandora.query2);
new From(new As("#instance"),new Instances())
Personal tools