Use of expressions or field aliases in GROUP BY clauses

I've seen numerous references, even BNF syntax
diagrams, that suggest that Oracle's parser will accept an expression in a
GROUP BY clause; however, I've had no success whatsoever in getting this to
work. Here's an example of something I had hoped would work, but does not:
SELECT
account_id,
CASE
WHEN txn_date BETWEEN DATE '2006-06-01' AND DATE '2006-06-07' THEN 1
WHEN txn_date BETWEEN DATE '2006-06-08' AND DATE '2006-06-14' THEN 2
ELSE 3
END AS week_id,
COUNT(*) AS week_cnt
FROM myschema.my_random_table_name
GROUP BY account_id, week_id;
The interpreter gags on the use of "week_id" in the GROUP BY statement.
Evidently Oracle syntax doesn't support the use of positional designations
in aggregating statements either - I tried using the clause
GROUP BY 1, 2;
as the last line, and it didn't like this either.
Any assistance or suggestions you can offer would be greatly appreciated.
I prefer to let the DBMS engine do my aggregating for me as much as
possible, but without being able to aggregate relative to programmer-defined
fields, I am somewhat hamstrung.

try this :
SQL> select case when hire_date between '01-JAN-00' and '31-DEC-05' then 1 else 0 end col1, count(*)
2 from employees
3 group by col1;
group by col1
ERROR at line 3:
ORA-00904: "COL1": invalid identifier
SQL>
SQL>
SQL>
1 select case when hire_date between '01-JAN-00' and '31-DEC-05' then 1 else 0 end col1, count(*)
2 from employees
3* group by case when hire_date between '01-JAN-00' and '31-DEC-05' then 1 else 0 end
SQL> /
COL1 COUNT(*)
1 11
0 96

