Search Results

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

Page 8/304 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • If-Else V.S. Switch end of flow

    - by Chris Okyen
    I was wondering the if if-else statements, is like a switch statement that does not have a break statement.To clarify with an example, will the if-else statement go through all the boolean expressions even if comes to one that is true before the final one... I.E., if boolean_expression_1 was true, would it check if boolean_expression_2 is true? If not, why do switch statements need break statements but if-else statements do not? And if they do, I ask the opposite sort question proposed in the previous sentence. if( boolean_expression_1 ) statement_1 else if( boolean_expression_2 ) statement_2 else default_statement switch( controlling_expression ) { case: ( A ) .... case: ( z ) }

    Read the article

  • SQL SERVER – A Puzzle – Swap Value of Column Without Case Statement

    - by pinaldave
    For the last few weeks, I have been doing Friday Puzzles and I am really loving it. Yesterday I received a very interesting question by Navneet Chaurasia on Facebook Page. He was asked this question in one of the interview questions for job. Please read the original thread for a complete idea of the conversation. I am presenting the same question here. Puzzle Let us assume there is a single column in the table called Gender. The challenge is to write a single update statement which will flip or swap the value in the column. For example if the value in the gender column is ‘male’ swap it with ‘female’ and if the value is ‘female’ swap it with ‘male’. Here is the quick setup script for the puzzle. USE tempdb GO CREATE TABLE SimpleTable (ID INT, Gender VARCHAR(10)) GO INSERT INTO SimpleTable (ID, Gender) SELECT 1, 'female' UNION ALL SELECT 2, 'male' UNION ALL SELECT 3, 'male' GO SELECT * FROM SimpleTable GO The above query will return following result set. The puzzle was to write a single update column which will generate following result set. There are multiple answers to this simple puzzle. Let me show you three different ways. I am assuming that the column will have either value ‘male’ or ‘female’ only. Method 1: Using CASE Statement I believe this is going to be the most popular solution as we are all familiar with CASE Statement. UPDATE SimpleTable SET Gender = CASE Gender WHEN 'male' THEN 'female' ELSE 'male' END GO SELECT * FROM SimpleTable GO Method 2: Using REPLACE  Function I totally understand it is the not cleanest solution but it will for sure work in giving situation. UPDATE SimpleTable SET Gender = REPLACE(('fe'+Gender),'fefe','') GO SELECT * FROM SimpleTable GO Method 3: Using IIF in SQL Server 2012 If you are using SQL Server 2012 you can use IIF and get the same effect as CASE statement. UPDATE SimpleTable SET Gender = IIF(Gender = 'male', 'female', 'male') GO SELECT * FROM SimpleTable GO You can read my article series on SQL Server 2012 various functions over here. SQL SERVER – Denali – Logical Function – IIF() – A Quick Introduction SQL SERVER – Detecting Leap Year in T-SQL using SQL Server 2012 – IIF, EOMONTH and CONCAT Function Let us clean up. DROP TABLE SimpleTable GO Question to you: I came up with three simple tricks where there is a single UPDATE statement which swaps the values in the column. Do you know any other simple trick? If yes, please post here in the comments. I will pick two random winners from all the valid answers. Winners will get 1) Print Copy of SQL Server Interview Questions and Answers 2) Free Learning Code for Online Video Courses I will announce the winners on coming Monday. Reference:  Pinal Dave (http://blog.SQLAuthority.com) Filed under: CodeProject, PostADay, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Puzzle, SQL Query, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology

    Read the article

  • How do I capture a 10053 trace for a SQL statement called in a PL/SQL package?

    - by Maria Colgan
    Traditionally if you wanted to capture an Optimizer trace (10053) for a SQL statement you would issue an alter session command to switch on a 10053 trace for that entire session, and then issue the SQL statement you wanted to capture the trace for. Once the statement completed you would exit the session to disable the trace. You would then look in the USER_DUMP_DEST directory for the trace file. But what if the SQL statement you were interested  in was actually called as part of a PL/SQL package? Oracle Database 11g, introduced a new diagnostic events infrastructure, which greatly simplifies the task of generating a 10053 trace for a specific SQL statement in a PL/SQL package. All you will need to know is the SQL_ID for the statement you are interested in. Instead of turning on the trace event for the entire session you can now switch it on for a specific SQL ID. Oracle will then capture a 10053 trace for the corresponding SQL statement when it is issued in that session. Remember the SQL statement still has to be hard parsed for the 10053 trace to be generated.  Let's begin our example by creating a PL/SQL package called 'cal_total_sales'. The SQL statement we are interested in is the same as the one in our original example, SELECT SUM(AMOUNT_SOLD) FROM SALES WHERE CUST_ID = :B1. We need to know the SQL_ID of this SQL statement to set up the trace, and we can find in V$SQL. We now have everything we need to generate the trace. Finally  you would look in the USER_DUMP_DEST directory for the trace file with the name you specified. Maria Colgan+

    Read the article

  • MySQLi - Should every statement be prepared?

    - by Kerry
    I know its supposed to improve performance and clean strings, but lets say there are no variables? Might just be a SELECT COUNT( `column` ) AS count FROM `table` Should that be prepared? Is there any case that a SELECT statement should not be prepared?

    Read the article

  • Updating your DotNetNuke Copyright Statement for 2011, and beyond

    - by Chris Hammond
    originally posted on my DotNetNuke.com blog Every January people start thinking “oh crap, I need to update the copyright statement on my website”. And everyone runs out and makes the change to the current year. Well, if you use DotNetNuke you can easily change the Copyright statement on your site from the Site Settings page, found under the Admin menu. You’ll find a setting like the following. If your Skin in DotNetNuke uses the Copyright SkinObject then changing that setting and updating the settings...(read more)

    Read the article

  • Stairway to T-SQL DML Level 10: Changing Data with the UPDATE Statement

    Unless you are working on a reporting-only application you will probably need to update tables in your SQL Server database. To update rows in a table you use the UPDATE statement. In this level we will be discussing how to find and update records in your database, and discuss the pitfalls you might run into when using the UPDATE statement. Is your SQL Database under Version Control?SSMS plug-in SQL Source Control connects SVN, TFS, Git, Hg and all others to SQL Server. Learn more.

    Read the article

  • New Interaction Hub Statement of Direction Published

    - by Matthew Haavisto
    The latest PeopleSoft Interaction Hub Statement of Direction is now available on My Oracle Support.  We think this subject will be particularly interesting to customers given the impending release of the PeopleSoft Fluid User Experience and all that offers.  The Statement of Direction describes how we see the Interaction Hub being used with the new user experience and the Hub's continued place in a PeopleSoft environment.  This paper also discusses subjects like branding, content management, easier design/deployment, and the optional restricted use license.

    Read the article

  • The DELETE statement in SQL Server

    Of the big four DML statements in SQL Server, the DELETE is the one least written about. This is odd considering the extra power conferred on the statement by the addition of the WITH common_table_expression; and the OUTPUT clause that essentially allows you to move data from one table to another in one statement. NEW! SQL Monitor 2.0Monitor SQL Server Central's servers withRed Gate's new SQL Monitor.No installation required. Find out more.

    Read the article

  • SQL Insert Into Statement

    - by Derek Dieter
    The “insert into” statement is used in order to insert data into an existing table. The syntax for this is fairly simple. In the first section of the statement, you specify the table name and column names in which you are inserting data into. The second part is where the source of [...]

    Read the article

  • Stairway to T-SQL DML Level 12: Using the MERGE Statement

    The final level of this stairway looks at the MERGE statement in detail, focusing on how to perform insert, update and delete logic using the MERGE statement. An accidental DBA? Try SQL MonitorUse the 30-day full product free trial to get easy-to-understand insights into SQL Server, and get suggestions on how to solve the type of issues that are uncovered. Begin your free trial.

    Read the article

  • Financial Statement Presentation Changes

    - by Theresa Hickman
    On March 10, 2010, FASB and IASB came to an agreement on financial statement presentation. They have been discussing changes for some time, such as displaying more lines items and moving certain line items from equity to the P&L, and now it seems they have finally come to a joint decision and put it in writing. I recently learned that there will be a trend to book nothing to equity and to convey everything in the P&L to take away any facility for companies to hide losses from its shareholders, investors, etc. (I'm exaggerating when I say book nothing to equity. Obviously, those items that already live there, such as stocks and dividends, would stay there.) But accounts like your CTA (Cumulative Translation Adjustment account) used to plug the gain or loss from equity translation would move from the equity section to your expense section. The rationale is that when you run translation, you're doing so for a subsidiary that you own, or simply put, it's a foriegn investment. Thus, the gains/losses of that foriegn investment should be itemized on your P&L and not buried in equity. The FASB will include changes in financial statement presentation in its Exposure Draft that is planned for issuance at the end of April 2010. Companies will be required to adopt the financial statement presentation provisions retroactively. Yes, that means companies will need to apply these changes to previously issued financial statements. The FASB Summary of Board Decisions can be found at "fasb.org".

    Read the article

  • A new mission statement for my school's algorithms class

    - by Eric Fode
    The teacher at Eastern Washington University that is now teaching the algorithms course is new to eastern and as a result the course has changed drastically mostly in the right direction. That being said I feel that the class could use a more specific, and industry oriented (since that is where most students will go, though suggestions for an academia oriented class are also welcome) direction, having only worked in industry for 2 years I would like the community's (a wider and much more collectively experienced and in the end plausibly more credible) opinion on the quality of this as a statement for the purpose an algorithms class, and if I am completely off target your suggestion for the purpose of a required Jr. level Algorithms class that is standalone (so no other classes focusing specifically on algorithms are required). The statement is as follows: The purpose of the algorithms class is to do three things: Primarily, to teach how to learn, do basic analysis, and implement a given algorithm found outside of the class. Secondly, to teach the student how to model a problem in their mind so that they can find a an existing algorithm or have a direction to start the development of a new algorithm. Third, to overview a variety of algorithms that exist and to deeply understand and analyze one algorithm in each of the basic algorithmic design strategies: Divide and Conquer, Reduce and Conquer, Transform and Conquer, Greedy, Brute Force, Iterative Improvement and Dynamic Programming. The Question in short is: do you agree with this statement of the purpose of an algorithms course, so that it would be useful in the real world, if not what would you suggest?

    Read the article

  • If statement causing xna sprites to draw frame by frame

    - by user1489599
    I’m a bit new to XNA but I wanted to write a simple program that would fire a cannon ball from a cannon at a 45 degree angle. It works fine outside of my keyboard i/o if statement, but when I encapsulate the code around an if statement checking to see if the user hits the space bar, the sprite will draw one frame at a time every time the space bar is hit. This is the code in question if (currentKeyboardState.IsKeyUp(Keys.Space) && previousKeyboardState.IsKeyDown(Keys.Space) && !skullBall.Alive) { //works outside the keyboard input if statement //{ skullBall.Position = cannon.Position; skullBall.DeltaY = -(float)(Math.Sin(MathHelper.ToRadians(45)) * 50/*39.7577*/ * time + 0.5 * (gravity * (time * time))); skullBall.DeltaX = (float)(Math.Cos(MathHelper.ToRadians(45)) * 50/*39.7577*/ * time); skullBall.Alive = true; //} } The skull ball represents the cannon ball and the cannon is just the starting point. DeltaX and DeltaY are the values I’m using to update the cannon balls position per update. I know it's dumb to have the cannon ball start at the cannons position every time the update is called but it’s not really noticeable right now. I was wondering if after examining my code, if anyone noticed any errors that would cause the sprite to display frame by frame instead of drawing it as a full animation of the cannon ball leaving the cannon and moving from there.

    Read the article

  • Is there a list of common object that implement IDisposable for the using statement?

    - by SkippyFire
    I was wondering if there was some sort of cheat sheet for which objects go well with the using statement... SQLConnection, MemoryStream, etc. Taking it one step further, it would be great to even show the other "pieces of the puzzle", like how you should actually call connection.Close() before the closing using statement bracket. Anything like that exist? If not, maybe we should make one.

    Read the article

  • How to do an if statement on a function in PHP?

    - by Bruce
    I just realized that you can't just use an if statement on a function, for example this doesn't work: function sayHello() { echo "Hello World"; } if(sayHello()) echo "Function Worked"; else echo "Function Failed"; I also saw that a function can't be put as the value of a variable. So how can I do an if statement to check if a function has executed properly and display it to the browser?

    Read the article

  • Mysqli prepared insert statements always returning false

    - by user1754679
    I'm writing prepared statements that are supposed to insert data into a table, on a database that's been pre-selected in the variable $GLOBALS['mysqli']. The connection has been tested, and that's not the problem I'm having. I'm only running into trouble whenever my prepared statement involves INSERT INTO. I know the tablename, and field names are correct, but $stmt is ALWAYS false. What gives? $stmt = $GLOBALS['mysqli']->prepare("INSERT INTO audit_RefreshCount (user, count, lastrefresh) values (?,?,?)"); if ($stmt == TRUE) { $stmt->bindParam('ssi', $_SESSION['username'], '0', time()); //$stmt->bind_Param('ssi', $_SESSION['username'], '0', time()); // Also doesn't work. $stmt->execute(); }

    Read the article

  • Reusing an anonymous parameter in a prepared statement

    - by Chris Lieb
    I am customizing the insert SQL generated by hibernate and have hit an issue. When Hibernate generates the query by itself, it inserts data into the first two columns of the table, but this causes a database error since all four columns of the table are non-nullable. For the insert to be performed properly, it must insert the same data into two columns of the new record. This means that I need Hibernate to bind the same data to two different parameters in the query (prepared statement) that I am writing. Is there some SQL syntax that allows me to refer to anonymous parameters bound to a prepared statement in an order different from which they are bound? Details REF_USER_PAGE_XREF ---------------------------------------- PK FK1 | NETWORK_ID | VARCHAR2(100) PK FK1 | PAGE_PATH | VARCHAR2(1000) | USER_LAST_UPDT | VARCHAR2(100) | TMSP_LAST_UPDT | DATE insert into REF_USER_ROLE_XREF( NETWORK_ID, PAGE_PATH, TMSP_LAST_UPDT, USER_LAST_UPDT) values ( ?, /* want to insert the same data here */ ?, ?, /* and here */ (select to_char(sysdate, 'DD-MON-YY') from dual) I want to insert the same data into the first and third anonymous parameters.

    Read the article

  • Bind Variable and SQL error during statement preparation

    - by Abhishek Dwivedi
    Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}  I was getting the following exception at run-time. JBO-27122: SQL error during statement preparation. Statement: SELECT AxEO.A_ID, AxEO.B_ID, AxEO.C_ID, ByEO.A_ID, ByEO.B_ID, ByEO.C_ID, Cz.A_ID, Cz.B_ID, Cz.C_ID FROM ABC_x AxEO, ABC_y ByEO, ABC_z CzEO WHERE AxEO.A_ID = ByEO.A_ID AND  CzEO.A_ID = :Bind_PId I copied and pasted the query on SQL worksheet, replaced :Bind_PId with a valid id, and executed the query. The query worked alright, implying the query was alright. I tried to connect to different DBs but the issue persisted, meaning it was not a DB issue either. Finally, the root cause was found to be in the concerned VO; one of the bind variables (say Bind_TId) was marked "Required". De-selecting the Required check-box resolved the issue. In retrospect, the issue looks to be rather straight-forward. However, the error message is not very helpful, if not misleading. Besides, it's counter-intuitive to think that a bind variable which is not being used in a query can cause error while statement preparation. The other bind variable - Bind_TId - was being used in other view criteria, not the view criteria involved in the given query. Still, it was required.

    Read the article

  • Execute TSQL statement with ExecuteStoreQuery in entity framework 4.0

    - by Jalpesh P. Vadgama
    I was playing with entity framework in recent days and I was searching something that how we can execute TSQL statement in entity framework. And I have found one great way to do that with entity framework ‘ExecuteStoreQuery’ method. It’s executes a TSQL statement against data source given enity framework context and returns strongly typed result. You can find more information about ExcuteStoreQuery from following link. http://msdn.microsoft.com/en-us/library/dd487208.aspx So let’s examine how it works. So Let’s first create a table against which we are going to execute TSQL statement. So I have added a SQL Express database as following. Now once we are done with adding a database let’s add a table called Client like following. Here you can see above Client table is very simple. There are only two fields ClientId and ClientName where ClientId is primary key and ClientName is field where we are going to store client name. Now it’s time to add some data to the table. So I have added some test data like following. Now it’s time to add entity framework model class. So right click project->Add new item and select ADO.NET entity model as following. After clicking on add button a wizard will start it will ask whether we need to create model classes from database or not but we already have our client table ready so I have selected generate from database as following. Once you process further in wizard it will be presented a screen where we can select the our table like following. Now once you click finish it will create model classes with for us. Now we need a gridview control where we need to display those data. So in Default.aspx page I have added a grid control like following. <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EntityFramework._Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Welcome to ASP.NET! </h2> <p> To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>. </p> <p> You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409" title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>. <asp:GridView ID="grdClient" runat="server"> </asp:GridView> </p> </asp:Content> Now once we are done with adding Gridview its time to write code for server side. So I have written following code in Page_load event of default.aspx page. protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { using (var context = new EntityFramework.TestEntities()) { ObjectResult<Client> result = context.ExecuteStoreQuery<Client>("Select * from Client"); grdClient.DataSource = result; grdClient.DataBind(); } } } Here in the above code you can see that I have written create a object of our entity model and then with the help of the ExecuteStoreQuery method I have execute a simple select TSQL statement which will return a object result. I have bind that object result with gridview to display data. So now we are done with coding.So let’s run application in browser. Following is output as expected. That’s it. Hope you like it. Stay tuned for more..Till then happy programming.

    Read the article

  • Add "not" to if statement in shell script

    - by John Crawford
    I have the following script that should exist if the user does not exist. #check if user currently exists on system if id $User > /dev/null 2>&1 then #user exists no need to exit program echo "blah blah, what a waste of space" else echo "This user does NOT exists. Please create that user before using this script.\n" exit fi My problem is that I would ideally like to place a "not" if that first if statement so that I can trim down my if, else statement. Ideally I would like something like this: if !(id $User > /dev/null 2>&1) then echo "This user does NOT exists. Please create that user before using this script.\n" exit fi

    Read the article

  • Neues Statement Of Direction veröffentlicht

    - by carstenczarski
    Das APEX Entwicklerteam hat ein neues Statement Of Direction (SOD) für die Version 5.0 veröffentlicht. Wie immer wird es die Verbesserung und Erweiterung vorhandener und die Einführung neuer Funktionen geben. Wie immer, ist das Statement Of Direction dazu gedacht, die Pläne und Ziele des APEX-Entwicklerteams mit der Community zu teilen. Insofern ist für APEX 5.0 unter anderem geplant ... ... modale Dialoge deklarativ bereitzustellen ... den Drag and Drop Layout Editor zurückzubringen ... HTML5 noch besser zu unterstützen ... mehr Varianten und Möglichkeiten für PDF-Ausgabe bereitzustellen ... spezielle User Interfaces für Tablets einzuführen ... Master / Detail / Detail Formulare zu ermöglichen ... mehrerer Interaktive Berichte auf einer Seite zu erlauben ... und vieles weitere mehr. Die APEX-Erfolgsgeschichte geht also weiter.

    Read the article

  • How can I make an SQL statement that finds unassociated records?

    - by William Calleja
    I have two tables as follows: tblCountry (countryID, countryCode) tblProjectCountry(ProjectID, countryID) The tblCountry table is a list of all countries with their codes and the tblProjectCountry table associates certain countries with certain projects. I need an SQL statement that gives me a list of the countries with their country code that do NOT have an associated record in the tblProjectCountry table. so far I got to here: SELECT tblCountry.countryID, tblCountry.countryCode FROM tblProjectCountry INNER JOIN tblCountry ON tblProjectCountry.countryID = tblCountry.countryID WHERE (SELECT COUNT(ProjectID) FROM tblProjectCountry WHERE (ProjectID = 1) AND (countryID = tblCountry.countryID)) = 0 The above statement parses as correct but doesn't give the exact result I'm looking for. Can anyone help?

    Read the article

  • In an If-Else Statement for a method return, should an Else be explicitly stated if it can instead b

    - by ccomet
    I have a method that checks certain things and returns a Boolean based on those checks. It involves a single branching If section that checks about 5 conditions in sequence. If any of those conditions return true, then the method will return true;. If none of the conditions return true, then the method will return false;. Since the code after the If section will only run if none of the conditions are true, then that code is logically identical to including an actual Else statement. So is it a better idea to actually write in the Else statement for this kind of situation?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >