I' ve got this string:  DealerCode = [MAZ3].AccountID:[4340].StartDate=[2015-06-01]  select parsename('DealerCode = [MAZ3].AccountID:[4340].StartDate=[2015-06-01]', 1)    and so on gives me null. How should i change my query to get values between dots?
3756
Using SQL Server, how do I split a string so I can access item x?  Take a string "Hello John Smith". How can I split the string by space and access the item at index 1 which should return "John"?
52590
When I have a Set of Id's and I want to do a dynamic SOQL query that I want to use it in for an IN comparison, I have to convert the Set to string in the format of:  ('id1','id2',id3',...)   The way I do it works, but is not particularly elegant, so I'm wondering if anyone has come up with a better way. Am I missing something? Is there something out there that can just turn a set or list into the properly formatted string?   Here's my code (yes, my example isn't dynamic SOQL, but I've used this several times in dynamic SOQL):   Map&lt;Id,Account&gt; accts = new Map&lt;Id,Account&gt;([select Id from Account]);  String idString = '(\''; for (Id thisId : accts.keyset()) {     idString += thisId + '\',\''; } idString = idString.substring(0,idString.length()-2); //&lt;--this is the bit I hate doing idString += ')';  String q = 'select id from Contact where AccountId in ' + idString;  List&lt;Contact&gt; cts = Database.query(q);
70279
I have the following in a file Output.dat. I need to extract the value between dn: uid= and ,ou=  dn: uid=user1,ou=Active,ou=Member,dc=domain,dc=org  dn: uid=user2@abc.com,ou=Active,ou=Member,dc=domain,dc=org  dn: uid=usertest,ou=Active,ou=Member,dc=domain,dc=org  dn: uid=abc1,ou=Active,ou=Member,dc=domain,dc=org   I tried using sed -e '/dn: uid=/,/,ou=/p' output.dat but  it returns complete line instead of value. When tried to use sed -e '/dn: uid=/,/,ou=/\1/p' output.dat  then got the following error: sed: -e expression #1, char 18: unknown command: `\'
34626
the soql in the following code is failing. The error message is: "Compile failure on line 6, column 5: Unexpected token '&lt;'."   Map&lt;Id, String&gt; profileIds = new Map&lt;Id, String&gt;(); profileIds.put('00eee000000xxxx','System Administrator'); profileIds.put('00eee00000yyyyy','YYY Profile'); profileIds.put('00eee00000zzzzz','ZZZ Profile');  List&lt;User&gt; users = [SELECT Id, Name, Email, ProfileId FROM User WHERE NOT(Email like '%@example.com') AND ProfileId NOT IN :profileIds.keySet()]; System.debug(users.size()); for (User usr: users) {     System.debug(usr.id+'    '+usr.Email); }   When I run the Query in SOQL Editor, it says "unexpected token: AND"  SELECT Id, Name, Email, ProfileId FROM User WHERE NOT(Email like '%@example.com') AND  ProfileId NOT IN ('00eee000000xxxx','00eee00000yyyyy','00eee000000zzzz')   When I remove one of the clauses from the where statement, it works. I do not understand whats wrong with the query. I tried wrapping the query with in parenthesis too, but no luck. for example   List&lt;User&gt; users = [SELECT Id, Name, Email, ProfileId FROM User WHERE (NOT(Email like '%@example.com') AND ProfileId NOT IN :profileIds.keySet())];  List&lt;User&gt; users = [SELECT Id, Name, Email, ProfileId FROM User WHERE (NOT(Email like '%@example.com') AND (ProfileId NOT IN :profileIds.keySet()))];
103584
I have a question regarding this Split String function Aaron Bertrand recommends .  With it you can extract information between two slashes. Now if I want to extract not only one piece of info like the servername, but also a second piece like the day of the week. How would I have to rewrite the code in order to get that info in one result set?  Here's a sample of my data  E:\BaseData\RUK\HPP_Conversion_Detail\hpp_conversion_detail_report_2015_11_02.csv E:\BaseData\RUK\Manual_Review\manual_review_report_2015_11_01.csv E:\BaseData\RUK\Disputes\dispute_report_2015_11_01.csv E:\BaseData\RSE\HPP_Conversion_Detail\hpp_conversion_detail_report_2015_11_02.csv E:\BaseData\RSE\Manual_Review\manual_review_report_2015_11_01.csv E:\BaseData\RSE\Disputes\dispute_report_2015_11_01.csv   I'm interested in everything between the second and third slash and the third and fourth slash. What Geoff suggested is a good idea. I'm then getting the results in rows. Is it possible to get the results back in additional columns?  Thanks!
44986
I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?
78597
I keep getting the System.NullPointerException: Attempt to de-reference a null object on my trigger at line 21. I've attempted to add != null to that line and I get an error too. Please see the code below.  trigger UpdateDMAAccount on Account (before insert, before update) { //get set of Postal Codes from leads to be inserted or updated Set&lt;String&gt; BillingpostalCodes = new Set&lt;String&gt;(); for(Account l : trigger.new){ if(l.BillingPostalCode != null){     BillingpostalCodes.add(l.BillingPostalCode);  } } if(BillingpostalCodes.size() &gt; 0){ //create Map of custom object records with Name (PostalCode) as key Map&lt;String,DMA_Value__c&gt; validBillingPostalCode = new Map&lt;String,DMA_Value__c&gt;(); for(DMA_Value__c obj : [SELECT Id, Name, DMA_Value__c FROM DMA_Value__c WHERE Name IN :BillingpostalCodes]){     validBillingPostalCode.put(obj.Name,obj); } for(Account l : trigger.new){     if((Trigger.isInsert || trigger.oldMap.get(l.Id).BillingPostalCode != l.BillingPostalCode) &amp;&amp; validBillingPostalCode.containsKey(l.BillingPostalCode)){          l.DMA__c = validBillingPostalCode.get(l.BillingPostalCode).DMA_Value__c;     }     else if(trigger.oldMap.get(l.Id).BillingPostalCode != NULL || l.BillingPostalCode &amp;&amp; !validBillingPostalCode.containsKey(l.BillingPostalCode)){         //blank value if new PostalCode does not match a record in the Map         l.DMA__c = Null;     }   }  } }
101419
I've got a string in .NET which is actually a URL.  I want an easy way to get the value from a particular parameter. Normally, I'd just use Request.Params[&quot;theThingIWant&quot;], but this string isn't from the request.  I can create a new Uri item like so: Uri myUri = new Uri(TheStringUrlIWantMyValueFrom);  I can use myUri.Query to get the query string...but then I apparently have to find some regexy way of splitting it up. Am I missing something obvious, or is there no built in way to do this short of creating a regex of some kind, etc?
119807
I am trying to retrieve list items using date range based on date column. It implicit both 'Fromdate' and 'Todate'.My CAML query is also querying on two other conditions as well. I am using the below query but it is not retrieving the data.when I remove the date range from query data is retrieved fine. But i want date range as well in my query how would i do this. Little help would work for me.   camlQuery.set_viewXml('&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;And&gt;&lt;Neq&gt;&lt;FieldRef Name="ID" /&gt;&lt;Value Type="Number"&gt;0&lt;/Value&gt;&lt;/Neq&gt;&lt;Eq&gt;&lt;FieldRef Name="_ModerationStatus" /&gt;&lt;Value Type="ModStat"&gt;0&lt;/Value&gt;&lt;/Eq&gt;&lt;Geq&gt;&lt;FieldRef Name="Created" /&gt;&lt;Value Type="DateTime"&gt;' + fromDate + '&lt;/Value&gt;&lt;/Geq&gt;&lt;Leq&gt;&lt;FieldRef Name="Created" /&gt;&lt;Value Type="DateTime"&gt;' + toDate + '&lt;/Value&gt;&lt;/Leq&gt;&lt;/And&gt;&lt;/And&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name="_ModerationStatus" Ascending="True" /&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;');
102402
I'm wanting to parse a string into a nullable int in C#.  ie. I want to get back either the int value of the string or null if it can't be parsed.  I was kind of hoping that this would work  int? val = stringVal as int?;   But that won't work, so the way I'm doing it now is I've written this extension method  public static int? ParseNullableInt(this string value) {     if (value == null || value.Trim() == string.Empty)     {         return null;     }     else     {         try         {             return int.Parse(value);         }         catch         {             return null;         }     } }      Is there a better way of doing this?  EDIT:  Thanks for the TryParse suggestions, I did know about that, but it worked out about the same.  I'm more interested in knowing if there is a built-in framework method that will parse directly into a nullable int?
42437
I've been trying to optimize my code to make it a little more concise and readable and was hoping I wasn't causing poorer performance from doing it.  I think my changes might have slowed down my application, but it might just be in my head.  Is there any performance difference between:  Command.Parameters["@EMAIL"].Value = email ?? String.Empty;   and  Command.Parameters["@EMAIL"].Value = (email == null) ? String.Empty: email;   and  if (email == null) {     Command.Parameters["@EMAIL"].Value = String.Empty } else {     Command.Parameters["@EMAIL"].Value = email }   My preference for readability would be the null coalescing operator, I just didn't want it to affect performance.
74148
Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it?  For example I would like the following  select * from users where name = 'Paul'   be changed to something like this  select *  from users where    name = 'Paul'   The exact formatting is not important. I just need something to take a large SQL string and break it up into something more readable.
75988
This question comes up occasionally, but I haven't seen a satisfactory answer.  A typical pattern is (row is a DataRow):   if (row["value"] != DBNull.Value)  {       someObject.Member = row["value"];  }   My first question is which is more efficient (I've flipped the condition):    row["value"] == DBNull.Value; // Or   row["value"] is DBNull; // Or   row["value"].GetType() == typeof(DBNull) // Or... any suggestions?    indicates that .GetType() should be faster, but maybe the compiler knows a few tricks I don't?  Second question, is it worth caching the value of row["value"] or does the compiler optimize the indexer away anyway?  For example:    object valueHolder;   if (DBNull.Value == (valueHolder = row["value"])) {}   Notes:   row["value"] exists. I don't know the column index of the column (hence the column name lookup). I'm asking specifically about checking for DBNull and then assignment (not about premature optimization, etc.).   I benchmarked a few scenarios (time in seconds, 10,000,000 trials):  row["value"] == DBNull.Value: 00:00:01.5478995 row["value"] is DBNull: 00:00:01.6306578 row["value"].GetType() == typeof(DBNull): 00:00:02.0138757   Object.ReferenceEquals has the same performance as "=="  The most interesting result? If you mismatch the name of the column by case (for example, "Value" instead of "value", it takes roughly ten times longer (for a string):  row["Value"] == DBNull.Value: 00:00:12.2792374   The moral of the story seems to be that if you can't look up a column by its index, then ensure that the column name you feed to the indexer matches the DataColumn's name exactly.  Caching the value also appears to be nearly twice as fast:  No Caching: 00:00:03.0996622 With Caching: 00:00:01.5659920   So the most efficient method seems to be:   object temp;  string variable;  if (DBNull.Value != (temp = row["value"]))  {       variable = temp.ToString();  }
103863
I'm trying to get the ID of a lookup field when using search api. My query looks something like this:  /_api/Search/query?querytext='ListId:12345678-1234-1234-1234-123456789012'&amp;selectproperties='Title,Company'   Where Company is the lookup field, in a specific list.  The result looks like this:  &lt;d:element m:type="SP.KeyValue"&gt;   &lt;d:Key&gt;Company&lt;/d:Key&gt;   &lt;d:Value&gt;Some company&lt;/d:Value&gt;   &lt;d:ValueType&gt;Edm.String&lt;/d:ValueType&gt; &lt;/d:element&gt;   I have created a managed property which looks like this:
113557
When using views to display start and end date by default it adds "to" text in between two dates, I was wondering what is the appropriate way to convert "to" to "-" or anything else.  Thanks
8231
Simple one really.  In SQL, if I want to search a text field for a couple of characters, I can do:  SELECT blah FROM blah WHERE blah LIKE '%text%'   The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem?
116653
I have this:  If String.IsNullOrEmpty(editTransactionRow.pay_id.ToString()) = False Then     stTransactionPaymentID = editTransactionRow.pay_id 'Check for null value End If   Now, when editTransactionRow.pay_id is Null Visual Basic throws an exception. Is there something wrong with this code?