Search Results

Search found 7596 results on 304 pages for 'prepared statement'.

Page 3/304 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Am I right in thinking there is no way to put an if statement and an else statement on line in Python?

    - by Louise
    Am I right in thinking I can't put an if-statement and the corresponding else-statement on one line in Python? NB: variable = value1 if condition else value2 is NOT two statements. It's one statement which can take the value of one of two expressions. I want to do something like if condition a=value else b=value Am I right in thinking this requires a full if-else in Python? Like if condition: a=value else: b=value Thanks, Louise

    Read the article

  • How to combine a list of choices to determine which select statement

    - by Larry
    I have a mysql db and am using php 5.2 What I am trying to do is offer a list of options for a person to select (only 1). The chosen option will cause a select, update, or delete statement to be ran. The results of the statement do not need to be shown, although, showing the old and then the new would be nice (no problems with that part tho'.). Pseudo-Code: Assign $choice = 0 Check the value of $choice // This way, if it = 100, we do a break Select a Choice:<br> 1. Adjust Status Value (+60) // $choice = 1<br> 2. Show all Ships <br> // $choice = 2 3. Show Ships in Port <br> // $choice = 3 ... 0. $choice="100" // if the value =100, quit this part Use either case (switch) or if/else statements to run the users choice1 If the choice is 1, then run the "Select" statement with the variable of $sql1 -- "SELECT .... If the choice is 2, then run the "Select" statement with the variable of $sql2 --- SELECT * FROM Ships If the choice is 3, then run the "Select" statement with the variable of $sql3 <br> .... If the choice is 0, then we are done. I figured the (3) statements would be assigned in php as: $sql1="...". $sql2="SELECT * FROM Ships" $sql3="SELECT * FROM Ships WHERE nPort="1" My idea was to use the switch statement, but got lost on it. :( I would like the options to be available over and over again, until a variable ($choice) is selected. In which case, this particular page is done and goes back to the "Main Menu"? The coding and display, if I use it, I can do. Just not sure how to write the way to select which one I want. It is possible that I would run all of the queries, and other times, only one, so that is why I would like the choice. An area I get confused in is the proper forms to use such as -- ' ' " " and ...?? Not sure the # of options I will end up with, but it will be more than 5 but less than 20 / page. So if I get the system down for 2-3 choices, I can replicate it for as many as I may need. And, as always, if a better way exists, I am willing to try it. Thanks again... Larry

    Read the article

  • how to go back to first if statement if no choices are valid - python

    - by wondergoat77
    how can i have python move to the top of an if statement if nothing is satisfied correctly i have a basic if/else statement like this: print "pick a number, 1 or 2" a = int(raw_input("> ") if a == 1: print "this" if a == 2: print "that" else: print "you have made an invalid choice, try again." what i want is to prompt the user to make another choice for 'a' this if statement without them having to restart the entire program, but am very new to python and am having trouble finding the answer online anywhere.

    Read the article

  • MySQL Prepared Statements to Generate Crosstab SQL

    MySQL Reporting requirements sometimes require both unknown column and row values, necessitating a more powerful means of generating crosstabs. Today's article presents Prepared Statements, which dynamically generate the SQL and assign it to a variable so that we can tailor the output based on the number of data values.

    Read the article

  • MySQL Prepared Statements to Generate Crosstab SQL

    MySQL Reporting requirements sometimes require both unknown column and row values, necessitating a more powerful means of generating crosstabs. Today's article presents Prepared Statements, which dynamically generate the SQL and assign it to a variable so that we can tailor the output based on the number of data values.

    Read the article

  • MySQL Prepared Statements to Generate Crosstab SQL

    <b>Database Journal:</b> "MySQL Reporting requirements sometimes require both unknown column and row values, necessitating a more powerful means of generating crosstabs. Today's article presents Prepared Statements, which dynamically generate the SQL and assign it to a variable so that we can tailor the output based on the number of data values."

    Read the article

  • Better Alternative to Case Statement

    - by Kyle Rozendo
    Hi All, I currently have a switch statement that runs around 300 odd lines. I know this is not as giant as it can get, but I'm sure there's a better way to handle this. The switch statement takes an Enum that is used to determine certain properties that pertain to logging. Right now the problem sets in that it is very easy to leave out an enumeration value and that it will not be given a value as it is not in the switch statement. Is there an option one can use to ensure that every enumeration is used and given a custom set of values it needs to do its job? Thanks, Kyle

    Read the article

  • Why use an OO approach instead of a giant "switch" statement?

    - by James P. Wright
    I am working in a .Net, C# shop and I have a coworker that keeps insisting that we should use giant Switch statements in our code with lots of "Cases" rather than more object oriented approaches. His argument consistently goes back to the fact that a Switch statement compiles to a "cpu jump table" and is therefore the fastest option (even though in other things our team is told that we don't care about speed). I honestly don't have an argument against this...because I don't know what the heck he's talking about. Is he right? Is he just talking out his ass? Just trying to learn here.

    Read the article

  • Data truncation when retrieving data from MySQL database with prepared statements

    - by KSiimson
    I have a script that retrieves multiple products using prepared statements. Like putting loops into loops, I have prepared statements in prepared statements - so there is a prepared statement for retrieving all products, a prepared statement to retrieve all images for that product, a prepared statement to get all attributes for that products, and so on. This does not work with one MySQLi instance, so I use multiple MySQLi objects that are opened and closed when needed. It usually works fine, but sometimes, especially when displaying multiple products, some data is truncated. For example - MicoLoans becomes MicoLoa. There was an actual spelling mistake here - now when I changed MicoLoans to MicroLoans, the same page displayed MicroLoa... So the same number of characters was truncated from the end. It is sort of consistent where it appears - for example there can be descriptions for 8 products, and description of 1 product is heavily truncated. When I add 9th product, the short description is still truncated for that same product as before. Any ideas?

    Read the article

  • How do I write a prepared statement with an update?

    - by Chris
    I am using mysqli prepared statments and I am trying to write a prepared statement with an UPDATE, but I think I am off somewhere. Here's my code: $upload_folder = 'Some String'; $sql = 'UPDATE orders (upload_location) SET (?) WHERE order_id = 160'; $stmt = $conn->stmt_init(); if($stmt->prepare($sql)){ $stmt->bind_param('s', $upload_folder); $location_inserted = $stmt->execute(); } What am I doing wrong?

    Read the article

  • Are there legitimate uses for JavaScript's "with" statement?

    - by Shog9
    Alan Storm's comments in response to my answer regarding the with statement got me thinking. I've seldom found a reason to use this particular language feature, and had never given much thought to how it might cause trouble. Now, I'm curious as to how I might make effective use of with, while avoiding its pitfalls... So my question is, where have you found the with statement useful?

    Read the article

  • if statement in aspx page

    - by Brad
    I want to write a basic if statement on my site to display either item 1 or item 2 depending on if a variable is set to true. I am not to familiar with .Net and need a little help with the basic structure of how to get an if statement to work on the aspx page. thank you for your help.

    Read the article

  • Separate clauses of an if statement?

    - by tarnfeld
    Is there any way to have multiple clauses in an if() statement? For instance: if( ($username=='textUser' && $role=='admin') || ($admin=='yes')) { // If the username AND role are set to admin OR if the admin is set to 'yes' } else { // Neither clauses of the if statement are true } Perhaps this is actually the correct code, i have no tried it - but if not, could anyone tell me how? :)

    Read the article

  • MYSQL if statement question...

    - by Dennis_M
    Is there any way to get the if statement to evaluate a query? SELECT if(50,'EQ_Type','*') FROM EQUIPMENT; Resulting in: +-----------------------+ | IF(50,'EQ_Type','*') | +-----------------------+ | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | +-----------------------+ 9 rows in set (0.00 sec) I would like the above statement to be equivalent to the following: SELECT 'EQ_Type' FROM EQUIPMENT; And produce: +--------------+ | EQ_Type | +--------------+ | ENGINE | | ENGINE | | ENGINE | | TRAILER | | TRAILER | | TRAILER | | WATER TENDER | | WATER TENDER | | WATER TENDER | +--------------+ Thanks for any help

    Read the article

  • use a sql select statement to get parameters for 2nd select statement

    - by diver-d
    Hi there, I am trying to write a sql statement that I have 2 tables Store & StoreTransactions. My first select command looks like SELECT [StoreID],[ParentStoreID] FROM Store Very simple stuff. How do I take the returned StoreID's and use them for my 2nd select statement? SELECT [StoreTransactionID],[TransactionDate],[StoreID] FROM StoreTransactions WHERE StoreID = returned values from the above query Any help would be great!

    Read the article

  • Performance of VIEW vs. SQL statement

    - by Matt W.
    I have a query that goes something like the following: select <field list> from <table list> where <join conditions> and <condition list> and PrimaryKey in (select PrimaryKey from <table list> where <join list> and <condition list>) and PrimaryKey not in (select PrimaryKey from <table list> where <join list> and <condition list>) The sub-select queries both have multiple sub-select queries of their own that I'm not showing so as not to clutter the statement. One of the developers on my team thinks a view would be better. I disagree in that the SQL statement uses variables passed in by the program (based on the user's login Id). Are there any hard and fast rules on when a view should be used vs. using a SQL statement? What kind of performance gain issues are there in running SQL statements on their own against regular tables vs. against views. (Note that all the joins / where conditions are against indexed columns, so that shouldn't be an issue.) EDIT for clarification... Here's the query I'm working with: select obj_id from object where obj_id in( (select distinct(sec_id) from security where sec_type_id = 494 and ( (sec_usergroup_id = 3278 and sec_usergroup_type_id = 230) or (sec_usergroup_id in (select ug_gi_id from user_group where ug_ui_id = 3278) and sec_usergroup_type_id = 231) ) and sec_obj_id in ( select obj_id from object where obj_ot_id in (select of_ot_id from obj_form left outer join obj_type on ot_id = of_ot_id where ot_app_id = 87 and of_id in (select sec_obj_id from security where sec_type_id = 493 and ( (sec_usergroup_id = 3278 and sec_usergroup_type_id = 230) or (sec_usergroup_id in (select ug_gi_id from user_group where ug_ui_id = 3278) and sec_usergroup_type_id = 231) ) ) and of_usage_type_id = 131 ) ) ) ) or (obj_ot_id in (select of_ot_id from obj_form left outer join obj_type on ot_id = of_ot_id where ot_app_id = 87 and of_id in (select sec_obj_id from security where sec_type_id = 493 and ( (sec_usergroup_id = 3278 and sec_usergroup_type_id = 230) or (sec_usergroup_id in (select ug_gi_id from user_group where ug_ui_id = 3278) and sec_usergroup_type_id = 231) ) ) and of_usage_type_id = 131 ) and obj_id not in (select sec_obj_id from security where sec_type_id = 494) )

    Read the article

  • My IF statement is changing variables in PHP

    - by user1902509
    I am fairly new to the whole programming thing, so forgive me if this is a stupid question. It seems odd that I haven't run into it before. I am trying to make an order form for a cake. You fill out the form, submit it, and it will then display the order in a new window, where you then hit "submit," and upload it to the Database. I have a series of If Statements to check for errors in the form before submitting it. Here is a simplified version of the code. Writing means any writing you want on the cake, Name is your name, and cake is what type of cake you want (the default is "None"). try { $name = trim($params->name); $cake = trim($params->cake); $writing = trim($params->writing); if (strlen($name) < 3){ throw new Exception("Please enter Your name."); } if ($cake = "None") { throw new Exception("Please select a Cake" } if ($cake = "Caramel Apple Pie" or $cake = "Pumpkin Pie" or $cake = "Eggnog Pie" and strlen($writing) > 1) { throw new Exception("We are sorry, but you can't write on any of our specialty pies."); } } catch(Exception $x) { $error = $x->getmessage(); } So what is happening is that when I go and hit submit the first time, the correct cake type comes up, but when you submit it the second time, the error comes up saying that I have "None" selected. All the other values are there and remain the same. I think the problem is that the first "IF" statement (Where it says "If($cake = "None")) is automatically changing $cake to "None" because I have tried commenting just that statement out, and it will then change the cake to be "Caramel Apple Pie," which is in the top of the next IF statement. Anyone know why it is doing this? And how to fix it?

    Read the article

  • Be Prepared: Technology Trends Converge and Disrupt

    - by Richard Lefebvre
    Cloud. Big data. Mobile. Social media: these mega trends in technology have had a profound impact on our lives. And now according to SVP Ravi Puri from North America Oracle Consulting Services, these trends are starting to converge and will affect us even more. His article, “Cloud, Analytics, Mobile, And Social: Convergence Will Bring Even More Disruption” appeared in Forbes on June 6. For example, mobile and social are causing huge changes in the business world. Big data and cloud are coming together to help us with deep analytical insights. And much more. These convergences are causing another wave of disruption, which can drive all kinds of improvements in such things as customer satisfaction, competitive advantage, and growth. But, according to Puri, companies need to be prepared. In this article, Puri urges companies to get out in front of the new innovations. H3 gives good directions on how to do so to accelerate time to value and minimize risk. The post is a good thought leadership piece to pass on to your customers.

    Read the article

  • Using statement question

    - by Dan
    I have two questions. 1) Should you always use a using statement on a connection? So, I would use it on the connection and then another one on a reader within the connection? So I would be using two using statements. 2) Lets say you use the using statement on the connection and also a reader being returned on the connection. So you have two using statements. Does it create two Try{}Finally{} blocks or just one? Thanks!

    Read the article

  • Is a switch statement the fastest way to implement operator interpretation in Java

    - by Mordan
    Is a switch statement the fastest way to implement operator interpretation in Java public boolean accept(final int op, int x, int val) { switch (op) { case OP_EQUAL: return x == val; case OP_BIGGER: return x > val; case OP_SMALLER: return x < val; default: return true; } } In this simple example, obviously yes. Now imagine you have 1000 operators. would it still be faster than a class hierarchy? Is there a threshold when a class hierarchy becomes more efficient in speed than a switch statement? (in memory obviously not) abstract class Op { abstract public boolean accept(int x, int val); } And then one class per operator.

    Read the article

  • Selecting the most common value from relation - SQL statement

    - by Ronnie
    I have a table within my database that has many records, some records share the same value for one of the columns. e.g. | id | name | software | ______________________________ | 1 | john | photoshop | | 2 | paul | photoshop | | 3 | gary | textmate | | 4 | ade | fireworks | | 5 | fred | textmate | | 6 | bob | photoshop | I would like to return the value of the most common occurring piece of software, by using an SQL statement. So in the example above the required SQL statement would return 'photoshop' as it occurs more than any other piece of software. Is this possible? Thank you for your time.

    Read the article

  • C++ Switch Statement Case Error

    - by Metal_Drummer
    I'm programming a simple text-based RPG using a switch statement for a game loop. The program works fine until I attempt to add another case statement, at which point it gives me the following three errors: "jump to case label" (error occurs at the line of the newly added case), and two "crosses initialization of 'ClassName *objectName'"(errors occur when the new objects are created in case 2). I'll paste the important code, if anyone needs more, please let me know. int main(void) { //initiate first object array and add some objects //initiate second object array and add some objects while(gamestate != 8) { switch(gamestate) { case 0: //do some stuff break; case 1: //do some stuff break; case 2: //declare new objects of the two... //...classes I have (ClassName *objectName) //do some stuff break; case 3: //this is the case I am trying to add //do nothing break; } } return 0; }

    Read the article

  • Using Container.DataItem with an If statement within <% %>

    - by William Calleja
    I have the following code in a c# aspx page: <ItemTemplate> <a <% if(((Dictionary<string, string>)Container.DataItem)["type"]==Session["type"]){%> class="active"<%}%> This code is causing the following error. Compiler Error Message: CS0117: 'System.ComponentModel.Container' does not contain a definition for 'DataItem' Why is that and how can I make a conditional statement that uses the Container.DataItem? Container.DataItem works perfectly when used within a <%# %> however putting the if statement within the <%# %> causes the following error: Compiler Error Message: CS1518: Expected class, delegate, enum, interface, or struct

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >