Search Results

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

Page 72/1146 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • Invalid Active Record Statement Rails 2.3.16

    - by Ranzit
    I am using rails 2.3.16 ruby 1.8.7 For the following line of code I ma getting error as follows: Code: ForeignScheduledItem.find(:all, :conditions => { :foreign_scheduled_item => { :scheduled_items => { :subscription_id => params[:subscription_id] } } }, :joins => :scheduled_item).each { |i| @subscriptions.push(Subscription.find_by_id(i.subscription_id)) } Error: ActiveRecord::StatementInvalid (ActiveRecord::StatementInvalid): Can u please help in this regard.

    Read the article

  • How to crosscheck two tables and insert relevant data into a new table in MYSQL?

    - by JackDamery
    I'm trying to crosscheck a row that exists in two tables using a MYSQL query in phpmyadmin and then if a userID is found in both tables, insert their userID and user name into another table. Here's my code: INSERT INTO userswithoutmeetings SELECT user.userID IF('user.userID'='meeting.userID'); I keep getting plagued by this error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF('user.userID'='meeting.userID')' at line 3 Other statements I've tried have worked but not deposited the values in the table.

    Read the article

  • "=null" and select statement!

    - by user329820
    Hi I have asked this question before in this forum and they told me that it will retun an empty result set,I want to know that if I set the column with null values it will retun an empty result set?also the ANSI_NULLS is OFF ,thanks SELECT 'A' FROM T WHERE A = NULL;

    Read the article

  • CakePHP ACL use case(s)

    - by Jonathan
    I have got a simple web app in development, i want to establish a couple of user groups; Admin, Doctors & Patients. Each group would have their access restricted to particular controller actions rather than individual content. So for example, Doctors can view patient records (index & view actions), but cannot delete them. Usually i would create a groups model, and assign the various users to a group. And filter in the beforeFilter() method to determine if the user has access. But if ACL can do the job, why right the code, right? Thanks

    Read the article

  • Cannot we use break statement in a lambda(C#3.0)

    - by Newbie
    Consider this List<int> intList = new List<int> { 1, 2, 3, 4, 5, 6 }; int j = 0; intList.ForEach(i => { if (i.Equals(1)) { j = i; break; } } ); Throwing error: No enclosing loop out of which to break or continue But the below works foreach(int i in intList) { j = i; break; } Why so. Am I making any mistake. Thanks

    Read the article

  • Which of these queries is more efficient?

    - by Brian
    Which of these queries are more efficient? select 1 as newAndClosed from sysibm.sysdummy1 where exists ( select 1 from items where new = 1 ) and not exists ( select 1 from status where open = 1 ) select 1 as newAndClosed from items where new = 1 and not exists ( select 1 from status where open = 1 )

    Read the article

  • Prioritize SQL WHERE clause

    - by JaTochNietDan
    Basically I want to do this: SELECT * FROM `table` WHERE x = 'hello' OR x = 'bye' LIMIT 1'; I want it to return 1 value, but to prioritize results from the 1st where clause. So if there exists a row where column x's value is "hello", it will not return the result from the 'bye' value. If the "hello" value doesn't exist though, it will return the result from the 'bye' value. Can't figure out a way to do it even though it seems fairly trivial. Any ideas?

    Read the article

  • Google sheet dynamic WHERE clause for query() statement

    - by jason_cant_code
    I have a data table like so: a 1 a 2 b 3 b 4 c 5 c 6 c 7 I want to pull items out of this table by dynamically telling it what letters to pull. My current formula is: =query(A1:B7,"select * where A ='" & D1 & "'"). D1 being the cell I wish to modify to modify the query. I want to be able input into D1 -- a, a,b, a,b,c and have the query work. I know it would involve or statements in the query, but haven't figured out how to make the formula dynamic. I am looking for a general solution for this pattern: a -- A = 'a' a,b -- A = 'a' or A = 'b' a,b,c -- A = 'a' or A = 'b' or A='c' Or any other solution that solves the problem. Edit: So far I have =ArrayFormula(CONCATENATE("A='"&split(D3,",")&"' or ")) this gives A='a' or A='b' or A='c' or for a,b,c. can't figure out how to remove the last or.

    Read the article

  • foreach statement (get string values)

    - by nhoyti
    Can someone please help me out? My code for splitting the strings is working however, i still need to use the splitted string my page. How can i achieve this? Here's my current code private void SplitStrings() { List<string> listvalues = new List<string>(); listvalues = (List<string>)Session["mylist"]; string[] strvalues = listvalues.ToArray(); if (listvalues != null) { foreach (string strElement in listvalues) { string[] prods = strElement.ToString().Split("|".ToCharArray()); string prodName = prods[0].ToString(); Response.Write(prodName); } } } link text how can i replace the response.write with any label or literal? when i tried to use a literal on the code it displays one single string not all of the strings that's been splitted. any ideas?

    Read the article

  • Else without if

    - by user2808951
    I'm trying to write a code for my computer programming class for a project due Monday, and I'm pretty new to Java, but I'm trying to write a program that will first determine if a number the user inputs is even or odd and then determine if the number is prime or not. I'm not sure if I did the algorithm right or not, so if anyone has any corrections on the program to my algorithm or anything else please say so, but my real issue is that the program is refusing to compile. Every time I try, it says it's having an else without if problem. Here's a link to my command box: http://s1341.photobucket.com/user/Emi_Nightshade/media/Capture_zps45f9a2ea.png.html Here's my code: import java.io.*; import java.util.*; public class Lesson9p1_ThuotteEmily { public static void main(String args[]) { Scanner kbReader0=new Scanner(System.in); System.out.print("\n\nPlease enter an integer. An integer is whole number, and it can be either negative or positive. Please enter your number: "); long num=kbReader0.nextLong(); if(num%2==0) //if and else with braces { System.out.println("Your integer " + num + " is even."); } else { System.out.println("Your integer " + num + " is odd."); } Scanner kbReader1=new Scanner(System.in); System.out.print("\n\nWould you like to know if your number is prime? Please enter yes or no: "); String yn=kbReader1.nextLine(); if(yn.equals.IgnoreCase("Yes")) { System.out.println("Okay. Give me a moment."); { if(num%2==0) { System.out.println("Your number isn't prime."); } else if(num==2) { System.out.println("Your number is 2, which is the only even prime number in existence. Cool, right?"); } for(int i=3;i*i<=n;i+=2) { if(n%1==0) { System.out.println("Your number isn't prime."); } } else { System.out.println("Your number is prime!"); } } } if(yn.equals.IgnoreCase("No")) { System.out.println("Okay."); } } } If anyone could help me out with this and also any problems I may have made elsewhere in the program, I'd be very grateful! Thanks.

    Read the article

  • What is wrong with this sql statement?

    - by chandru_cp
    I am trying to fetch records based on two dates from sql server... Select * from table where CreatedDate between @StartDate and @EndDate and i pass 5/12/2010 and 5/12/2010 (ie) fetching records for today... I have 17 records dated 5/12/2010 but none seems to get selected.... EDIT: I use this but when i debug my value it shows 5/12/2010 12:00:00AM DateTime baseDate = DateTime.Today; var today = baseDate; GetBookingReportByDate(today,today);

    Read the article

  • Unexpected '{' with IF statement

    - by user1926208
    this is my code to move all the files in a directory to another directory which are 1 hour old or more. <?php $srcDir = 'code'; $destDir = 'code/old'; if (file_exists($destDir)) { if (is_dir($destDir)) { if (is_writable($destDir)) { if ($handle = opendir($srcDir)) { while (false !== ($file = readdir($handle))) { if (is_file($srcDir . '/' . $file)) { if(date("U",filectime($srcDir . '/' . $file) >= time() - 3600) { rename($srcDir . '/' . $file, $destDir . '/' . $file); } } } closedir($handle); } else { echo "$srcDir could not be opened.\n"; } } else { echo "$destDir is not writable!\n"; } } else { echo "$destDir is not a directory!\n"; } } else { echo "$destDir does not exist\n"; } ?> and I am getting this error: Parse error: syntax error, unexpected '{' in /home/tcity/public_html/myDir/movefiles.php on line 11

    Read the article

  • Subscript out of bounds on a which statement in R

    - by ahandler
    I have data that looks like this: > head(newdata) zero one real 601 0.01273885 0.9872611 1 602 0.01273885 0.3242234 1 I want to select records where one is greater than .5 When I try this, I get "subscript out of bounds." Why am I getting this error? How do I perform this select? newDataGoodPredict <- newdata[ which(one0.5),] Error in newdata[which(one 0.5), ] : subscript out of bounds

    Read the article

  • PHP - if == not working for 0 or ""

    - by user2933212
    I am checking the validation of the request with an if query, if ($request_userid == $userid) { ... } Thats working as expected. But further testing has shown, that if $request_userid or $userid is 0 or "", then the condition is true and the script runs the if query but it shouldn't. I am currently solving it with: if ($userid == "" ) { exit ("exit"); } But I don't think that this is the right way? Can you explain why it doesn’t work with the if query and what would be the correct way to check it?

    Read the article

  • If there's no problem treating a statement as an expression, why was there a distinction in the first place in some programming languages?

    - by cdmckay
    Why do we have the distinction between statements and expressions in most programming languages? For example, in Java, assuming f and g return ints, this still won't compile because it's a statement and statements don't return values. // won't compile int i = if (pred) { f(x); } else { g(x); } but in Scala, it's very happy with treating if as an expression. // compiles fine val i: Int = if (pred) f(x) else g(x) So if there's no problem treating an if statement as an expression, why was there a distinction in the first place?

    Read the article

  • Single statement if block - braces or no? [on hold]

    - by Zannjaminderson
    Which is better/more generally accepted? This: if(condition) { statement; } Or: if(condition) statement; I tend to prefer the first one, because I think it makes it easier to tell what actually belongs in the if block, it saves others from adding the braces later (or creating a bug by forgetting to), and it makes all your if statements uniform instead of some with braces and some without. The second one, however, is still syntactically correct and definitely more compact. I'm curious to see which is more generally preferred by others though.

    Read the article

  • Why are Pascal control structures inconsistent?

    - by 70Mike
    Most Pascal control structures make sense to me, like: for ... do {statement}; if (condition) then {statement}; while (condition) do {statement}; where the {statement} is either a single statement, or a begin ... end block. I have a problem with: repeat {statement-list} until (expression); try {statement-list} except {statement-list} end; Wouldn't it be better that repeat and try have the same general structure, accepting only a single statement or a begin ... end block, instead of having a statement-list that's not formally blocked with a begin and an end?

    Read the article

  • Specification: Use cases for CRUD

    - by Mario Ortegón
    I am writing a Product requirements specification. In this document I must describe the ways that the user can interact with the system in a very high level. Several of these operations are "Create-Read-Update-Delete" on some objects. The question is, when writing use cases for these operations, what is the right way to do so? Can I write only one Use Case called "Manage Object x" and then have these operations as included Use Cases? Or do I have to create one use case per operation, per object? The problem I see with the last approach is that I would be writing quite a few pages that I feel do not really contribute to the understanding of the problem. What is the best practice?

    Read the article

  • SQL Server 2008 Dead lock issue

    - by user173552
    I got into a deadlock issue where I am struggling find the root-cause...The Deadlock graph suggests that an UPDATE statement became the victim over a SELECT statement... What puzzles me is that the UPDATE statement is trying to acquire an index on some other table that is never referred in update statement... This is how my UPDATE statement looks like... UPDATE Table set col1 = @P1 where col2 = @P2 This statement acquired a X lock on the col2 index, but also tries to acquire an index on a column defined in some other table that is no way related to the UPDATE statement... And the SELECT statement that won the deadlock situation had nothing to do with the table or index in the update statement but tried to acquire an index on the table in UPDATE statement. eventually causing the DEADLOCK.

    Read the article

  • Why do Pascal control structures appear to be inconsistent?

    - by 70Mike
    Most Pascal control structures make sense to me, like: for ... do {statement}; if (condition) then {statement}; while (condition) do {statement}; where the {statement} is either a single statement, or a begin ... end block. I have a problem with: repeat {statement-list} until (expression); try {statement-list} except {statement-list} end; Wouldn't it be better that repeat and try have the same general structure, accepting only a single statement or a begin ... end block, instead of having a statement-list that's not formally blocked with a begin and an end?

    Read the article

  • Is there a way to refactor this javascript/jquery?

    - by whyzee
    switch (options.effect) { case 'h-blinds-fadein': $('.child').each(function (i) { $(this).stop().css({opacity:0}).delay(100 * i).animate({ 'opacity': 1 }, { duration: options.speed, complete: (i !== r * c - 1) || function () { $(this).parent().replaceWith(prev); options.cp.bind('click',{effect: options.effect},options.ch); } }); }); break; case 'h-blinds-fadein-reverse': $('.child').each(function (i) { $(this).stop().css({opacity:0}).delay(100 * (r * c - i)).animate({ 'opacity': 1 }, { duration: options.speed, complete: (i !== 0) || function () { $(this).parent().replaceWith(prev); options.cp.bind('click',{effect: options.effect},options.ch); } }); }); break; ....more cases } I have alot of similiar other cases. One way i could think of is to write functions ? i'm not sure i'm still fairly new to the language

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >