Search Results

Search found 28627 results on 1146 pages for 'case statement'.

Page 35/1146 | < Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >

  • how to reuse a CASE in the WHERE ?

    - by Thibault Witzig
    Hello I'm trying to do a request that looks like this SELECT field1, field2, field3 = CASE WHEN field2 = 'something' THEN 'something' WHEN field1 IS NOT NULL and field2 IS NULL THEN 'somethingElse' ELSE NULL END FROM SomeTable WHERE field3 IS NOT NULL This results in a syntax error. I have to rewrite the CASE in the WHERE instead of just refering to it. Is there a better way to achieve this ? And out of curiosity, why is "WHERE field3 IS NOT NULL" refused while for example "ORDER BY field3" would pass ?

    Read the article

  • SQL SERVER – Implementing IF … THEN in SQL SERVER with CASE Statements

    - by Pinal Dave
    Here is the question I received the other day in email. “I have business logic in my .net code and we use lots of IF … ELSE logic in our code. I want to move the logic to Stored Procedure. How do I convert the logic of the IF…ELSE to T-SQL. Please help.” I have previously received this answer few times. As data grows the performance problems grows more as well. Here is the how you can convert the logic of IF…ELSE in to CASE statement of SQL Server. Here are few of the examples: Example 1: If you are logic is as following: IF -1 < 1 THEN ‘TRUE’ ELSE ‘FALSE’ You can just use CASE statement as follows: -- SQL Server 2008 and earlier version solution SELECT CASE WHEN -1 < 1 THEN 'TRUE' ELSE 'FALSE' END AS Result GO -- SQL Server 2012 solution SELECT IIF ( -1 < 1, 'TRUE', 'FALSE' ) AS Result; GO If you are interested further about how IIF of SQL Server 2012 works read the blog post which I have written earlier this year . Well, in our example the condition which we have used is pretty simple but in the real world the logic can very complex. Let us see two different methods of how we an do CASE statement when we have logic based on the column of the table. Example 2: If you are logic is as following: IF BusinessEntityID < 10 THEN FirstName ELSE IF BusinessEntityID > 10 THEN PersonType FROM Person.Person p You can convert the same in the T-SQL as follows: SELECT CASE WHEN BusinessEntityID < 10 THEN FirstName WHEN BusinessEntityID > 10 THEN PersonType END AS Col, BusinessEntityID, Title, PersonType FROM Person.Person p However, if your logic is based on multiple column and conditions are complicated, you can follow the example 3. Example 3: If you are logic is as following: IF BusinessEntityID < 10 THEN FirstName ELSE IF BusinessEntityID > 10 AND Title IS NOT NULL THEN PersonType ELSE IF Title = 'Mr.' THEN 'Mister' ELSE 'No Idea' FROM Person.Person p You can convert the same in the T-SQL as follows: SELECT CASE WHEN BusinessEntityID < 10 THEN FirstName WHEN BusinessEntityID > 10 AND Title IS NOT NULL THEN PersonType WHEN Title = 'Mr.' THEN 'Mister' ELSE 'No Idea' END AS Col, BusinessEntityID, Title, PersonType FROM Person.Person p I hope this solution is good enough to convert the IF…ELSE logic to CASE Statement in SQL Server. Let me know if you need further information about the same. Reference: Pinal Dave (http://blog.sqlauthority.com)Filed under: PostADay, SQL, SQL Authority, SQL Function, SQL Query, SQL Server, SQL Tips and Tricks, T SQL

    Read the article

  • How to determine the correct (case sensitive) URL for a SharePoint site

    - by Goyuix
    SharePoint is generally very tolerant of accepting a URL in a case-insensitive fashion, however there are a few cases where it completely breaks down. For example, when creating a site column it somehow stores and uses the URL when it was created, and when trying to edit the field definition through the Site Column Gallery (fldedit.aspx page in the LAYOUTS) you end up throwing the error below. Value does not fall within the expected range. at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName, Boolean bThrowException) at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName) at Microsoft.SharePoint.ApplicationPages.BasicFieldEditPage.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) How can I reliably get the correct URL for a site/web? The SPSite.Url and SPWeb.Url properties seem to return back whatever case they are instantiated with. In other words, the site collection is provisioned using the following URL: http://server/Path/Site If I create a new Site Column using the SharePoint object model and happen to use http://server/path/site when instantiating the SPSite and SPWeb objects, the site column will be made available but when trying to access it through the gallery the error above is generated. If I correct the URL in the address bar, I can still view/modify the definition for the SPField in question, but the default URL that is generated is bogus. Clear as mud? Example code: (this is a bad example because of the case sensitivity issue) // note: site should be partially caps: http://server/Path/Site using (SPSite site = new SPSite("http://server/path/site")) { using (SPWeb web = site.OpenWeb()) { web.Fields.AddFieldAsXml("..."); // correct XML really here } }

    Read the article

  • NSPredicate case-insensitive matching on to-many relationship

    - by Brian Webster
    I am implementing a search field where the user can type in a string to filter the items displayed in a view. Each object being displayed has a keywords to-many relationship, and I would like to be able to filter the objects based on their keywords. Each keyword object has a name property, so I've set up an NSPredicate to do the filtering that looks like this: NSPredicate* predicate = [NSPredicate predicateWithFormat:@"keywords.name CONTAINS %@", self.searchString]; This works, but the problem is that the search is case-sensitive, so if the keyword has a capital letter but the user types in all lowercase, no matches are found. I've tried the following modification: NSPredicate* predicate = [NSPredicate predicateWithFormat:@"keywords.name CONTAINS[c] %@", self.searchString]; But that doesn't make any difference in the case sensitivity of the matching. Is there a way to do this case-insensitive matching using just a plain predicate? Or will I need to implement some sort of custom accessor on the keyword class, e.g. write a lowercaseName method and match against a lowercased version of the search string instead? Addendum: After further exploration, the workaround of adding a custom accessor works OK for manual use of NSPredicate, but does not work at all when using NSFetchRequest with Core Data, which only works when querying attributes defined in the Core Data model.

    Read the article

  • How does this Switch statement know which case to execute? (PHP/MySQL)

    - by ggfan
    Here is a code form a PHP+MySQL book I am reading and I am having trouble understanding this code. This code is about checking a file uploaded into a database. (Please excuse any spelling errors if any, I was typing it in) Q1: How does it know which case to echo? In the whole code, there is no mention of each case. Q2: Why do they skip case 5?! Or does it not matter which numbers you use(so I can have case 1, case 18, case 2?) if($_FILES['userfile']['error']>0) { echo 'Problem: '; switch($_FILES['userfile']['error']) { case 1: echo 'File exceeded upload_max_filesize'; break; case 2: echo 'File exceeded max_file_size'; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; case 6: echo 'Cannot upload file: no temp directory specified'; break; case 7: echo 'Upload failed: Cannot write to disk'; break; } exit; }

    Read the article

  • AStar in a specific case in C#

    - by KiTe
    Hello. To an intership, I have use the A* algorithm in the following case : the unit shape is a square of height and width of 1, we can travel from a zone represented by a rectangle from another, but we can't travel outside these predifined areas, we can go from a rectangle to another through a door, represented by a segment on corresponding square edge. Here are the 2 things I already did but which didn't satisfied my boss : 1 : I created the following classes : -a Door class which contains the location of the 2 separated squares and the door's orientation (top, left, bottom, right), -a Map class which contains a door list, a rectangle list representing the walkable areas and a 2D array representing the ground's squares (for additionnal infomations through an enumeration) - classes for the A* algorithm (node, AStar) 2 : -a MapCase class, which contains information about the case effect and doors through an enumeration (with [FLAGS] attribute set on, to be able to cummulate several information on each case) -a Map classes which only contains a 2D array of MapCase classes - the classes for the A* algorithm (still node an AStar). Since the 2 version is better than the first (less useless calculation, better map classes architecture), my boss is not still satisfied about my mapping classes architecture. The A* and node classes are good and easily mainainable, so I don't think I have to explain them deeper for now. So here is my asking : has somebody a good idea to implement the A* with the problem specification (rectangle walkable but with a square unit area, travelling through doors)? He said that a grid vision of the problem (so a 2D array) shouldn't be the correct way to solve the problem. I wish I've been clear while exposing my problem .. Thanks KiTe

    Read the article

  • Can I store SQL Server sort order in a variable?

    - by Steve Weet
    I have the following SQL within a stored procedure. Is there a way to remove the IF statement and pass the 'ASC'/'DESC' option as a variable? I know I could do the query a number of different ways, or return a table and sort it externally etc. I would just like to know if I can avoid duplicating the CASE statement. IF @sortOrder = 'Desc' BEGIN SELECT * FROM #t_results ORDER BY CASE WHEN @OrderBy = 'surname' THEN surname END DESC, CASE WHEN @OrderBy = 'forename' THEN forename END DESC, CASE WHEN @OrderBy = 'fullName' THEN fullName END DESC, CASE WHEN @OrderBy = 'userId' THEN userId END DESC, CASE WHEN @OrderBy = 'MobileNumber' THEN MSISDN END DESC, CASE WHEN @OrderBy = 'DeviceStatus' THEN DeviceStatus END DESC, CASE WHEN @OrderBy = 'LastPosition' THEN LastPosition END DESC, CASE WHEN @OrderBy = 'LastAlert' THEN LastAlert END DESC, CASE WHEN @OrderBy = 'LastCommunication' THEN LastCommunication END DESC, CASE WHEN @OrderBy = 'LastPreAlert' THEN LastPreAlert END DESC END ELSE BEGIN SELECT * FROM #t_results ORDER BY CASE WHEN @OrderBy = 'surname' THEN surname END DESC, CASE WHEN @OrderBy = 'forename' THEN forename END DESC, CASE WHEN @OrderBy = 'fullName' THEN fullName END DESC, CASE WHEN @OrderBy = 'userId' THEN userId END DESC, CASE WHEN @OrderBy = 'MobileNumber' THEN MSISDN END DESC, CASE WHEN @OrderBy = 'DeviceStatus' THEN DeviceStatus END DESC, CASE WHEN @OrderBy = 'LastPosition' THEN LastPosition END DESC, CASE WHEN @OrderBy = 'LastAlert' THEN LastAlert END DESC, CASE WHEN @OrderBy = 'LastCommunication' THEN LastCommunication END DESC, CASE WHEN @OrderBy = 'LastPreAlert' THEN LastPreAlert END DESC END END

    Read the article

  • Case Insensitive Ternary Search Tree

    - by Yan Cheng CHEOK
    I had been using Ternary Search Tree for a while, as the data structure to implement a auto complete drop down combo box. Which means, when user type "fo", the drop down combo box will display foo food football The problem is, my current used of Ternary Search Tree is case sensitive. My implementation is as follow. It had been used by real world for around 1++ yeas. Hence, I consider it as quite reliable. My Ternary Search Tree code However, I am looking for a case insensitive Ternary Search Tree, which means, when I type "fo", the drop down combo box will show me foO Food fooTBall Here are some key interface for TST, where I hope the new case insentive TST may have similar interface too. /** * Stores value in the TernarySearchTree. The value may be retrieved using key. * @param key A string that indexes the object to be stored. * @param value The object to be stored in the tree. */ public void put(String key, E value) { getOrCreateNode(key).data = value; } /** * Retrieve the object indexed by key. * @param key A String index. * @return Object The object retrieved from the TernarySearchTree. */ public E get(String key) { TSTNode<E> node = getNode(key); if(node==null) return null; return node.data; } An example of usage is as follow. TSTSearchEngine is using TernarySearchTree as the core backbone. Example usage of Ternary Search Tree // There is stock named microsoft and MICROChip inside stocks ArrayList. TSTSearchEngine<Stock> engine = TSTSearchEngine<Stock>(stocks); // I wish it would return microsoft and MICROCHIP. Currently, it just return microsoft. List<Stock> results = engine.searchAll("micro");

    Read the article

  • Scala: Correcting type inference of representation type over if statement

    - by drhagen
    This is a follow-up to two questions on representation types, which are type parameters of a trait designed to represent the type underlying a bounded type member (or something like that). I've had success creating instances of classes, e.g ConcreteGarage, that have instances cars of bounded type members CarType. trait Garage { type CarType <: Car[CarType] def cars: Seq[CarType] def copy(cars: Seq[CarType]): Garage def refuel(car: CarType, fuel: CarType#FuelType): Garage = copy( cars.map { case `car` => car.refuel(fuel) case other => other }) } class ConcreteGarage[C <: Car[C]](val cars: Seq[C]) extends Garage { type CarType = C def copy(cars: Seq[C]) = new ConcreteGarage(cars) } trait Car[C <: Car[C]] { type FuelType <: Fuel def fuel: FuelType def copy(fuel: C#FuelType): C def refuel(fuel: C#FuelType): C = copy(fuel) } class Ferrari(val fuel: Benzin) extends Car[Ferrari] { type FuelType = Benzin def copy(fuel: Benzin) = new Ferrari(fuel) } class Mustang(val fuel: Benzin) extends Car[Mustang] { type FuelType = Benzin def copy(fuel: Benzin) = new Mustang(fuel) } trait Fuel case class Benzin() extends Fuel I can easily create instances of Cars like Ferraris and Mustangs and put them into a ConcreteGarage, as long as it's simple: val newFerrari = new Ferrari(Benzin()) val newMustang = new Mustang(Benzin()) val ferrariGarage = new ConcreteGarage(Seq(newFerrari)) val mustangGarage = new ConcreteGarage(Seq(newMustang)) However, if I merely return one or the other, based on a flag, and try to put the result into a garage, it fails: val likesFord = true val new_car = if (likesFord) newFerrari else newMustang val switchedGarage = new ConcreteGarage(Seq(new_car)) // Fails here The switch alone works fine, it is the call to ConcreteGarage constructor that fails with the rather mystical error: error: inferred type arguments [this.Car[_ >: this.Ferrari with this.Mustang <: this.Car[_ >: this.Ferrari with this.Mustang <: ScalaObject]{def fuel: this.Benzin; type FuelType<: this.Benzin}]{def fuel: this.Benzin; type FuelType<: this.Benzin}] do not conform to class ConcreteGarage's type parameter bounds [C <: this.Car[C]] val switchedGarage = new ConcreteGarage(Seq(new_car)) // Fails here ^ I have tried putting those magic [C <: Car[C]] representation type parameters everywhere, but without success in finding the magic spot.

    Read the article

  • Make password case unsensitive in shared ASP.Net membership tables web ap

    - by bill
    Hi all, i have two webapps.. that share ASP.Net membership tables. Everything works fine except i cannot remove case-sensitivity in one of the apps the way i am doing it in the other. in the non-working app void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { string username = Login1.UserName.Trim(); if (!string.IsNullOrEmpty(username)) { MembershipUser user = Membership.GetUser(username); if (user != null) { // Only adjust the UserName if the password is correct. This is more secure // so a hacker can't find valid usernames if we adjust the case of mis-cased // usernames with incorrect passwords. string password = Login1.Password.ToUpper(); if (Membership.ValidateUser(user.UserName, password)) { Login1.UserName = user.UserName; } } } } is not working. the password is stored as all upper case. Converted at the time the membership user is created! So if the password is PASSWORD, typing PASSWORD allows me to authenticate. but typing password does not! Even though i can see the string being sent is PASSWORD (converted with toUpper()). I am at a complete loss on this.. in the other app i can type in lower or upper or mixed and i am able to authenticate. In the other app i am not using the textboxes from the login control though.. not sure if this is making the difference??

    Read the article

  • C++: Case statement within while loop?

    - by Jason
    I just started C++ but have some prior knowledge to other languages (vb awhile back unfortunately), but have an odd predicament. I disliked using so many IF statements and wanted to use switch/cases as it seemed cleaner, and I wanted to get in the practice.. But.. Lets say I have the following scenario (theorietical code): while(1) { //Loop can be conditional or 1, I use it alot, for example in my game char something; std::cout << "Enter something\n -->"; std::cin >> something; //Switch to read "something" switch(something) { case 'a': cout << "You entered A, which is correct"; break; case 'b': cout << "..."; break; } } And that's my problem. Lets say I wanted to exit the WHILE loop, It'd require two break statements? This obviously looks wrong: case 'a': cout << "You entered A, which is correct"; break; break; So can I only do an IF statement on the 'a' to use break;? Am I missing something really simple? This would solve a lot of my problems that I have right now.

    Read the article

  • C++: Switch statement within while loop?

    - by Jason
    I just started C++ but have some prior knowledge to other languages (vb awhile back unfortunately), but have an odd predicament. I disliked using so many IF statements and wanted to use switch/cases as it seemed cleaner, and I wanted to get in the practice.. But.. Lets say I have the following scenario (theorietical code): while(1) { //Loop can be conditional or 1, I use it alot, for example in my game char something; std::cout << "Enter something\n -->"; std::cin >> something; //Switch to read "something" switch(something) { case 'a': cout << "You entered A, which is correct"; break; case 'b': cout << "..."; break; } } And that's my problem. Lets say I wanted to exit the WHILE loop, It'd require two break statements? This obviously looks wrong: case 'a': cout << "You entered A, which is correct"; break; break; So can I only do an IF statement on the 'a' to use break;? Am I missing something really simple? This would solve a lot of my problems that I have right now.

    Read the article

  • Motherboard Wiring

    - by JT
    HI All, I bought a new case to put a motherboard in. Everything fits, I have done this before, but not in a long time! The case has wires for - Power SW - Reset SW - Power LED - HDD LED On the motherboard (ASUS M2NPV-VM) it is clearly labeled where these go, but I cannot remember where the black wire for each goes versus the colored wire? I don't want to put it backwards, wont I blow the motherboard?

    Read the article

  • Who uses Zimbra Collaboration Suite and why?

    - by AlberT
    I am really curious about other people experiences and choices. After a long scouting, I found ZCS to be a really impressive solution, maybe the only real alternative to M$ Exchange. I'm very interested in opinions and case histories from users having already deployed Zimbra on their infrastructure or planning to do it. Both Community and Network edition cases are appreciated, pro and cons explained too :) Zimlets, addons, useful skins, Zimbra Desktop and other apps or mobile integration use case too of course.

    Read the article

  • Use the &ldquo;using&rdquo; statement on objects that implement the IDisposable Interface

    - by mbcrump
    From MSDN : C#, through the .NET Framework common language runtime (CLR), automatically releases the memory used to store objects that are no longer required. The release of memory is non-deterministic; memory is released whenever the CLR decides to perform garbage collection. However, it is usually best to release limited resources such as file handles and network connections as quickly as possible. The using statement allows the programmer to specify when objects that use resources should release them. The object provided to the using statement must implement the IDisposable interface. This interface provides the Dispose method, which should release the object's resources. In my quest to write better, more efficient code I ran across the “using” statement. Microsoft recommends that we specify when to release objects. In other words, if you use the “using” statement this tells .NET to release the object specified in the using block once it is no longer needed.   So Using this block: private static string ReadConfig()         {             const string path = @"C:\SomeApp.config.xml";               using (StreamReader reader = File.OpenText(path))             {                 return reader.ReadToEnd();             }         }   The compiler converts this to: private static string ReadConfig1() {     StreamReader sr = new StreamReader(@"C:\SomeApp.config.xml");       try     {         return sr.ReadToEnd();     }     finally     {         if (sr != null)             ((IDisposable)sr).Dispose();     }   }

    Read the article

  • T4 Toolbox - mixing class feature and statement blocks

    - by Mauricio Scheffer
    I'm a T4 newbie trying to use T4 Toolbox to generate F# code based on this answer, but it seems that class feature blocks can't be mixed with statement blocks. Here's my code: <#@ template language="C#" hostspecific="True" debug="True" #> <#@ output extension="txt" #> <#@ include file="T4Toolbox.tt" #> <# FSharpTemplate template = new FSharpTemplate(); template.Output.Project = @"..\Library1\Library1.fsproj"; template.Output.File = "Module2.fs"; template.Render(); #> <#+ class FSharpTemplate: Template { public override string TransformText() { #> module Module2 <# for (int i = 0; i < 10; i++) { #> <#= i #> <# } #> <#+ return this.GenerationEnvironment.ToString(); } } #> And I get this error: A Statement cannot appear after the first class feature in the template. Only boilerplate, expressions and other class features are allowed after the first class feature block. So... how can I rewrite the template to achieve this?

    Read the article

  • Need help making a check statement to make sure al the controls are not blank

    - by Michael Quiles
    This is for a tic tac toe game. I need help making a check statement to see if all the controls' Texts are non-blank, and if they are, you have a draw (if someone had won the previous code would have discovered that). Can you give me a good example using my code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; namespace MyGame { public class Result1 { static private int[,] Winners = new int[,] { // main gameplay Ex: if x is on 0,1,2 x is the winner {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}, }; static public bool CheckWinner(Button[] myControls) { //bolean statement to check for the winner bool gameOver = false; for (int i = 0; i < 8; i++) { int a = Winners[i, 0]; int b = Winners[i, 1]; int c = Winners[i, 2]; Button b1 = myControls[a], b2 = myControls[b], b3 = myControls[c]; if (b1.Text == "" || b2.Text == "" || b3.Text == "") continue; if (b1.Text == b2.Text && b2.Text == b3.Text) { b1.BackColor = b2.BackColor = b3.BackColor = Color.LightCoral; b1.Font = b2.Font = b3.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Italic & System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); gameOver = true; xWinnerForm xWinnerForm = new xWinnerForm(); xWinnerForm.ShowDialog(); //only works with show not showDialog method gets overloaded (b1.Text + " is the Winner"); to get around this I added and image showing the last player } } return gameOver; } } }

    Read the article

  • Linq to NHibernate wrapper issue using where statement

    - by Jacob
    I'am using wrapper to get some data from table users IQueryable<StarGuestWrapper> WhereQuery = session.Linq<User>().Where(u => u.HomeClub.Id == clubId && u.IsActive).Select( u => new StarGuestWrapper() { FullName = u.Name + " " + u.LastName, LoginTime = DateTime.Now, MonthsAsMember = 2, StarRating = 1, UserPicture = u.Photo.PhotoData, InstructorFullName = "Someone Xyz", TalkInteractionDuringSession = true, GoalInteractionDuringSession = false }); I use this without a problem as a IQueryable so I can do useful things before actually running the query. Like : WhereQuery.Skip(startRowIndex).Take(maximumRows).ToList(); and so on. The problem occurs using 'where' statement on query. For example: WhereQuery.Where(s => s.StarRating == 1) will throw an exception in runtime that 'StarRating' doesn't exist in User table - of course it doesn't it's a wrappers property. I will work if I materialize query by WhereQuery.AsEnumerable().Where(s => s.StarRating == 1) but then it loses all the sens of using IQueryable and I don't want to do this. What is strange and interesting that not all properties from wrapper throw error, all the bool values can be used in where statement. Example : WhereQuery.Where(s => s.TalkInteractionDuringSession) It works in EntityFramework , why do I get this error in NHibernate and how to get it working the way I want it to ?

    Read the article

  • Simple Select Statement on MySQL Database Hanging

    - by AlishahNovin
    I have a very simple sql select statement on a very large table, that is non-normalized. (Not my design at all, I'm just trying to optimize while simultaneously trying to convince the owners of a redesign) Basically, the statement is like this: SELECT FirstName, LastName, FullName, State FROM Activity Where (FirstName=@name OR LastName=@name OR FullName=@name) AND State=@state; Now, FirstName, LastName, FullName and State are all indexed as BTrees, but without prefix - the whole column is indexed. State column is a 2 letter state code. What I'm finding is this: When @name = 'John Smith', and @state = '%' the search is really fast and yields results immediately. When @name = 'John Smith', and @state = 'FL' the search takes 5 minutes (and usually this means the web service times out...) When I remove the FirstName and LastName comparisons, and only use the FullName and State, both cases above work very quickly. When I replace FirstName, LastName, FullName, and State searches, but use LIKE for each search, it works fast for @name='John Smith%' and @state='%', but slow for @name='John Smith%' and @state='FL' When I search against 'John Sm%' and @state='FL' the search finds results immediately When I search against 'John Smi%' and @state='FL' the search takes 5 minutes. Now, just to reiterate - the table is not normalized. The John Smith appears many many times, as do many other users, because there is no reference to some form of users/people table. I'm not sure how many times a single user may appear, but the table itself has 90 Million records. Again, not my design... What I'm wondering is - though there are many many problems with this design, what is causing this specific problem. My guess is that the index trees are just too large that it just takes a very long time traversing the them. (FirstName, LastName, FullName) Anyway, I appreciate anyone's help with this. Like I said, I'm working on convincing them of a redesign, but in the meantime, if I someone could help me figure out what the exact problem is, that'd be fantastic.

    Read the article

  • UITabBarControllerDelegate compare value of viewController

    - by T9
    I have a tabBar with 4 tabs on it, and I want to perform some action when a specific tab is selected, so I have uncommented the UITabBarControllerDelegate in the xxAppDelegate.m I also wanted to see the value that was being sent logged in the console - in order to test my "if" statement. However this is where I got stumped. // Optional UITabBarControllerDelegate method - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"%@", viewController); } The console dutifully logged any selected controller that had been selected, but in this particular format: <MyViewController: 0x3b12950> Now, I wasn't expecting the square brackets or the colon or the Hex. So my question is how do I format my IF statement? This is what I thought would work but I get an error mentioned further down. // Optional UITabBarControllerDelegate method - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"%@", viewController); if (viewController == MyViewController) { //do something nice here … }; } ... The error is "Expected expression before 'MyViewController'" Anyone know how I should be doing this?

    Read the article

  • If statement with dataitems in markup

    - by Eric
    I am trying to write an if statement to decide whether or not to display a field. I'm using a listview. <telerik:RadListView ID="RadListView4" runat="server" ItemPlaceholderID="WitnessPlaceHolder" DataSourceID="SqlDataSource5"> <LayoutTemplate> <asp:PlaceHolder ID="WitnessPlaceHolder" runat="server" /> </LayoutTemplate> <ItemTemplate> <center> <fieldset style="float: left; width: 280px;"> <legend> <%# Eval("title").ToString()%> </legend> <table> <tr> <td align="center"> <%if (DataBinder.Eval(Container.DataItem,"field").Equals("C")) Response.Write(Eval("field"));%> </td> How can I write the above if statement in the markup?? What i have doesn't work.

    Read the article

  • MonoRail ActiveRecord - The UPDATE statement conflicted with the FOREIGN KEY SAME TABLE

    - by Justin
    Hey all, I'm new to MonoRail and ActiveRecord and have inherited an application that I need to modify. I have a Category table (Id, Name) and I'm adding a ParentId FK which references the Id in the same table so that you can have parent/child category relationships. I tried adding this to my Category model class: [Property] public int ParentId { get; set; } I also tried doing it this way: [BelongsTo("ParentId")] public Category Parent { get; set; } When I call a method to get all parent categories (they have a null ParentId), it works fine: public static Category[] GetParentCategories() { var criteria = DetachedCriteria.For<Core.Models.Category>(); return (FindAllByProperty("ParentId", null)); } However, when I call a method to get all child categories within a specific category, it errors out: public static Category[] GetChildCategories(int parentId) { var criteria = DetachedCriteria.For<Core.Models.Category>(); return (FindAllByProperty("ParentId", parentId)); } The error is: "The UPDATE statement conflicted with the FOREIGN KEY SAME TABLE constraint \"FK_Category_ParentId\". The conflict occurred in database \"UCampus\", table \"dbo.Category\", column 'Id'.\r\nThe statement has been terminated." I'm hard-coding in the parentId parameter as 1 and I'm 100% sure it exists as an id in the Category table so I don't know why it'd give this error. Also, I'm doing a select, not an update, so what is going on here?? Thanks for any input on this, Justin

    Read the article

< Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >