Search Results

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

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

  • Jump to the start of next statement

    - by Borek
    Say that I'm writing a test and my caret is here (indicated by "|"): [ExpectedException(typeof(InvalidOperationException|))] In Visual Studio 2010, I'd like to press some shortcut that would take me to the next line so that I could start typing "public void Etc()". Right now, I need to press Right arrow Right arrow Right arrow Enter Which is too many key presses IMO. Is there a VS2010 / ReSharper shortcut to aid this operation?

    Read the article

  • Lambda "if" statement?

    - by AndyC
    I have 2 objects, both of which I want to convert to dictionarys. I use toDictionary<(). The lambda expression for one object to get the key is (i = i.name). For the other, it's (i = i.inner.name). In the second one, i.name doesn't exist. i.inner.name ALWAYS exists if i.name doesn't. Is there a lambda expression I can use to combine these two? Basically to read as: "if i.name exists then set id to i.name, else set id to i.inner.name". Many thanks.

    Read the article

  • Help me construct this Linq statement

    - by Geoffrey
    There should be a simple Linq query for what I'm trying to accomplish, but I'm producing some ugly code. I have two tables, one of issues and another of issue status. There is a one-to-many relationship between issue and issue status. When an issue is created an IssueStatus is also created with the status field set to "Open" when it is closed, another IssueStatus is created with the status field set to "Closed" ... but issues can be re-opened. It seems like I should be able to write something like this: public static List<Issue> FindOpenIssues(this IList<Issue> issues) { return ( from issue in issues from issueStatus in issue.issueStatus.OrderBy(x=>x.CreatedOn).Single() where issueStatus.Status == "Open" select issue ).ToList(); } This obviously fails, but there must be a clean way to do this? Thanks!

    Read the article

  • Get insert statement query

    - by Karthick
    Hi, Is there a way to get the insert statements for a table via some query in MySql? for ex: if the table name is Cards,which has 5 rows, i need to get the insert statements for that particular table. Thanks.

    Read the article

  • TSQL - create a stored proc inside a transaction statement

    - by Chris L
    I have a sql script that is set to roll to production. I've wrapped the various projects into separate transactions. In each of the transactions we created stored procedures. I'm getting error messages Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'procedure'. I created this example script to illustrate Begin Try Begin Transaction -- do a bunch of add/alter tables here -- do a bunch of data manipulation/population here -- create a stored proc create procedure dbo.test as begin select * from some_table end Commit End Try Begin Catch Rollback Declare @Msg nvarchar(max) Select @Msg=Error_Message(); RaisError('Error Occured: %s', 20, 101,@Msg) With Log; End Catch The error seems to imply that I can't create stored procs inside of transaction, but I'm not finding any docs that say otherwise(maybe google isn't being freindly today).

    Read the article

  • The best way to return related data in a SQL statement

    - by Darvis Lombardo
    I have a question on the best method to get back to a piece of data that is in a related table on the other side of a many-to-many relationship table. My first method uses joins to get back to the data, but because there are multiple matching rows in the relationship table, I had to use a TOP 1 to get a single row result. My second method uses a subquery to get the data but this just doesn't feel right. So, my question is, which is the preferred method, or is there a better method? The script needed to create the test tables, insert data, and run the two queries is below. Thanks for your advice! Darvis -------------------------------------------------------------------------------------------- -- Create Tables -------------------------------------------------------------------------------------------- DECLARE @TableA TABLE ( [A_ID] [int] IDENTITY(1,1) NOT NULL, [Description] [varchar](50) NULL) DECLARE @TableB TABLE ( [B_ID] [int] IDENTITY(1,1) NOT NULL, [A_ID] [int] NOT NULL, [Description] [varchar](50) NOT NULL) DECLARE @TableC TABLE ( [C_ID] [int] IDENTITY(1,1) NOT NULL, [Description] [varchar](50) NOT NULL) DECLARE @TableB_C TABLE ( [B_ID] [int] NOT NULL, [C_ID] [int] NOT NULL) -------------------------------------------------------------------------------------------- -- Insert Test Data -------------------------------------------------------------------------------------------- INSERT INTO @TableA VALUES('A-One') INSERT INTO @TableA VALUES('A-Two') INSERT INTO @TableA VALUES('A-Three') INSERT INTO @TableB (A_ID, Description) VALUES(1,'B-One') INSERT INTO @TableB (A_ID, Description) VALUES(1,'B-Two') INSERT INTO @TableB (A_ID, Description) VALUES(1,'B-Three') INSERT INTO @TableB (A_ID, Description) VALUES(2,'B-Four') INSERT INTO @TableB (A_ID, Description) VALUES(2,'B-Five') INSERT INTO @TableB (A_ID, Description) VALUES(3,'B-Six') INSERT INTO @TableC VALUES('C-One') INSERT INTO @TableC VALUES('C-Two') INSERT INTO @TableC VALUES('C-Three') INSERT INTO @TableB_C (B_ID, C_ID) VALUES(1, 1) INSERT INTO @TableB_C (B_ID, C_ID) VALUES(2, 1) INSERT INTO @TableB_C (B_ID, C_ID) VALUES(3, 1) -------------------------------------------------------------------------------------------- -- Get result - method 1 -------------------------------------------------------------------------------------------- SELECT TOP 1 C.*, A.Description FROM @TableC C JOIN @TableB_C BC ON BC.C_ID = C.C_ID JOIN @TableB B ON B.B_ID = BC.B_ID JOIN @TableA A ON B.A_ID = A.A_ID WHERE C.C_ID = 1 -------------------------------------------------------------------------------------------- -- Get result - method 2 -------------------------------------------------------------------------------------------- SELECT C.*, (SELECT A.Description FROM @TableA A WHERE EXISTS (SELECT * FROM @TableB_C BC JOIN @TableB B ON B.B_ID = BC.B_ID WHERE BC.C_ID = C.C_ID AND B.A_ID = A.A_ID)) FROM @TableC C WHERE C.C_ID = 1

    Read the article

  • What to prefer in the following case?

    - by GK
    say suppose I have class as : public class Age { private int age; public int getAge() { return this.age; } } In my Main class I am calling the getAge() method many times. So I wanted to know is it advisable to call so many times or call once and assign it to some variable and use that variable. Which is best and why?

    Read the article

  • Modifying MySQL Where Statement Based on Array

    - by Ryan
    Using an array like this: $data = array ( 'host' => 1, 'country' => 'fr', ) I would like to create a MySQL query that uses the values of the array to form its WHERE clause like: SELECT * FROM table WHERE host = 1 and country = 'fr' How can I generate this query string to use with MySQL?

    Read the article

  • Java PreparedStatement Throws MySQLSyntaxErrorException

    - by sqlBugs
    I have the following Java code: String query = "Select 1 from myTable where name = ? and age = ?"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, name); stmt.setInt(2, age); ResultSet rs = stmt.executeQuery(); Whenever I run the above code, it throws an exception on line 2 (where the PreparedStatement is declared): Error 0221202: SQLException = com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '? AND age = ?' at line 1 Does anyone have any suggestions about what I am doing wrong? Thanks!

    Read the article

  • SQLite: Simple DELETE statement did not work

    - by user186446
    I have a table MRU, that has 3 columns. (VALUE varchar(255); TYPE varchar(20); DT_ADD datetime) This is a table simply storing an entry and recording the date time it was recorded. What I wanted to do is: delete the oldest entry whenever I add a new entry that exceeds a certain number. here is my query: delete from MRU where type = 'FILENAME' ORDER BY DT_ADD limit 1; The query returns an error. Thanks

    Read the article

  • Php function within SQL statement syntax

    - by Vafello
    I have the following code. I would like username to take the value of the getUserName function however I am fighting with syntax. Can anybody tell me what should be the correct one? $query = "SELECT user FROM users_entity WHERE username = getUserName()";

    Read the article

  • postgres syntax question for OR?

    - by Dashiell0415
    The first one below works, but, just wanted to see if there's a better way... If I'm trying to find all records that start with 'C' with either a flag of 2 or a status of 9, do I need to incorporate the 'C' criteria twice? i.e., "SELECT * FROM mytable WHERE name like 'C%' AND flag = 2 OR name like 'C%' AND status = 9" Or, is there a way quicker way to write it so that I only need to set 'C%' once?

    Read the article

  • one-liner if statements...

    - by snickered
    Total noob here so be gentle. I've looked everywhere and can't seem to find the answer to this. How do I condense the following? if (expression) { return true; } else { return false; } I can't get it to work since it's returning something vs. setting something. I've already seen things like this: somevar = (expression) ? value1 : value2; Like I said, please be gentle :)

    Read the article

  • dynamically build Intersect statement ASP.NET

    - by TDDG
    I would like to use the IEnumerable function Intersect() to combine a few list and get the similar integers from each list. The problem I'm faced with is that I don't know how many list I will need to compare. Here is an example: A{1,2,3,4} B{1,2,3} C{1,2} results = A.Intersect(B).Intersect(C) This works great, but the next time around I may have a D{1,2} next time I come across the function. I'd like to use the Intersect method, but I'm open to new ideas as well.

    Read the article

  • Javascript if/else statement in iframe

    - by gr33nh4t
    So I'm trying to use javascript to pop up a video, and need to know when I'm in an iframe so I can resize the video accordingly. When outside the iframe, I see three alerts ('this is seen by both', 'not in iframe', and 'this is after the fact') When in the iframe, I just see the first alert ('this is seen by both'). var handleViewVideoClick = function (dataAction, eventType, targetElement, dataActionElement) { alert('this is seen by both'); if ($('iframe', window.parent.document).length == 0) { alert('not in iframe'); } else { alert('in iframe'); } alert('this is after the fact...'); }; What's going on here?

    Read the article

  • Can this statement ever evaluate to FALSE?

    - by BojanG
    I stumbled upon this while doing a review and the author is not available: int n = Convert.ToInt32(text); if (((n > 0) || (n < 0)) || (n == 0)) { return 1; } The code in general looks solid and it's hard for me to believe that the only purpose of this snippet is to confuse reviewers, but I don't see a way for this condition to fail. Am I missing something?

    Read the article

  • Understanding PHP's way of reading if statements

    - by Masi
    How does PHP read if statements? I have the following if statements in this order if ( $number_of_figures_in_email < 6) { -- cut: gives false } if($number_of_emails > 0) { -- cut: gives false } if ( $number_of_emails == 0) { -- cut: gives true } The code behaves randomly. It sometimes goes to the third if clause and gives me a success, while sometimes to the one of the first two if clauses when the input variables are constant. This suggests me that I cannot code only with if statements.

    Read the article

  • The case of the mysterious MySQL caching across restarts

    - by shanusmagnus
    I found a very slow MySQL query in my web app. The weird thing is that the query is only slow the first time it's executed, despite the fact that the query_cache is set to its default (query_cache_size 0) like so: mysql> show variables like 'query%'; +------------------------------+---------+ | Variable_name | Value | +------------------------------+---------+ | query_alloc_block_size | 8192 | | query_cache_limit | 1048576 | | query_cache_min_res_unit | 4096 | | query_cache_size | 0 | | query_cache_type | ON | | query_cache_wlock_invalidate | OFF | | query_prealloc_size | 8192 | +------------------------------+---------+ The even weirder thing is that this speedup persists even after the MySQL server has been stopped and restarted (I'm using OSX, and perform this restart using the system preferences pane.) The only way I can re-create the poor performance of the initial query is by rebooting the system. So my question is: how is this happening? Obviously some sort of caching at work, but where? And how does it persist across database restarts? This query is mediated through our web app, which comes via PHP/Apache, but there are no extra bells and whistles, and the curious caching also persists across Apache restarts. Help?

    Read the article

  • MySQL: group by and IF statement

    - by notset
    By default, parent_id = 0. I want to select all records with parent_id = 0 and only the last ones with parent_id 0. I tried this, but it didn't work: SELECT * FROM `articles` IF `parent_id` > 0 THEN GROUP BY `parent_id` HAVING COUNT(`parent_id`) >= 1 END; ORDER BY `time` DESC What could be the solution?

    Read the article

  • How to make NOT IN statement via Restrictions

    - by slavig
    I used this trick: List statuses = new ArrayList(); Criteria criteria = session.createCriteria(MessageQueue.class); criteria.add(Restrictions.not(Restrictions.in("message_status", statuses))); and this code creates: ...from MESSAGE_QUEUE mq where not (mq.message_status in (?, ?, ?, ?))... but I need: ...from MESSAGE_QUEUE mq where mq.message_status NOT IN (?, ?, ?, ?) Du you think they are equal statements?

    Read the article

  • Can't figure out what's wrong with my php/sql statement

    - by Olegious
    So this is probably a dumb beginner question, but I've been looking at it and can't figure it out. A bit of background: just practicing making a web app, a form on page 1 takes in some values from the user, posts them to the next page which contains the code to connect to the DB and populate the relevant tables. I establish the DB connection successfully, here's the code that contains the query: $conn->query("SET NAMES 'utf9'"); $query_str = "INSERT INTO 'qa'.'users' ('id', 'user_name','password' ,'email' ,'dob' ,'sx') VALUES (NULL, $username, $password, $email, $dob, $sx);"; $result = @$conn->query($query_str); Here's the error that is returned:Insert query failed: 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 ''qa'.'users' ('id', 'user_name' ,'password' ,'email' ,'dob' ,'s' at line 1 Thanks in advance!

    Read the article

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