Search Results

Search found 6988 results on 280 pages for 'if else statement'.

Page 127/280 | < Previous Page | 123 124 125 126 127 128 129 130 131 132 133 134  | Next Page >

  • C# Compiler Directives

    - by pm_2
    I’m looking at some C# code, and have come across the following statement: #if DEBUG // Do something here #else // Do something else #endif I assumed that DEBUG would be a defined somewhere as follows: #define DEBUG But I’m unable to find such a definition, although the code seems to behave as though it were set. Is DEBUG a special case, and if so, how is it set / unset?

    Read the article

  • typeset problem/solution pair (example) in latex

    - by FurtiveFelon
    Hey guys, I'd like to know if there is a way in latex to show the following: Example 1: problem statement here Solution: solution here and wrap that in a box so that it will be noticeable. Seems like a common enough problem that there should be ready made solutions If there are any suggestions it would be much appreciated!

    Read the article

  • comparing indexPaths in a loop iphone

    - by Brodie4598
    I am trying to compare an index path in my didSelectRowAtIndexPath delegate method with an array of index paths. for (n=0; n < [tempMutArrray count]; n= n+1){ NSComparisonResult *result = [indexPath compare:[tempMutArray objectAtIndex:n]; //What I want to do is is write an if statement that executes a certain block of code //if the two index paths are equal, but I cant figure out how to work with an //NSComparisonResult. }

    Read the article

  • Executable directory where application is running from?

    - by JPJedi
    I need to get the path (not the executable) where my application is running from: System.AppDomain.CurrentDomain.BaseDirectory() When I run the above statement with & "/images/image.jpg" on my local machine it works fine but when I install the application on another machine it says it cannot find the file and there is a lot of extra path information some. I just need the directory of where the app is running. I am coding in VB.NET with Visual Studio 2008. Thanks!

    Read the article

  • rails multiple outer joins syntax

    - by Craig McGuff
    I have the following models user has_many :leave_balances leave_balance belongs_to :user belongs_to :leave_type leave_type has_many :leave_balances I want to output a table format showing user names and their balance by leave type. Not every user can have every balance i.e. outer joins required. I'd like to see something like this: Employee Annual Leave Sick Leave Bob 10 Fred 9 Sara 12 15 I am unsure how to get this out as a single statement? I am thinking something like User.joins(:leave_balances).joins(:leave_type)

    Read the article

  • Should I avoid using Java Label Statements?

    - by Kamikaze Mercenary
    Today I had a coworker suggest I refactor my code to use a label statement to control flow through 2 nested for loops I had created. I've never used them before because personally I think they decrease the readability of a program. I am willing to change my mind about using them if the argument is solid enough however. What are people's opinions on label statements?

    Read the article

  • a multi-component truth table for assembly

    - by Malfist
    Can someone help me convert this C if statement into something assembly can understand? if((plain>='a' && plain<='x') || (plain>='A' && plain <='X')){ code = plain+2; } plain is a char, which for assembly is stored in the al register. Any help would be appreciated.

    Read the article

  • Order By Problem T-Sql

    - by Nick LaMarca
    I have a sql statement I am using a simple sort such as the following Select numbers From theTable Order By numbers What I get in return is the following 1 11 12 14 2 21 22 23 3 35 37 etc... I want it to be ordered in normal order 1 2 3 4 5 6 etc...

    Read the article

  • Biggest performance improvement you've had with the smallest change?

    - by JoelFan
    What's the biggest performance improvement you've had with the smallest change? For example, I once improved the performance of a certain page on a high-profile web app by a factor of 10, just by moving "where customerID = ?" to a different place inside a complicated SQL statement (before my change it had been selecting all customers in a join, then later selecting out the desired customer).

    Read the article

  • Selecting only the first item of an xpath result set in PHP

    - by IkimashoZ
    I am currently achieving the desired outcome with two PHP statements: $thisBlarg = $xmlResource->xpath('//blarg[@ID='.$someBlargID.']'); echo $thisBlarg[0]->name; But, not wanting to settle for second best, I'd really prefer this to be one statement, but PHP doesn't like this: echo $xmlResource->xpath('//blarg[@ID='.$someBlargID.']')[0]->name; And for good reason. But I can't find a way to force an xpath query to return the result directly. Any suggestions?

    Read the article

  • Mysql Avg function for recent 15 records by date (order date desc) in every symbol

    - by venkatesh
    i am trying to create a statement in sql (for a table which holds stock symbols and price on specified date) with avg of 5 day price and avg of 15 days price for each symbol. table description: symbol open high close date the average price is calculated from last 5 days and last 15 days. i tried this for getting 1 symbol: SELECT avg(close), avg(`trd_qty`) FROM (select * from cashmarket WHERE symbol = \'hdil\' order by `M_day` desc limit 0,15 ) s ...but I couldn't get the desired the list for showing avg values for all symbols.

    Read the article

  • Committing Transaction

    - by Costa
    Hi http://msdn.microsoft.com/en-us/library/ms189797.aspx In this link they are committing a transaction within catch clause IF (XACT_STATE()) = 1, I don't get it, if there is an error why they are committing it? even if the problem in select statement and there is no big deal committing it, why don't just roll it back. Thanks

    Read the article

  • if else within CTE ?

    - by stackoverflowuser
    I want to execute select statement within CTE based on a codition. something like below ;with CTE_AorB ( if(condition) select * from table_A else select * from table_B ), CTE_C as ( select * from CTE_AorB // processing is removed ) But i get error on this. Is it possible to have if else within CTEs? If not is there a work around Or a better approach. Thanks.

    Read the article

  • Bulk update + SQL + self join

    - by Nev_Rahd
    Hello All I would like to update a column in Table with reference to other column(s) in same table. Ex: As in figure below - I would like to update effective endate with min date whichever is greater than effective Start Date of currrent record. How can this be acheived in T-SQL. Can this be done with single update statement ? Thanks.

    Read the article

  • Spring's JdbcDaoSupport (using MySQL Connector/J) fails after executing sql that adds FK

    - by John
    I am using Spring's JdbcDaoSupport class with a DriverManagerDataSource using the MySQL Connector/J 5.0 driver (driverClassName=com.mysql.jdbc.driver). allowMultiQueries is set to true in the url. My application is an in-house tool we recently developed that executes sql scripts in a directory one-by-one (allows us to re-create our schema and reference table data for a given date, etc, but I digress). The sql scripts sometime contain multiple statements (hence allowMultiQueries), so one script can create a table, add indexes for that table, etc. The problem happens when including a statement to add a foreign key constraint in one of these files. If I have a file that looks like... --(column/constraint names are examples) CREATE TABLE myTable ( fk1 BIGINT(19) NOT NULL, fk2 BIGINT(19) NOT NULL, PRIMARY KEY (fk1, fk2) ); ALTER TABLE myTable ADD CONSTRAINT myTable_fk1 FOREIGN KEY (fk1) REFERENCES myOtherTable (id) ; ALTER TABLE myTable ADD CONSTRAINT myTable_fk2 FOREIGN KEY (fk2) REFERENCES myOtherOtherTable (id) ; then JdbcTemplate.execute throws an UncategorizedSqlException with the following error message and stack trace: Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [ THE SQL YOU SEE ABOVE LISTED HERE ]; SQL state [HY000]; error code [1005]; Can't create table 'myDatabase.myTable' (errno: 150); nested exception is java.sql.SQLException: Can't create table 'myDatabase.myTable' (errno: 150) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) and the table and foreign keys are not inserted. Also, especially weird: if I take the foreign key statements out of the script I showed above and then place them in their own script that executes after (so I now have 1 script with just the create table statement, and 1 script with the add foreign key statements that executes after that) then what happens is: tool executes create table script, works fine, table is created tool executes add fk script, throws the same exception as seen above (except errno=121 this time), but the FKs actually get added (!!!) In other words, when the create table/FK statements are in the same script then the exception is thrown and nothing is created, but when they are different scripts a nearly identical exception is thrown but both things get created. Any help on this would be greatly appreciated. Please let me know if you'd like me to clarify anything more.

    Read the article

  • Help with IF THEN breaking when comparing results from MYSQL query.

    - by roydukkey
    I'm have a problem with an invite system. The if statement seems to break. It shows the message "Fail" but the UPDATE statement still executes. Why do both the THEN and the ELSE excute? $dbConn = new dbConn(); // Check if POST user_username and user_hash are matching and valid; both are hidden for fields $sql = "SELECT user_username " . "FROM table_users " . "WHERE user_id=".mysql_real_escape_string($_POST["user_id"])." " . "AND user_hash='".mysql_real_escape_string($_POST["user_hash"])."' " . "AND user_enabled=0;"; $objUser = $dbConn->query($sql); // If result contains 1 or more rows if( mysql_num_rows($objUser) != NULL ){ $objUser = mysql_fetch_assoc($objUser); $ssnUser->login( $objUser["user_username"] ); $sql = "UPDATE table_users SET " . "user_enabled=1, " . "user_first_name='".mysql_real_escape_string($_POST["user_first_name"])."', " . "user_last_name='".mysql_real_escape_string($_POST["user_last_name"])."', " . "user_password='".mysql_real_escape_string( md5($_POST["user_password"]) )."' " . "WHERE user_id=".mysql_real_escape_string($_POST["user_id"]).";"; $dbConn->query($sql); echo "Success"; header( "Refresh: 5; url=/account/?action=domains" ); } else { echo "Fail"; } This dbConn Class is as follows: class dbConn{ var $username = "xxxx_admin"; var $password = "xxxxxxxx"; var $server = "localhost"; var $database = "xxxx"; var $objConn; function __construct(){ $conn = mysql_connect( $this->server, $this->username, $this->password, true ); if( !$conn ){ die("Could not connect: ".mysql_error() ); } else { $this->objConn = $conn; } unset($conn); } function __destruct(){ mysql_close( $this->objConn ); unset( $this ); } function query( $query, $db = false ){ mysql_select_db( $db != false ? $db : $this->database, $this->objConn ); $result = mysql_query( $query ); unset($query,$db); return $result; } }

    Read the article

  • Question about JSON?

    - by Alex
    Hi all, I have a fairly simple question: In Javascript how can I return the boolean (if its found in the JSON) rather than the actual value? Example: var myJSON = { "foo" : "bar", "bar" : "foo" }; var keyToLookFor = "foo"; var found = myJSON[keyToLookFor]; if (found) { // I know I can test if the string exists in the if } // but is there a way I could just return something like: return found; // instead of testing found in the if statement and then returning true?

    Read the article

  • java hashmap flaws ?

    - by Tiberiu Hajas
    hi there, if (agents != null) for (Iterator iter = agents.keySet().iterator(); iter .hasNext();) { // some stuffs here } I have the following piece of java code, the agents is a hashmap, wondering if anyone can figure it out why on the line with "for" statement sometimes I got NPE ? is there any flaw with hashmaps ? thanks

    Read the article

< Previous Page | 123 124 125 126 127 128 129 130 131 132 133 134  | Next Page >