Similar Messages

  • Can i use an analytic function instead of a group by clause?

    Can i use an analytic function instead of a group by clause? Will this help in any performance improvement?

    analytic can sometimes avoid scanning the table more than once :
    SQL> select ename,  sal, (select sum(sal) from emp where deptno=e.deptno) sum from emp e;
    ENAME             SAL        SUM
    SMITH             800      10875
    ALLEN            1600       9400
    WARD             1250       9400
    JONES            2975      10875
    MARTIN           1250       9400
    BLAKE            2850       9400
    CLARK            2450       8750
    SCOTT            3000      10875
    KING             5000       8750
    TURNER           1500       9400
    ADAMS            1100      10875
    JAMES             950       9400
    FORD             3000      10875
    MILLER           1300       8750
    14 rows selected.
    Execution Plan
    Plan hash value: 3189885365
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    14 |   182 |     3   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE    |      |     1 |     7 |            |          |
    |*  2 |   TABLE ACCESS FULL| EMP  |     5 |    35 |     3   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS FULL | EMP  |    14 |   182 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("DEPTNO"=:B1)which could be rewritten as
    SQL> select ename, sal, sum(sal) over (partition by deptno) sum from emp e;
    ENAME             SAL        SUM
    CLARK            2450       8750
    KING             5000       8750
    MILLER           1300       8750
    JONES            2975      10875
    FORD             3000      10875
    ADAMS            1100      10875
    SMITH             800      10875
    SCOTT            3000      10875
    WARD             1250       9400
    TURNER           1500       9400
    ALLEN            1600       9400
    JAMES             950       9400
    BLAKE            2850       9400
    MARTIN           1250       9400
    14 rows selected.
    Execution Plan
    Plan hash value: 1776581816
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    14 |   182 |     4  (25)| 00:00:01 |
    |   1 |  WINDOW SORT       |      |    14 |   182 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    14 |   182 |     3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------well, there is no group by and no visible performance enhancement in my example, but Oracle7, you must have written the query as :
    SQL> select ename, sal, sum from emp e,(select deptno,sum(sal) sum from emp group by deptno) s where e.deptno=s.deptno;
    ENAME             SAL        SUM
    SMITH             800      10875
    ALLEN            1600       9400
    WARD             1250       9400
    JONES            2975      10875
    MARTIN           1250       9400
    BLAKE            2850       9400
    CLARK            2450       8750
    SCOTT            3000      10875
    KING             5000       8750
    TURNER           1500       9400
    ADAMS            1100      10875
    JAMES             950       9400
    FORD             3000      10875
    MILLER           1300       8750
    14 rows selected.
    Execution Plan
    Plan hash value: 2661063502
    | Id  | Operation            | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |      |    14 |   546 |     8  (25)| 00:00:01 |
    |*  1 |  HASH JOIN           |      |    14 |   546 |     8  (25)| 00:00:01 |
    |   2 |   VIEW               |      |     3 |    78 |     4  (25)| 00:00:01 |
    |   3 |    HASH GROUP BY     |      |     3 |    21 |     4  (25)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL| EMP  |    14 |    98 |     3   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS FULL  | EMP  |    14 |   182 |     3   (0)| 00:00:01 |
    -----------------------------------------------------------------------------So maybe it helps

  • -- SQL -- GROUP BY clause: non-aggregate fields mandate

    Hello,
    I was studying Databases, (particularly the retrieval of the data), and found something interesting.
    While using an Aggregate Function in the SELECT clause, it is mandatory to have all the non-aggregate fields in the SELECT clause to be there in the GROUP BY clause.
    For example,
    SELECT dept_no, SUM(salary)
    FROM employee
    GROUP BY dept_no;
    The above SQL works fine.
    But, what if the user misses the dept_no in the GROUP BY clause or he/she misses the GROUP BY clause itself?
    Certainly, it is an error.
    Why is this error not handled by the database. I mean, the database should be smart/intelligent enough to add the GROUP BY clause by itself. So suppose, if I miss out the GROUP BY clause or miss a non-aggregate field from the SELECT clause when I am having at least one aggregate function on a field with at least one non-aggregated field in the SELECT clause, the database should check the GROUP BY clause at time of compilation and add the mandate missed out fields in the GROUP BY clause.
    Example,
    SQL1:_
    SELECT dept_no, SUM(salary)
    FROM employee
    GROUP BY dept_no;
    SQL2:_
    SELECT dept_no, SUM(salary)
    FROM employee;
    Here, the SQL1 and SQL2, both should give me same outputs without an error.
    I am unable to understand why is this not handled?

    Hi,
    998478 wrote:
    ... If we mix aggregate and non-aggregate values then there must be a GROUP BY clause containing all the non-aggregate values. Why is this not handled by the database/compiler itself? It IS handled by the compiler itself. The compiler handles it by raising an error. The compiler has no way of knowing whether you want to remove something from the SELECT clause, or to add something to the GROUP BY clause, or not to use aggregate functions, or to use more aggregate functions, or some combination of the above. If the compiler re-wrote your code, and did any of these things automatically, it would be wrong more often than it was right, and you would (rightly) be complaining about its behavior.
    For example, this is clearly wrong:
    SELECT    deptno
    ,       job
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ;What is the right way to fix it?
    <h3>1. Remove something from the SELECT clause</h3>
    SELECT    deptno
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ;<h3>2. Add something to the GROUP BY clause</h3>
    SELECT    deptno
    ,       job
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ,         job
    ;<h3>3. Not use aggregate functions</h3>
    SELECT    deptno
    ,       job
    ,       sal
    FROM       scott.emp
    ;<h3>4. Use more aggregate functions</h3>
    SELECT    deptno
    ,       MIN (job)
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ;These aren't all the options, either. For example, the correct fix might be to use analytic functions instead of aggregate functions.
    How can anybody say which of these is right? All of them are the right answer for some problem.
    By the way, saying that everying in the SELECT clause must be an aggregate or in the GROUP BY clause is a bit over-simplified.
    More completely, here are the ABC's of GROUP BY:
    When you use a GROUP BY clause and/or an aggregate function, then everything in the SELECT clause must be:
    (A) an <b>A</b>ggregate function,
    (B) one of the "group <b>B</b>y" expressions,
    (C) a <b>C</b>onstant, or
    (D) something that <b>D</b>epends entirely on the above. (For example, if you "GROUP BY TRUNC(dt)", you can SELECT "TO_CHAR (TRUNC(dt), 'Mon-DD')").
    Edited by: Frank Kulash on Apr 13, 2013 1:44 PM
    Added code examples.

  • Using indexes when using group by clause

    How can I make use of indexes when there is a group by clause in the sql/ pl/sql. Heard that when ever there is a group by clause , sql bypasses use of indexes. Is it true?
    Thanks in advance

    Hi,
    Depending on the query containing the group by, indexes will still be used.
    For example, create a big table based on the all_objects table. Then create an index on the object_type column. Then run this query:
    select count(*), object_type from big_table where object_type != 'PACKAGE' group by object_type
    The execution plan for this query will show the index to be used, the group by does not prevent the optimizer from using an index. Then run this query:
    select count(*), object_type from big_table group by object_type
    The execution plan for this query will show the index not to be used because the whole table - no restrictions - needs to be read to get the result.
    Hope this helps!
    Regards,
    Marco Stuijvenberg
    =
    www.marcostuijvenberg.nl

  • Group by clause and having clause in select

    hi frnds
    plz give me some information of group by and having clause used in select statement with example
    thanks

    The Open SQL statement for reading data from database tables is:
    SELECT      <result>
      INTO      <target>
      FROM      <source>
      [WHERE    <condition>]
      [GROUP BY <fields>]
      [HAVING   <cond>]
      [ORDER BY <fields>].
    The SELECT statement is divided into a series of simple clauses, each of which has a different part to play in selecting, placing, and arranging the data from the database.
    You can only use the HAVING clause in conjunction with the GROUP BY clause.
    To select line groups, use:
    SELECT <lines> <s1> [AS <a1>] <s2> [AS <a2>] ...
                   <agg> <sm> [AS <am>] <agg> <sn> [AS <an>] ...
           GROUP BY <s1> <s2> ....
           HAVING <cond>.
    The conditions <cond> that you can use in the HAVING clause are the same as those in the SELECT clause, with the restrictions that you can only use columns from the SELECT clause, and not all of the columns from the database tables in the FROM clause. If you use an invalid column, a runtime error results.
    On the other hand, you can enter aggregate expressions for all columns read from the database table that do not appear in the GROUP BY clause. This means that you can use aggregate expressions, even if they do not appear in the SELECT clause. You cannot use aggregate expressions in the conditions in the WHERE clause.
    As in the WHERE clause, you can specify the conditions in the HAVING clause as the contents of an internal table with line type C and length 72.
    Example
    DATA WA TYPE SFLIGHT.
    SELECT   CONNID
    INTO     WA-CONNID
    FROM     SFLIGHT
    WHERE    CARRID = 'LH'
    GROUP BY CONNID
    HAVING   SUM( SEATSOCC ) > 300.
      WRITE: / WA-CARRID, WA-CONNID.
    ENDSELECT.
    This example selects groups of lines from database table SFLIGHT with the value ‘LH’ for CARRID and identical values of CONNID. The groups are then restricted further by the condition that the sum of the contents of the column SEATSOCC for a group must be greater than 300.
    The <b>GROUP BY</b> clause summarizes several lines from the database table into a single line of the selection.
    The GROUP BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. You can specify the columns in the GROUP BY clause either statically or dynamically.
    Specifying Columns Statically
    To specify the columns in the GROUP BY clause statically, use:
    SELECT <lines> <s1> [AS <a 1>] <s 2> [AS <a 2>] ...
                   <agg> <sm> [AS <a m>] <agg> <s n> [AS <a n>] ...
           GROUP BY <s1> <s 2> ....
    To use the GROUP BY clause, you must specify all of the relevant columns in the SELECT clause. In the GROUP BY clause, you list the field names of the columns whose contents must be the same. You can only use the field names as they appear in the database table. Alias names from the SELECT clause are not allowed.
    All columns of the SELECT clause that are not listed in the GROUP BY clause must be included in aggregate functions. This defines how the contents of these columns is calculated when the lines are summarized.
    Specifying Columns Dynamically
    To specify the columns in the GROUP BY clause dynamically, use:
    ... GROUP BY (<itab>) ...
    where <itab> is an internal table with line type C and maximum length 72 characters containing the column names <s 1 > <s 2 > .....
    Example
    DATA: CARRID TYPE SFLIGHT-CARRID,
          MINIMUM TYPE P DECIMALS 2,
          MAXIMUM TYPE P DECIMALS 2.
    SELECT   CARRID MIN( PRICE ) MAX( PRICE )
    INTO     (CARRID, MINIMUM, MAXIMUM)
    FROM     SFLIGHT
    GROUP BY CARRID.
      WRITE: / CARRID, MINIMUM, MAXIMUM.
    ENDSELECT.
    regards
    vinod

  • How to use User Options and User-Defined Fields in DC Group function?

    Dears,
    As title, when should I use above fields?  I did not see the related information in SAPME help library.
    Thanks!

    The user options fields are just information fields you can store at the Data Collection Maintenance activity. You can think of these as extra information fields for storage purposes only.  I can't give you a use case except to say 'information fields' only.
    With regards to the User-Defined fields in DC Group - you can think of these as extra data fields to be collected.  They will appear immediately underneath the data parameter they are defined in in the DC Plug-in for the POD.  They do not have limits but are just extra pieces of data you may want to collect about the specific parameter.

  • Using regular expressions for validating time fields

    Similar to my problem with converting a big chunk of validation into smaller chunks of functions I am trying to use Regular Expressions to handle the validation of many, many time fields in a flexible working time sheet.
    I have a set of FormCalc scripts to calculate the various values for days, hours and the gain/loss of hours over a four week period. For these scripts to work the time format must be in HH:MM.
    Accessibility guidelines nix any use of message box pop ups so I wanted to get around this by having a hidden/visible field with warning text but can't get it to work.
    So far I have:
    var r = new RegExp(); // Create a new Regular Expression Object
    r.compile ("^[00-99]:\\] + [00-59]");
    var result = r.test(this.rawValue);
    if (result == true){
    true;
    form1.flow.page.parent.part2.part2body.errorMessage.presence = "visible";
    else (result == false){
    false;
    form1.flow.page.parent.part2.part2body.errorMessage.presence = "hidden";
    Any help would be appreciated!

    Date and time fields are tricky because you have to consider the formattedValue versus the rawValue. If I am going to use regular expressions to do validation I find it easier to make them text fields and ignore the time patterns (formattedValue). Something like this works (as far as my very brief testing goes) for 24 hour time where time format is HH:MM.
    // form1.page1.subform1.time_::exit - (JavaScript, client)
    var error = false;
    form1.page1.subform1.errorMsg.rawValue = "";
    if (!(this.isNull)) {
      var time_ = this.rawValue;
      if (time_.length != 5) {
        error = true;
      else {
        var regExp = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
        if (!(regExp.test(time_))) {
          error = true;
    if (error == true) {
      form1.page1.subform1.errorMsg.rawValue = "The time must be in the format HH:MM where HH is 00-23 and MM is 00-59.";
      form1.page1.subform1.errorMsg.presence = "visible";
    Steve

  • Help with Regular Expression for field validation

    I'm fairly new to using regular expressions and using Acrobat. This is probably a simple question, but I've been unable to figure it out.
    I have a text field on a PDF that I would like to be 9 characters in length. The first 2 characters can only be alphanumeric, the last 7 characters can only be numeric.
    At first I was using the following, which allows all the characters to be alphanumeric:
    var re = /^[A-Za-z0-9 :\\_]$/;
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    That works fine, but it's not quite what I needed. With some assistance I changed it (see below) to fit what I was looking for. However, this didn't work; it prevents anything from being entered in the field:
    var re = /^[A-Za-z0-9]{2}\d{7}$/;
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    Any help would be greatly appreciated.
    Thanks...

    Here's a function you can call form the field's custom Format script. It should be placed in a document-level JavaScript:
    function custom_ks1() {
        // Define non-commited regular expression
        var re = /^[A-Za-z0-9]{0,2}([0-9]{0,7})?$/;
        // Get all of the characters the user has entered
        var value = AFMergeChange(event);
        // Allow field to be cleared
        if(!value) return;
        if (event.willCommit) {
            // Define commited regular expression
            var re = /^[A-Za-z0-9]{2}[0-9]{7}$/;
            if (!re.test(value)) {  // If final value doesn't match, alert user
                app.alert("Your error message goes here.");
                // event.rc = false
        } else {  // not commited
            // Only allow characters that match the regular expression
            event.rc = re.test(value);
    Call it like this:
    // Custom Keystroke script
    custom1_ks();

  • How to synchonize the field of Sales group in VN01  from R/3

    Dear  Sir,
    I would like to synchonize the field of Sales group in T-code VN01 in SAP  R/3 to CRM. I can't see the field of Sales group in R/3 , what should I do ??
    Please kindly advise.
    Thank you and best regards,
    Vimol

    Hi,
    To do it in JS you need to use oData, as wrote above:
    to make this requests easer, i use a XrmSvcToolkit library (https://xrmsvctoolkit.codeplex.com/)
    Your code will be about this:
    /// <reference path="rtb_XrmSvcToolkit.js" />
    XrmSvcToolkit.retrieve({
    entityName: "Entity1",
    id: Xrm.Page.getAttribute("quantity").getValue()[0].id,
    select: ["my_FieldNeedToUpdate"], //Here are the name of your fields, which you want to select.
    expand: [""],
    async: false,
    successCallback: function (result) {
    FieldNeedToUpdate= result.my_FieldNeedToUpdate;
    errorCallback: function (error) {
    Error = error;
    FieldNeedToUpdate = FieldNeedToUpdate + 1; //Doing some work here
    var InputEntity =
    my_FieldNeedToUpdate: FieldNeedToUpdate //here are fields, witch you want to update
    XrmSvcToolkit.updateRecord({
    entityName: "Entity1",
    id: Xrm.Page.getAttribute("quantity").getValue()[0].id,
    entity: InputEntity ,
    async: false
    Here are more samples:
    https://xrmsvctoolkit.codeplex.com/SourceControl/latest#Samples/XrvSvcToolkit.Samples.updateRecord.js

  • Free PO indicator in field selection key/group

    Hi all,
    I would like to make Free PO indicator as mandatory field in PO thru specific document type field selection reference key. When I search for the field, it is not available for existing field selection key (Field selection group).
    How can I add the Free PO indicator into this field selection key/group or Does it represented in different name.
    Kindly clarify.
    With regards
    Suddy

    Hi,
    "Free Indicator" doesn't exist in field selection. If you wanto to have Free Indicator ON for a specific PO Document Type then you need to do ABAP Development for this.
    Use BAdi --> ME_PROCESS_PO_CUST
    Interface --> PROCESS_ITEM (Processing of Item Data)
    Below is the Sample Code for your reference;
    If w_bsart EQ 'ZPOD'.
        wa_item3-repos = ' '.
      ELSE.
      ENDIF.

  • Trying to use regular expressions to convert names to Title Case

    I'm trying to change names to their proper case for most common names in North America (esp. the U.S.).
    Some examples are in the comments of the included code below.
    My problem is that *retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");* does not work as I expect. It seems that the toUpperCase method call does not actually do anything to the identified group.
    Everything else works as I expect.
    I'm hoping that I do not have to iterate through each character of the string, upshifting the characters that follow spaces.
    Any help from you RegEx experts will be appreciated.
    {code}
    * Converts names in some random case into proper Name Case. This method does not have the
    * extra processing that would be necessary to convert street addresses.
    * This method does not add or remove punctuation.
    * Examples:
    * DAN MARINO --> Dan Marino
    * old macdonald --> Old Macdonald &lt;-- Can't capitalize the 'D" because of Ernst Mach
    * ROY BLOUNT, JR. --> Roy Blount, Jr.
    * CAROL mosely-BrAuN --> Carol Mosely-Braun
    * Tom Jones --> Tom Jones
    * ST.LOUIS --> St. Louis
    * ST.LOUIS, MO --> St. Louis, Mo &lt;-- Avoid City Names plus State Codes
    * This is a work in progress that will need to be updated as new exceptions are found.
    public static String toNameCase(String name) {
    * Basic plan:
    * 1. Strategically create double spaces in front of characters to be capitalized
    * 2. Capitalize characters with preceding spaces
    * 3. Remove double spaces.
    // Make the string all lower case
    String retName = name.trim().toLowerCase();
    // Collapse strings of spaces to single spaces
    retName = retName.replaceAll("[ ]+", " ");
    // "mc" names
    retName = retName.replaceAll("( mc)", " $1");
    // Ensure there is one space after periods and commas
    retName = retName.replaceAll("(\\.|,)([^ ])", "$1 $2");
    // Add 2 spaces after periods, commas, hyphens and apostrophes
    retName = retName.replaceAll("(\\.|,|-|')", "$1 ");
    // Add a double space to the front of the string
    retName = " " + retName;
    // Upshift each character that is preceded by a space
    // For some reason this doesn't work
    retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");
    // Remove double spaces
    retName = retName.replaceAll(" ", "");
    return retName;
    Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:56 AM
    Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:57 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hopefully someone will still be able to provide a RegEx solution, but until that time here is a working method.
    Also, if people have suggestions of other rules for letter capitalization in names, I am interested in those too.
    * Converts names in some random case into proper Name Case.  This method does not have the
    * extra processing that would be necessary to convert street addresses.
    * This method does not add or remove punctuation.
    * Examples:
    * CAROL mosely-BrAuN --&gt; Carol Mosely-Braun
    * carol o'connor --&gt; Carol O'Connor
    * DAN MARINO --&gt; Dan Marino
    * eD mCmAHON --&gt; Ed McMahon
    * joe amcode --&gt; Joe Amcode         &lt;-- Embedded "mc"
    * mr.t --&gt; Mr. T                    &lt;-- Inserted space
    * OLD MACDONALD --&gt; Old Macdonald   &lt;-- Can't capitalize the 'D" because of Ernst Mach
    * old mac donald --&gt; Old Mac Donald
    * ROY BLOUNT,JR. --&gt; Roy Blount, Jr.
    * ST.LOUIS --&gt; St. Louis
    * ST.LOUIS,MO --&gt; St. Louis, Mo     &lt;-- Avoid City Names plus State Codes
    * Tom Jones --&gt; Tom Jones
    * This is a work in progress that will need to be updated as new exceptions are found.
    public static String toNameCase(String name) {
         * Basic plan:
         * 1.  Strategically create double spaces in front of characters to be capitalized
         * 2.  Capitalize characters with preceding spaces
         * 3.  Remove double spaces.
        // Make the string all lower case
        String workStr = name.trim().toLowerCase();
        // Collapse strings of spaces to single spaces
        workStr = workStr.replaceAll("[ ]+", " ");
        // "mc" names
        workStr = workStr.replaceAll("( mc)", "  $1  ");
        // Ensure there is one space after periods and commas
        workStr = workStr.replaceAll("(\\.|,)([^ ])", "$1 $2");
        // Add 2 spaces after periods, commas, hyphens and apostrophes
        workStr = workStr.replaceAll("(\\.|,|-|')", "$1  ");
        // Add a double space to the front of the string
        workStr = "  " + workStr;
        // Upshift each character that is preceded by a space and remove double spaces
        // Can't upshift using regular expressions and String methods
        // workStr = workStr.replaceAll("( [^ ])([^ ]+)", "$1"toUpperCase() + "$2");
        StringBuilder titleCase = new StringBuilder();
        for (int i = 0; i < workStr.length(); i++) {
            if (workStr.charAt(i) == ' ') {
                if (workStr.charAt(i+1) == ' ') {
                    i += 2;
                while (i < workStr.length() && workStr.charAt(i) == ' ') {
                    titleCase.append(workStr.charAt(i++));
                if (i < workStr.length()) {
                    titleCase.append(workStr.substring(i, i+1).toUpperCase());
            } else {
                titleCase.append(workStr.charAt(i));
        return titleCase.toString();
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Use Granfeldts Create Object to create dynamic groups

    Trying to use Sorens Granfeldts, Create Object WF activity to create dynamic groups.
    In a standard function evaluator activity I generate the Filter as [//WorkflowData/Filter]
    The "string" I set it to is:
    &lt;Filter xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; Dialect=&quot;http://schemas.microsoft.com/2006/11/XPathFilterDialect&quot; xmlns=&quot;http://schemas.xmlsoap.org/ws/2004/09/enumeration&quot;&gt;/Person[ObjectID
    = /*[ObjectID = &apos;8dfcb5e8-ff01-400c-8ca7-2a0002d2d2d4&apos;]/ComputedMember]&lt;/Filter&gt;
    In the CreateObject activity I then just have [//WorkflowData/Filter],Filter among the initial values.
    The creation works if I remove this attribute so the rest of the attributes seems to be working.
    The creation fails however end I get the error below in the Forefront Identity Manager event log.
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.ResourceManagement.WFActivities.Resolver.GetDisplayStringFromGuid(Guid id, String[] expansionAttributes)
       at Microsoft.ResourceManagement.WFActivities.Resolver.ReplaceGuidWithTemplatedString(Match m)
       at System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat)
       at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator)
       at Microsoft.ResourceManagement.WFActivities.Resolver.GetStringAttributeValue(Object attribute)
       at Microsoft.ResourceManagement.WFActivities.Resolver.ResolveEvaluatorWithoutAntiXSS(String match, ResolverOptions resolveOptions)
       at Microsoft.ResourceManagement.WFActivities.Resolver.ResolveEvaluatorForWithAntiXSS(String match, ResolverOptions resolveOptions)
       at Microsoft.ResourceManagement.WFActivities.Resolver.ReplaceMatches(String input, Boolean useAntiXssEncoding, ResolverOptions resolveOptions)
       at Microsoft.ResourceManagement.Workflow.Hosting.ResolverEvaluationServiceImpl.ResolveLookupGrammar(Guid requestId, Guid targetId, Guid actorId, Dictionary`2 workflowDictionary, Boolean encodeForHTML, String expression)
       at Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.Execute(ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
       at System.Workflow.Runtime.Scheduler.Run()
    Have anyone used this WF activity to create dynamic groups and can tell how to set the Filter?

    Hey Kent!
    I did the same thing, with Søren`s Create Object WF. I did it like this on the filter part:
    <Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Dialect="http://schemas.microsoft.com/2006/11/XPathFilterDialect" xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration">/Person[(Department = '[//Target/ObjectID]')]</Filter>,Filter
    The whole thing looks like this:
    (I use Function evaluator to generate a AccountName for groups based on a clean version of DisplayName).
    [//Target/DisplayName],DisplayName
    SEC_[//WorkFlowData/CleanAccountName],AccountName
    [//Target/Manager],Owner
    Security,Type
    DOMAIN_STRING,Domain
    Universal,Scope
    [//Target/DisplayName]_SecGroup,Description
    [//Target/Manager],DisplayedOwner
    None,MembershipAddWorkflow
    True,MembershipLocked
    [//Target/CleanAccountName],MailNickname
    <Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Dialect="http://schemas.microsoft.com/2006/11/XPathFilterDialect" xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration">/Person[(Department = '[//Target/ObjectID]')]</Filter>,Filter
    Regards, Remi www.iamblogg.com

  • More than one user "using an expression" in a BPM Task

    Hello,
    I want to send a notification step for multiple users. I see two options
    1. Choose one or more UME principals.
    2. Use an expression.
    However I have to send the notification for more than one user using an expression. I'm using this expression, 
    getPrincipal(DO_xyz)
    but this only works for one user. I need something like this
    getPrincipal(DO_xyz);  getPrincipal(DO_xyz2);  getPrincipal(DO_xyz3)
    But this is not possible. I can't use a group because all this information is dynamic and it's born within the process.
    Please, How can I solve this?
    Best Regards
    SU

    Hello Abhijeet,
    I've seen that I can use the getPrincipals adding in the XSD an string with 1..* cardinality. However I don't know how to map an attribute from the UITask to that new attribute in the XSD because in Web Dynpro I can't create an string with cardinality 1..*
    I've tried to create a node (1..*) with a String inside in the UI but I couldn't map it to the process context, it shows me an error that I cannot map a node to a String.
    Thanks
    Regards
    SU

  • Using AP Express for Printing ONLY

    Hey Discussions,
    I want to purchase an Airport Express for the sole purpose (right now) of printing. Is it possible to use the Express without an Internet connection?
    Thanks,
    Mateo

    Yes, you can use it as a client to an existing wireless network for printing or streaming iTunes.
    AirPort Express Base Station (AX) - Client Mode Setup
    - Plug the AX into a power outlet.
    - On your computer, join the wireless network created by AX.
    - Open AirPort Admin Utility. (Mac users: Find it in /Applications/Utilities/. Windows users: On the Start menu, point to All Programs and click AirPort.)
    - After AirPort Admin Utility opens, the name of your AX appears in the list. Select it, then click Configure.
    - Enter the administrator password if prompted.
    - Click the AirPort tab.
    - Enter a name for your AX in the Name field. (This name is how it will appear in AirPort Admin Utility; it may be different from the AirTunes remote speaker name. (Note that AirPort Setup Assistant does not allow you to differentiate these names, but AirPort Admin Utility does.)
    - If your AX does not already have an administrator password, click the Change Password button to enter one. This password can be different from any network password, and is used for just changing settings on AX.
    - In the same pane, under the AirPort Network heading, change the Wireless Mode from "Create a Wireless Network (Home Router)" to "Join an Existing Wireless Network (Wireless Client)."
    - Type the name of the wireless network you want to join in the Network Name field. (Note: If you're using AirPort Admin Utility in Mac OS X, you may be able to choose the network from a pop-up menu. This is the name (or SSID) of your current wireless network with the Trendnet router.)
    - If the wireless network is password protected, you will need to enter the password. (Mac users: Click Security Options, choose the level of password encryption from the Wireless Security pop-up menu, then enter the password. When finished, click OK. Windows users: Click Wireless Security, choose the level of password encryption from the Wireless Security menu, then click "Set WEP Password" to enter the password. When finished, click OK.)
    - Click the Music tab to enter the name that will appear in iTunes as your AirTunes remote speakers. You can also enter a password to prevent others from streaming music to your speakers.
    - Finally, click Update to send your new settings to AX.
    Once the AX has had a minute or so to restart, it should join the existing wireless network, as indicated by its status light turning solid green.

  • How to addthe field 'external material group' in MM60 from material master

    Hi
    In MM60, I need to include the field 'external material group' from material master
    How can I do this?
    Is there any other report that gives me this information with material code?
    please help
    Regards,
    shetty

    >
    shetty123s wrote:
    > Hi
    >
    > In MM60, I need to include the field 'external material group' from material master
    >
    > How can I do this?
    >
    > Is there any other report that gives me this information with material code?
    >
    > please help
    >
    > Regards,
    > shetty
    Not possible in MM60.
    Develop a report using table MARA with field EXTWG

Maybe you are looking for