DB2 SQL syntax

in Sybase/SQL server, you can do conditional compound SQL like following:
begin transaction
begin
insert into blah values ("blah")
if(@@rowcount>0)
begin
update blah set blah = "blah" where blah = "blah"
end
end
commit transaction;Does anyone know to do that in DB2 SQL syntax?
Thanks alot.

Your question has nothing to do with Java, and I don't really understand it.
If you are talking about Subqueries, then all you need to use is brackets grouping different parts of the statement.

Similar Messages

  • Com.ibm.db2.jcc.b.SqlException: DB2 SQL Error: SQLCODE=-973, SQLSTATE=00000

    Hi,
    We are running WebLogic 10.3.0 on RHEL 5.3 with JRockit JDK 1.6 and DB2 Version 8 on mainframe running z/OS 1.9.
    We are getting below exception in webLogic logs from connection pool connecting to DB2 database.
    >
    ####<Jul 23, 2010 10:05:49 AM EDT> <Warning> <JDBC> <testing.us.test.net> <testingDB2> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1279893949615> <BEA-001129> <Received exception while creating connection for pool "TestDB2Pool": DB2 SQL Error: SQLCODE=-973, SQLSTATE=00000, SQLERRMC=MON_HEAP_SZ, DRIVER=3.53.70>
    ####<Jul 23, 2010 10:05:49 AM EDT> <Info> <JDBC> <testing.us.test.net> <testingDB2> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1279893949616> <BEA-001156> <Stack trace associated with message 001129 follows:
    com.ibm.db2.jcc.b.SqlException: DB2 SQL Error: SQLCODE=-973, SQLSTATE=00000, SQLERRMC=MON_HEAP_SZ, DRIVER=3.53.70
         at com.ibm.db2.jcc.b.bd.a(bd.java:679)
         at com.ibm.db2.jcc.b.bd.a(bd.java:60)
         at com.ibm.db2.jcc.b.bd.a(bd.java:127)
         at com.ibm.db2.jcc.b.jb.a(jb.java:4016)
         at com.ibm.db2.jcc.t4.bb.l(bb.java:403)
         at com.ibm.db2.jcc.t4.bb.d(bb.java:141)
         at com.ibm.db2.jcc.t4.b.Oc(b.java:1305)
         at com.ibm.db2.jcc.t4.b.b(b.java:1225)
         at com.ibm.db2.jcc.t4.b.B(b.java:5129)
         at com.ibm.db2.jcc.t4.b.c(b.java:783)
         at com.ibm.db2.jcc.t4.b.b(b.java:726)
         at com.ibm.db2.jcc.t4.b.a(b.java:409)
         at com.ibm.db2.jcc.t4.b.<init>(b.java:345)
         at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:197)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(ConnectionEnvFactory.java:316)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:217)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1109)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1033)
         at weblogic.common.resourcepool.ResourcePoolImpl.createResources(ResourcePoolImpl.java:574)
         at weblogic.jdbc.wrapper.Connection.run(Connection.java:268)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    >
    Below is snippet of my datasource configuration.
    <?xml version='1.0' encoding='UTF-8'?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/jdbc-data-source" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/jdbc-data-source http://www.bea.com/ns/weblogic/jdbc-data-source/1.0/jdbc-data-source.xsd">
    <name>TestingDB2</name>
    <jdbc-driver-params>
    <url>jdbc:db2://DB2.testing.us.com:50003/TestingDB</url>
    <driver-name>com.ibm.db2.jcc.DB2Driver</driver-name>
    <properties>
    <property>
    <name>maxRetriesForClientReroute</name>
    <value>2</value>
    </property>
    <property>
    <name>retryIntervalForClientReroute</name>
    <value>5</value>
    </property>
    <property>
    <name>user</name>
    <value>testuser</value>
    </property>
    <property>
    <name>resultSetHoldability</name>
    <value>2</value>
    </property>
    <property>
    <name>enableSysplexWLB</name>
    <value>true</value>
    </property>
    <property>
    <name>enableConnectionConcentrator</name>
    <value>true</value>
    </property>
    <property>
    <name>databaseName</name>
    <value>DB2QA</value>
    </property>
    <property>
    <name>maxTransportObjects</name>
    <value>108</value>
    </property>
    </properties>
    <password-encrypted>{3DES}eh4WI16Xb8E=</password-encrypted>
    </jdbc-driver-params>
    <jdbc-connection-pool-params>
    <initial-capacity>40</initial-capacity>
    <max-capacity>215</max-capacity>
    <capacity-increment>1</capacity-increment>
    <shrink-frequency-seconds>300</shrink-frequency-seconds>
    <highest-num-waiters>2147483647</highest-num-waiters>
    <connection-creation-retry-frequency-seconds>15</connection-creation-retry-frequency-seconds>
    <connection-reserve-timeout-seconds>10</connection-reserve-timeout-seconds>
    <test-frequency-seconds>300</test-frequency-seconds>
    <test-connections-on-reserve>true</test-connections-on-reserve>
    <ignore-in-use-connections-enabled>true</ignore-in-use-connections-enabled>
    <inactive-connection-timeout-seconds>300</inactive-connection-timeout-seconds>
    <test-table-name>SYSIBM.SYSDUMMY</test-table-name>
    <login-delay-seconds>1</login-delay-seconds>
    <statement-cache-size>300</statement-cache-size>
    <statement-cache-type>LRU</statement-cache-type>
    <remove-infected-connections>true</remove-infected-connections>
    <seconds-to-trust-an-idle-pool-connection>15</seconds-to-trust-an-idle-pool-connection>
    <statement-timeout>-1</statement-timeout>
    <pinned-to-thread>false</pinned-to-thread>
    </jdbc-connection-pool-params>
    <jdbc-data-source-params>
    <jndi-name>TestingDB2</jndi-name>
    <global-transactions-protocol>None</global-transactions-protocol>
    </jdbc-data-source-params>
    </jdbc-data-source>
    Please help me on this.
    - BoyelT

    Thanks Joe. I will test the standalone client program you provided.
    Below are links I found on web on SQL CODE -972 error message
    http://www.dbforums.com/db2/875633-sqlcode-973-sqlstate-57011-drda_heap_sz-cobol-db2-error.html
    http://publib.boulder.ibm.com/infocenter/tivihelp/v4r1/index.jsp?topic=/com.ibm.tpc_V411.doc/fqz0_r_tbs_db2_sql_973.html
    http://www-01.ibm.com/support/docview.wss?uid=swg1IY55389
    Below is explanation about this message
    ===============================================
    SQL0973N Not enough storage is available in the "<heap-name>" heap to process the statement.
    Explanation: All available memory for this heap has been used. The statement cannot be processed.
    User Response: Terminate the application on receipt of this message (SQLCODE). Increase the configuration parameter for "<heap-name>" to increase the heap size.
    ===============================================
    Can you please advise if this is the problem from DBMS side?

  • SQL Developer 1.1.0.21: Issues with Data Grid and SQL syntax checking

    In this new release of SQL Dev, when I execute a SQL in the SQL Worksheet and click in the Data Grid in the Results tab and try to navigate within a record using arrow keys, the grid cell enters into edit mode by default and so I cannot use the Left or Right arrow keys to navigate the grid. I am forced to use tab key to navigate. This is counter intuitive in my opinion.
    Is there any option to change this behavior?
    Another issue that I have come across is with SQL syntax checking. In some cases, when I press F9 to execute a SQL, it shows the SQL as executed i.e. shows something like 0.0134 seconds in the toolbar and no results displayed. In reality, the SQL had some syntax error which were NOT reported. This can be frustrating since now I have to fall back to SQL*Plus or TOAD just for syntax check.
    I like the fact that SQLDev highlights the current SQL but it would be more useful if it just indicated the first line of the current sql instead of highlighting the whole sql.
    Manish

    "In this new release of SQL Dev, when I execute a SQL in the SQL Worksheet and click in the Data Grid in the Results tab and try to navigate within a record using arrow keys, the grid cell enters into edit mode by default and so I cannot use the Left or Right arrow keys to navigate the grid. I am forced to use tab key to navigate. This is counter intuitive in my opinion."
    In the "Results" tab, Click Ctrl & Tab keys (at the same time) or with mouse click on any cell other than the first column (a sequence or rownum), you will be able to navigate using the arrow keys.
    "Another issue that I have come across is with SQL syntax checking. In some cases, when I press F9 to execute a SQL, it shows the SQL as executed i.e. shows something like 0.0134 seconds in the toolbar and no results displayed. In reality, the SQL had some syntax error which were NOT reported. This can be frustrating since now I have to fall back to SQL*Plus or TOAD just for syntax check."
    The 0.0134 seconds could be the result of the most recently executed successful statement. Check the Script Output tab for errors. Use F5 (Run Script option) instead of F9.
    "I like the fact that SQLDev highlights the current SQL but it would be more useful if it just indicated the first line of the current sql instead of highlighting the whole sql."
    On the SQL statement (or code), Right Click -> Format SQL (or press Ctrl & B), proper formatting would help.
    I use version 1.0.0.15.57 and seems to be working allright.
    - Babu Rangasamy

  • Sql syntax in jsp

    Hey All!
    Im trying ot use a a bean to select data from a table where email != ''
    The funny thing is my code works in one couple of jsp/bean but not in another, even though it's the exact same code.
    This works
    The Bean:
    String sql = "SELECT applicantid, firstname, lastname, dob, " +
    "homestreet, homestate, homecity, homezip, " +
    "email, college, major, standing, " +
    "graddate, schstreet, schcity, schstate, " +
    "schzip, schphone, resOne, resTwo, " +
    "resThree, waiver, bioletter, password, " +
    "homephone " +
    "FROM apptest " +
    "WHERE " + filter + " " +
    "ORDER BY " + orderBy;
    The filter is the String "email != ''" and orderBy ="lastname"
    Works perfectly!
    But when I use similar code for another table
    Code:
    String sql = "SELECT providerid, applicantid, pin, title, " +
    "company, firstname, lastname, phone, " +
    "email, recletter " +
    "FROM provtest " +
    "WHERE " + filter + " " +
    "ORDER BY " + orderBy;
    with filter as "email != '' " and orderBy = "lastname"
    I get the following error:
    Error in findRecords ProviderUtility(Syntax error or access violation, message from server: "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 '' at line 1")
    Keep in mind that email != '' (these are single quotes)
    I am really baffled.
    Ike

    "The funny thing is my code works in one couple of jsp/bean but not in another, even though it's the exact same code."
    If it's EXACTLY the same code, what did you need another bean for?
    If you needed a new bean, then it's not exactly the same.
    Why aren't you using PreparedStatement to escape strings and dates for you?
    Believe the engine when it tells you there's a mistake.
    %

  • SQL Syntax Issue

    This is a weird one!!!
    I am using Dreamweaver/php/mysql and I am in the process of
    developing the forms that edit articles that have been added to the
    CMS. I have a page called edit.php which has the current list of
    articles. Each article has a radio button next to it and have given
    it an id of "id" (which is what I called it in the DB). On
    selecting this article, and hitting submit, this should load up a
    editnews2.php. On editnews2.php I have a filtered recordset that
    filters on "id " so that it loads the article selected into the
    editnews2 form. I have bound the fields in the form to the related
    fields in the recordset.
    When I test this out using the TEST button, in the recordset
    pop-up window and enter an id, it retrieves the correct article
    from the database. However, when I do it using the forms, I get an
    error:
    "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 " at line 1"
    This is really weird because the recordset works and
    retreives the data no problems, which mean the connection file path
    is correct and other parameters are correct. I have tried lots of
    times to try and figure this out but I am now really stuck.
    Could anyone shed some light on this one?
    regards
    orange22

    orange22 wrote:
    > When I test this out using the TEST button, in the
    recordset pop-up window and
    > enter an id, it retrieves the correct article from the
    database. However, when
    > I do it using the forms, I get an error:
    >
    > "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 " at line 1"
    What that means is that the way Dreamweaver is building your
    query
    contains a mistake - probably an extra quotation mark or
    something like
    that.
    Go into Code view and use echo to display the actual SQL
    query being
    sent to the database. That will give you a clue as to where
    to start
    troubleshooting the rest of the code.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Error in SQL syntax

    Hi all,
    I have an SQL database which up untli about 20 minutes ago was fine.  I have a complex contact form whic is (was) all finished.  I have added a couple more tables to the database (now totalling 4), in order to create a registration / login page.
    (Is it okay to have 4 tables in 1 database?)
    Anyway.  I have just finished with the login stuff and all works fine.  I decided to have a quick look around the site and make sure everything is okay - but for some reason when I navigate to the "complex contact form" - I get this message:
    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 'ASCE LIMIT 0, 150' at line 1
    The registration wizard and login pages still work, and in general the site is browseable.  But this page will not work and I have no idea why?
    Does anyone have any suggestion?  All I have done since it worked is add 2 other tables as I said....
    Thank you / please help!
    NJ

    There was a typo in my previous post. There should be only one $ in $query_recordsetName. I should also have added that "recordsetName" is the name of your recordset. I would have thought it was obvious, but I see you're limiting the number of results, so the name is slightly different.
    The other thing is that you have not put it where I told you. Apart from that...
    $query_rscontacts1 = "SELECT contacts.Logo, contacts.Industries,
    contacts.coverage, contacts.misc, contacts.id, contacts.email,
    contacts.website FROM contacts WHERE {$NXTFilter_rscontacts1} ORDER BY
    {$NXTSort_rscontacts1}";
    $query_limit_rscontacts1 = sprintf("%s LIMIT %d, %d", $query_rscontacts1, $startRow_rscontacts1, $maxRows_rscontacts1);
    echo $query_limit_rscontacts1 . '<br />';
    $rscontacts1 = mysql_query($query_limit_rscontacts1, $Contacts) or die(mysql_error());

  • Error with SQL syntax

    I'm trying to get onto a website i could normally get into but all it says is this
    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 adlx.'action' !=  2' at line 1
    I'm not good with computers and I've never heard of this i need some help, I may just be stupid but i seriously need some help here
    preferably instructions for a hp computer

    This looks to be an error with the web site you are visiting, not a problem with your PC.  I suggest you contact the web site owner.  The error suggests a problem with programming against a MySQL database, which is not a Microsoft technology.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • ANSI SQL Syntax - What belongs to join-clause and what to where-clause

    Hello,
    we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
    Lets say there is a query like this:
    +SELECT *+
    FROM employees emp, departments dept
    WHERE emp.dept_country = dept.dept_country
    AND emp.dept_name = dept.dept_name
    AND dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
    Now I have rewritten the query to Ansi Syntax:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
    WHERE dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    +ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
    WHERE emp.emp_lastname = 'Smith'
    Can somebody tell me which on is correct?
    Is there any definition for that? I couldn't find it in the Oracle Database definition.
    I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
    I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
    Thank you in advance
    Marco

    Hi,
    As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
    This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
    From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
    Regards

  • SQL syntax error...

    SQL Syntax:
    select ename||'-'||job from emp
    Initially, I was using the .Net Framework Data Provider for Oracle and had no problem bringing up the Query Builder in VS 2008. However, when I use the ODP .Net from Oracle, I get an error when bringing up the Query Builder:
    Error in SELECT clause: expression near '|'.
    Unable to parse query text.
    It seems like when uing ODP .Net, it does not like the concatenation in the Select statment.
    Any clue why?

    Is this consistently reproducible for you? Is it query builder specific? What version of ODP are you using? I just tried this with 11.1.6.20 ODP and it worked fine..
    Cheers
    Greg
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    class Program
        static void Main(string[] args)
            using (OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger"))
                con.Open();
                using (OracleCommand cmd = new OracleCommand("select ename||'-'||job from emp", con))
                    Console.WriteLine(cmd.ExecuteScalar().ToString());
    }

  • CR2011 - SQL Syntax Error

    After updating our ODBC driver to match our current Unidata database version (7.1), we now get the following message from Crystal Reports 2011 on many of our existing reports:
    "Failed to retrieve data from the database. Details: 37000:[Rocket U2][U2ODBC][1401249]Error ID: 21 Severity: ERROR Facility: DBCAPERR - SQL Syntax error. [Database Vendor Code: 5365440]
    The generated SQL statement follows:
    SELECT "INVCDETH_NF"."ITEM_NBR", "ITEMMAST_NF"."ITEM_DESC", "INVCDETH_NF"."SHIPPED_QUANTITY", "INVCDETH_NF"."Z_INV_DATE", "INVCDETH_NF"."Z_COMPANY", "INVCHDRH_NF"."INVOICE_TYPE", "INVCDETH_NF"."EXTENDED_PRICE", "INVCDETH_NF"."COST_OF_SALES", "INVCDETH_NF"."Z_PCC_CODE", "INVCDETH_NF"."DISCOUNT_AMOUNT", "INVCDETH_NF"."WAREHOUSE", "ITEMMAST_NF"."PRICE_CODE", "INVCHDRH_NF"."INVOICE_NBR", "INVCHDRH_NF"."REFERENCE_NBR"
    FROM   ("Administrators"."ITEMMAST_NF" "ITEMMAST_NF" INNER JOIN "Administrators"."INVCDETH_NF" "INVCDETH_NF" ON "ITEMMAST_NF"."ITEM_NBR"="INVCDETH_NF"."ITEM_NBR") INNER JOIN "Administrators"."INVCHDRH_NF" "INVCHDRH_NF" ON ((("INVCDETH_NF"."INVOICE_NBR"="INVCHDRH_NF"."INVOICE_NBR") AND ("INVCDETH_NF"."INV_HEADER_ID"="INVCHDRH_NF"."INV_HEADER_ID")) AND ("INVCDETH_NF"."REFERENCE_NBR"="INVCHDRH_NF"."REFERENCE_NBR")) AND ("INVCDETH_NF"."RELEASE_NBR"="INVCHDRH_NF"."RELEASE_NBR")
    WHERE  "INVCDETH_NF"."Z_COMPANY"='01' AND "INVCDETH_NF"."WAREHOUSE"='086' AND ("INVCDETH_NF"."Z_INV_DATE">={d '2013-12-08'} AND "INVCDETH_NF"."Z_INV_DATE"<={d '2013-12-26'})
    ORDER BY "INVCDETH_NF"."WAREHOUSE"
    I downloaded the trial version of CR2013 and get the same result. Can anyone shed any light? Thanks!

    Yes, in that the query is what Crystal generated from the report being built in the designer. I simply copied it from the Database > Show SQL Query screen. Since the error I'm receiving is a SQL Syntax Error, I thought it would be appropriate to show it.
    The bottom line is that because I am not very knowledgeable in SQL, I can't look at the query and identify the error. However, I am responsible for supporting CR in-house. Naturally, I have reported this to Rocket (the makers of the ODBC driver) but haven't received their reply yet.

  • Parse sql syntax

    I have temp table inside my stored procedure:
    CREATE TABLE #tmpOrders(product_id VARCHAR(20))
    SELECT * FROM #tmpOrders o INNER JOIN dbo.products p ON o.productID=p.productID
    o.productID column doesn't exists. The join should be:
    ON o.product_id=p.productID
    But when I create procedure, parser doesn't raise an error. The error is raised at run time.
    Is there some option to check the SQL syntax before run time - to parse also temp table names?
    Thanks,
    Simon

    Hi Simon
    See my latest replay... I create a temporary table and then run CREATE PROCEDURE script to get the error, that was a mistake
    CREATE TABLE #t (c int)
    CREATE PROCEDURE sp1
    AS
    CREATE TABLE #t (c int)
    SELECT * FROM #t JOIN sys.objects o on #t.c1=o.object_id
    Msg 207, Level 16, State 1, Procedure sp1, Line 6
    Invalid column name 'c1'.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Simple SQL syntax problem

    Ok, I'm sure this is a very simple problem but I'm confused.
    Statement s = con.createStatement();
    s.execute("SELECT COUNT (*) FROM table WHERE id = 6 AND somechar = 'N'");java.sql.SQLException: Syntax error or access violation message from server: "You have an error in y
    our SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax
    to use near '(*) FROM table WHERE id = 6 AND somechar = 'N'' at line 1"
    This works fine when input into the phpMyAdmin database interface. Is there something blatantly wrong with my syntax, or...?

    Maybe it doesn't like the space between COUNT and (*)
    %Yuck.
    Yep, that was it. Thanks.
    Weird, I'm accustomed to programs ignoring most whitespace as long as it doesn't create ambiguity.

  • SQL syntax error when creating record insertion form

    Good day,
    I was hoping someone could help me.  I am trying to create a record insertion form on a website to insert data into a database table.  When attempting to create the form, I am getting the following error: 
    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 ' Organization, Office, Department, Phone, EmailAddress, JobTitle, `OfficialMaili' at line 1
    Not sure what is going on.  I am running windows 8 and DW cs5 w/ MYSQL.  I am testing on a local server prior to pushing to the remote server.
    Thank you for your assistance and please advise any code you would like me to send.

    Here is all the code from this particular webpage.  I apologize, I am too stupid to realize which parts are SQL vice PHP vice HTML:
    <?php require_once('Connections/group4.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
       if (PHP_VERSION < 6) {
         $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
         case "text":
           $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
           break;   
         case "long":
         case "int":
           $theValue = ($theValue != "") ? intval($theValue) : "NULL";
           break;
         case "double":
           $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
           break;
         case "date":
           $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
           break;
         case "defined":
           $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
           break;
       return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
       $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
       $insertSQL = sprintf("INSERT INTO individual (Grade, LastName, FirstName, M.I., Organization, Office, Department, Phone, EmailAddress, JobTitle, `OfficialMailing Address`, Citizenship, Designation, IATrainingComplete, IADate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                            GetSQLValueString($_POST['Grade'], "text"),
                            GetSQLValueString($_POST['LastName'], "text"),
                            GetSQLValueString($_POST['FirstName'], "text"),
                            GetSQLValueString($_POST['MI'], "text"),
                            GetSQLValueString($_POST['Organization'], "text"),
                            GetSQLValueString($_POST['Office'], "text"),
                            GetSQLValueString($_POST['Department'], "text"),
                            GetSQLValueString($_POST['Phone'], "double"),
                            GetSQLValueString($_POST['EmailAddress'], "text"),
                            GetSQLValueString($_POST['JobTitle'], "text"),
                            GetSQLValueString($_POST['OfficialMailing_Address'], "text"),
                            GetSQLValueString($_POST['Citizenship'], "text"),
                            GetSQLValueString($_POST['Designation'], "text"),
                            GetSQLValueString($_POST['IATrainingComplete'], "text"),
                            GetSQLValueString($_POST['IADate'], "text"));
      mysql_select_db($database_group4, $group4);
       $Result1 = mysql_query($insertSQL, $group4) or die(mysql_error());
      $insertGoTo = "index.php";
       if (isset($_SERVER['QUERY_STRING'])) {
         $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
         $insertGoTo .= $_SERVER['QUERY_STRING'];
       header(sprintf("Location: %s", $insertGoTo));
    mysql_select_db($database_group4, $group4);
    $query_rsIndividual = "SELECT * FROM individual ORDER BY IndividualNumber ASC";
    $rsIndividual = mysql_query($query_rsIndividual, $group4) or die(mysql_error());
    $row_rsIndividual = mysql_fetch_assoc($rsIndividual);
    $totalRows_rsIndividual = mysql_num_rows($rsIndividual);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contact Us</title>
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .header {
      font-size: 36px;
      text-decoration: underline;
    .quote {
      font-size: 18px;
      font-style: italic;
    .tablethisone {
      margin: 5px;
      padding: 25px;
      border: medium none #000;
      text-align: center;
    </style>
    </head>
    <body>
    <p><img src="Images/EGA.png" width="227" height="222" alt="EGA" /><span class="header">SAAR Tracking System
    </span></p>
    <ul id="MenuBar1" class="MenuBarHorizontal">
       <li><a href="index.php">Home</a>  </li>
       <li><a href="search.php">Search</a></li>
       <li><a href="contact.php">Contact Us</a>  </li>
    </ul>
    <p> </p>
    <p>PRIVACY ACT STATEMENT</p>
    <p>Executive Order 10450, 9397; and Public Law 99-474, the Computer Fraud and Abuse Act.
       To record names, signatures, and other identifiers for the purpose of validating the trustworthiness of individuals requesting
       access to Department of Defense (DoD) systems and information. NOTE: Records may be maintained in both electronic
       and/or paper form.</p>
    <p> </p>
    <p> </p>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
       <table align="center">
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Grade:</td>
           <td><input type="text" name="Grade" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">LastName:</td>
           <td><input type="text" name="LastName" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">FirstName:</td>
           <td><input type="text" name="FirstName" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">M.I.:</td>
           <td><input type="text" name="MI" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Organization:</td>
           <td><input type="text" name="Organization" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Office:</td>
           <td><input type="text" name="Office" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Department:</td>
           <td><input type="text" name="Department" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Phone:</td>
           <td><input type="text" name="Phone" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">EmailAddress:</td>
           <td><input type="text" name="EmailAddress" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">JobTitle:</td>
           <td><input type="text" name="JobTitle" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">OfficialMailing Address:</td>
           <td><input type="text" name="OfficialMailing_Address" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Citizenship:</td>
           <td><input type="text" name="Citizenship" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">Designation:</td>
           <td><input type="text" name="Designation" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">IATrainingComplete:</td>
           <td><input type="text" name="IATrainingComplete" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right">IADate:</td>
           <td><input type="text" name="IADate" value="" size="32" /></td>
         </tr>
         <tr valign="baseline">
           <td nowrap="nowrap" align="right"> </td>
           <td><input type="submit" value="Insert record" /></td>
         </tr>
       </table>
       <input type="hidden" name="MM_insert" value="form1" />
    </form>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p>Disclosure of this information is voluntary; however, failure to provide the requested information may impede, delay or
    prevent further processing of this request.</p>
    <p class="quote">&quot;Be polite, be professional, but have a plan to kill everybody you meet&quot; General James Mattis</p>
    <p> </p>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>
    <?php
    mysql_free_result($rsIndividual);
    ?>

  • Converting XPATH to SQL syntax?

    HI, all
    I am looking for a third party tool to convert XPATH syntax to SQL syntax?
    XPATH is primary syntax to retrieve and locate data in XML structre, while SQL is the stand syntax to operate data in RDBMS. Please assume I have a way to map XML data to RDBMS.
    Thanks in advance!
    Tao
    2002/11/15

    Did you ever find a solution?????... that�s exactly what I�m trying to do. Any help would be appreciated. Theres like no information on this stuff. Thanks
    bpfl

  • Sql syntax

    Can someone kindly tell me the correct syntax for this statement?
    String sql = "UPDATE answers SET q1 = '" + value + "'" + "WHERE EXISTS (SELECT * FROM users u, answers a WHERE u.username = a.username)";
    int numRows = stmt.executeUpdate(sql);
    The error I am getting is:
    Caught SQL Exception: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near 'EXISTS SELECT * FROM users u, answers a WHERE u.username = a.username' at line 1

    I am using a cookie instead. But, when I use an update, my values are the same for each column, not the appropriate values. Is my syntax below correct?
    String delete = request.getParameter("delete");
    String question = request.getParameter("question");
    String value = request.getParameter("R");
    Cookie[] cookies = request.getCookies();
    if (delete.equals("no") && !value.equals(""))
    if(cookies != null)
    for (int i = 0; i < cookies.length; i++)
    String name = cookies.getName();
    String valuecook = cookies[i].getValue();
    //Cookie getUser = new Cookie(name, valuecook);
    String sql = "UPDATE answers SET q1 ='" + value + "' " + "WHERE USERNAME = '" + valuecook + "'";
    int numRows = stmt.executeUpdate(sql);
    String sql2 = "UPDATE answers SET q2 ='" + value + "' " + "WHERE USERNAME = '" + valuecook + "'";
    int numRows2 = stmt.executeUpdate(sql2);
    String sql3 = "UPDATE answers SET q3 ='" + value + "' " + "WHERE USERNAME = '" + valuecook + "'";
    int numRows3 = stmt.executeUpdate(sql3);
    out.println(value);
    out.println(valuecook);
    // UPDATE table_name SET column_name1 = value1 [, column_name2 = value2, etc.] WHERE criteria
    out.println("Record has been inserted");
    String nextPage = request.getParameter("nextPage");

Maybe you are looking for

  • How to create a Warning or Error Message in LIV

    I am a Functional Team Member on Accounts Payables. We want to customize our errors for Payment Methods on Credit Memos on MIRO and MIR7 transactions. How do I do this?  Thanks!  David

  • Why is HP SimplePass on my new windows 8.1 machine, when I do not have a finger or card reader?

    Why is HP SimplePass on my new windows 8.1 machine, when I do not have a finger print or card reader? It keeps popping up and asking me to use it? Can it be used to keep my passwords? What Version of SimplePass are you using?   Unknown, apparently yo

  • Q: Can Oracle Access Manage achieve the following? WS-Fed(RP) - SAML2(IdP)

    Can Oracle Access Manager do protocol translation and act as a gateway for multiple SAML2 IdP's talking back to a WS-Fed (RP/SP) ? <-> SAML2 (IdP) (multiple namespaces) WS-Fed (RP) <-> SAML2 (IdP) (multiple namespaces) <-> SAML2 (IdP) Sincerely, Adam

  • 11.2.0.2 resources dependencies configuration.

    Hi all, I'm trying to configure an Oracle 10.2.05 db and a listener (10.2 version) as 11.2.0.2 GI cluster resources as if they were merely applications with an start/stop/check script. My goal is to define the dependencies so that these two resources

  • More shared variable help

    Yep, I'm attempting a large shared variable project, so, I guess it's time to get active on the board again.  Anyway, so I had this problem; http://forums.ni.com/t5/LabVIEW/Getting-a-list-shared-variable-references/td-p/1817829 but we got that figure