Problem inserting record using INSERT INTO

I am an amateur web builder using some ColdFusion functionality to access information on an Access database. I know very little about ColdFusion syntax, but I'm using Dreamweaver CS3 to help generate most of the code. I'm working on an insert record page to create a user database with login information. I'm not sure what the problem is, but I'm getting a syntax error referencing this particular portion of the code:
Syntax error in INSERT INTO statement.
The error occurred in C:\ColdFusion9\wwwroot\Everett\register.cfm: line 22
Below is the entire page with line 22 (referenced in the error message) in red. Any ideas?
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "register">
  <cfquery datasource="everettweb">  
    INSERT INTO Users ([First Name], [Last Name], [Email Address], Password)
VALUES (<cfif IsDefined("FORM.first_name") AND #FORM.first_name# NEQ "">
<cfqueryparam value="#FORM.first_name#" cfsqltype="cf_sql_clob" maxlength="255">
<cfelse>
</cfif>
, <cfif IsDefined("FORM.last_name") AND #FORM.last_name# NEQ "">
<cfqueryparam value="#FORM.last_name#" cfsqltype="cf_sql_clob" maxlength="255">
<cfelse>
</cfif>
, <cfif IsDefined("FORM.email") AND #FORM.email# NEQ "">
<cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_clob" maxlength="255">
<cfelse>
</cfif>
, <cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
<cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_clob" maxlength="255">
<cfelse>
</cfif>
  </cfquery>
  <cflocation url="register_success.cfm">
</cfif>
<!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"><!-- InstanceBegin template="/Templates/Main.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<link href="main.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Everett Music Department, Everett, MA</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
background-color: #660000;
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
//-->
</script>
<!-- InstanceBeginEditable name="head" -->
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
color: #660000;
a:visited {
color: #A01D22;
a:hover {
color: #FFCC00;
-->
</style>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body onload="MM_preloadImages('menu_about_over','menu_ensembles_over.jpg','menu_schools_over.j pg','menu_events_over.jpg','menu_faculty_over.jpg','menu_contacts_over.jpg','menu_home_ove r.jpg','menu_about_over.jpg','menu_links_over.jpg','menu_login_over.jpg')">
<table width="960" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><img src="top_border.jpg" width="960" height="20" align="top" /></td>
  </tr>
  <tr align="center">
    <td colspan="3"><a href="index.php"><img src="e_oval_top.jpg" height="100" width="270" border="0" /></a><a href="index.php"><img src="header.jpg" height="100" width="690" border="0" /></a></td>
  </tr>
  <tr>
    <td height="35" width="301"><a href="index.php"><img src="e_oval_bottom.jpg" height="35" width="234" border="0" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','menu_home_over.jpg',1)"><img src="menu_home.jpg" width="67" height="35" name="home" border="0" id="home" /></a></td>
    <td width="251"><ul id="MenuBar1" class="MenuBarHorizontal">
      <li><a class="MenuBarItemSubmenu" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('about','','menu_about_over.jpg',1)"><img src="menu_about.jpg" width="71" height="35" name="about" border="0" id="about" /></a>
        <ul>
          <li><a href="#">News</a></li>
          <li><a href="#">History</a></li>
          <li><a href="#">Media</a></li>
        </ul>
      </li>
      <li><a class="MenuBarHorizontal" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('ensembles','','menu_ensembles_over.jpg',1)"><img src="menu_ensembles.jpg" width="98" height="35" name="ensembles" border="0" id="ensembles" /></a>
        <ul>
          <li><a href="#">Band</a></li>
          <li><a href="#">Chorus</a></li>
          <li><a href="#">Strings</a></li>
        </ul>
      </li>
      <li><a class="MenuBarItemSubmenu" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('schools','','menu_schools_over.jpg',1)"><img src="menu_schools.jpg" width="82" height="35" name="schools" border="0" id="schools" /></a>
        <ul>
          <li><a href="#">Everett High School</a></li>
          <li><a href="#">English School</a></li>
          <li><a href="#">Keverian School</a></li>
          <li><a href="#">Lafayette School</a></li>
          <li><a href="#">Parlin School</a></li>
          <li><a href="#">Webster School</a></li>
          <li><a href="#">Whittier School</a></li>
        </ul>
      </li>
    </ul>
    </td>
           <td width="408"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('events','','menu_events_over.jpg',1)"><img src="menu_events.jpg" width="74" height="35" name="events" border="0" id="events" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('faculty','','menu_faculty_over.jpg',1)"><img src="menu_faculty.jpg" width="79" height="35" name="faculty" border="0" id="faculty" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('links','','menu_links_over.jpg',1)"><img src="menu_links.jpg" width="66" height="35" name="links" border="0" id="links" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('login','','menu_login_over.jpg',1)"><img src="menu_login.jpg" name="login" width="69" height="35" border="0" id="login" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','menu_contact_over.jpg',1)"><img src="menu_contact.jpg" width="100" height="35" name="contact" border="0" id="contact" /></a><img src="menu_spacer_end.jpg" width="20" height="35" /></td>
  </tr>
  <tr height="10">
    <td colspan="3"><img src="menu_bottom_spacer.jpg" height="10" width="960" /></td>
  </tr>
</table>
<table width="960" cellpadding="0" cellspacing="0" align="center">
  <tr height="50">
    <td width="30" background="left_border.jpg"><img src="clear.gif" width="30" height="50" /></td>
    <td width="900" bgcolor="#FFFFFF">
      <table width="900" cellpadding="0" cellspacing="0">
        <tr>
          <td width="900" height="350" valign="top"><!-- InstanceBeginEditable name="PageBody" -->
      <form action="<cfoutput>#CurrentPage#</cfoutput>" method="POST" name="register" preloader="no" id="register">
            <table width="100%">
              <tr>
                <td colspan="2" class="heading1">Fill in the information below to register for this site:</td>
              </tr>
              <tr>
                <td colspan="2"><img src="clear.gif" height="15" /></td>
              </tr>
              <tr>
                <td width="50%" class="form" align="right">First Name:</td>
                <td width="50%"><span id="sprytextfield1">
                  <input type="text" name="first_name" required="yes" id="first_name" width="150" typeahead="no" showautosuggestloadingicon="true" />
                  <span class="textfieldRequiredMsg">A value is required.</span></span></td>
              </tr>
              <tr>
                <td class="form" align="right">Last Name:</td>
                <td><span id="sprytextfield2">
                  <input type="text" name="last_name" required="yes" id="last_name" width="150" typeahead="no" showautosuggestloadingicon="true" />
                  <span class="textfieldRequiredMsg">A value is required.</span></span></td>
              </tr>
              <tr>
                <td class="form" align="right">Email Address:</td>
                <td><span id="sprytextfield3">
                <input type="text" name="email" validate="email" required="yes" id="email" width="150" typeahead="no" showautosuggestloadingicon="true" />
                <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
              </tr>
              <tr>
                <td class="form" align="right">Confirm Email Address:</td>
                <td><span id="sprytextfield4"><span id="ConfirmWidget">
                <input type="text" name="email_confirm" validate="email" required="yes" id="email_confirm" width="150" typeahead="no" showautosuggestloadingicon="true" />
                <span class="confirmInvalidMsg">The values do not match</span></span></span></td>
              </tr>
              <tr>
                <td class="form" align="right">Password:</td>
                <td><span id="sprytextfield5">
                  <input type="password" name="password" required="yes" id="password" width="150" />
                  <span class="textfieldRequiredMsg">A value is required.</span></span></td>
              </tr>
              <tr>
                <td class="form" align="right">Confirm Password:</td>
                <td><span id="sprytextfield6"><span id="ConfirmWidget">
                  <input type="password" name="password_confirm" required="yes" id="password_confirm" width="150" />
                  <span class="confirmInvalidMsg">The values do not match</span></span></span></td>
              </tr>
              <tr>
                <td> </td>
                <td><input name="submit" type="submit" id="submit" value="Register" /></td>
              </tr>
            </table>
      <input type="hidden" name="MM_InsertRecord" value="register" />
      </form>
      <script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "email");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "email");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5");
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6");
//-->
</script>
<script type="text/javascript">
var ConfirmWidgetObject = new Spry.Widget.ValidationConfirm("sprytextfield4", "email");
var ConfirmWidgetObject = new Spry.Widget.ValidationConfirm("sprytextfield6", "password");
</script>
          <!-- InstanceEndEditable --></td>
        </tr>
      </table>
    </td>
    <td width="30" background="right_border.jpg"><img src="clear.gif" width="30" height="50" /></td>
  </tr>
  <tr>
    <td colspan="3" background="footer.jpg" class="footer" height="80"/>This website best viewed using:<br /><a href="http://www.firefox.com"><img src="firefox_logo.gif" width="110" height="40" border="0" /></a></td>
  </tr>
</table>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
<!-- InstanceEnd --></html>

Syntax error in INSERT INTO statement.  INSERT INTO Users ([First Name], [Last Name], [Email Address], Password)
That oh-so-uninformative error is because "Password" is a reserved word with your database driver.  Either escape it by putting square brackets around it too, or rename the column permanently. It is best to avoid using reserved words whenever possible. So renaming the column is the better option.  Also, I would try and avoid using invalid characters like spaces in column names ie "First Name". It is technically allowed, but it requires special handling everywhere which adds unecessary complexity.
I'm not sure what the problem is, but I'm getting a syntax error referencing this particular portion of the code:
Do not take the error line numbers as gospel. Sometimes they just indicate that the error is within the vincinty of that line.
I'm using Dreamweaver CS3 to help generate most of the code
Unforutnately, DW wizards generate some truly awful and verbose code.  To give you an idea, here is what the query should look like, without all the wizard nonsense.
  <cfparam name="FORM.first_name" default="">
  <cfparam name="FORM.last_name" default="">
  <cfparam name="FORM.email" default="">
  <cfparam name="FORM.FORM.password" default="">
  <cfquery datasource="YourDSNName"> 
    INSERT INTO Users ([First Name], [Last Name], [Email Address], [Password])
    VALUES (
      <cfqueryparam value="#FORM.first_name#" cfsqltype="cf_sql_varchar">
     , <cfqueryparam value="#FORM.last_name#" cfsqltype="cf_sql_varchar">
     , <cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_varchar">
     , <cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_varchar">
  </cfquery>
CF is pretty easy to learn. You might want to begin perusing the CF documentation and a few tutorials to get more familiar with the language. Since you are working with a database, I would also recommend a  SQL tutorial.

Similar Messages

  • Quite complext problem - INSERT into PAYMENTS

    I am trying to use the following code to insert data into the payments table. The code does work, the user is prompted for the order number (3 times - but this is ok). The fnext time this code is used the order number previously entered is used again without the user being prompted. This assignment is due in next week so any help would be great. The code is:
    INSERT into Payments values(Payments_seq.nextval, '&order_no', initcap('&Payment_Method'),
    (select sum(order_details.cost) from order_details WHERE '&order_no' = order_details.order_no),
    (select (orders.date_of_order+7) FROM orders where '&order_no' = orders.order_no), &Amount_Paid);
    The table we want to enter details is called 'payments' but we want details taken from order_details which is another table.
    Pam

    Use "&&order_no" to prevent re-prompting.
    Use "UNDEFINE order_no" to unset the variable.
    btw the problem would seem to be to do with setting and clearing SQL*Plus substitution variables, and nothing to do with inserting, payments tables or query complexity.

  • Problem inserting into tables

    Hello All, I hope that someone out there may be able to shed some light on my problem!!
    I have developed a series of JSP pages for my web site (using Tomcat 4.1)to allow a Customer to register themselves with the site. I have developed 3 corresponding JavaBeans to hold the details that the customer enters; a Customer bean, an Address bean and a Payment bean. In my database (MySQL) i have tables corresponding to each of these beans, which simply take the data inserted into a field by the user and create a new instance of each.
    Now, the above is all working fine and the database tables populate themselves exactly as they should; however, to allow a customer to add more than one address, or more than one payment method, I have developed the relationship tables 'hasaddress' and 'haspaymentdetails' to store the relevant id numbers in the database (i.e. hasaddress stores a customerid from the customer bean and an addressid from the address bean).
    Finally, i get round to my question!!..
    I am using the following jsp code to insert data into one such table:
    <------------------------------------------------------------------->
    <jsp:useBean id="registration" class="projectBeans.RegistrationBean" scope="session"/>
    //set the connection
    registration.setConnection(c);
    //retrieve the customer attribute
    projectBeans.Customer customer = (projectBeans.Customer)session.getAttribute("newCust");
    //retrieve the address attribute
    projectBeans.AddressBean address = (projectBeans.AddressBean)session.getAttribute("newAddr");
    //use the addCustomer method in the bean to create a new customer     
    registration.addCustomer(customer);
    //ditto for address
    registration.addAddressDetails(address);
    //populate the hasaddress table with the correct ids
    String table = "hasaddress";
    int customerid = customer.getCustomerId();
    int addressid = address.getAddressId();
    registration.updateRelationship(table, customerid, addressid);Both the addCustomer and addAddressDetail methods work fine, so below is just the code for updateRelationship method in the registrationBean:
    public void updateRelationship(String table, int id1, int id2) throws SQLException
       sta = c.prepareStatement("INSERT INTO "+table +" VALUES(?,?)");
       sta.setInt(1, id1);
       sta.setInt(2, id2);
       sta.executeUpdate();
    }I would expect this method to retrieve the newly assigned customer and address ids and enter them into the hasaddress table; however, when the page compiles and i look at the table it enters 0 for each of the fields (when it should, for example be entering 14 and 16):
    ----------+
    | cid | aid |
    ----------+
    | 0 | 0 |
    ----------+
    so my question is: does anyone have an idea as to why this is happening, or what may be wrong with my code for this to occur?
    Alternatively, am i being dumb and is there some way of getting MySql to handle the updates to the relationship table internally?
    Thanks in advance for any ideas,
    Cheers

    Try to specify you database field as SQL need field names to do updating
    sta = c.prepareStatement("INSERT INTO "+table + "("+ id1+","+id2+ ")"+ VALUES(?,?)");

  • Problem inserting into access database.

    I am using the following code to create a table and insert values into an access database. Problem is that it only inserts the first 3 values no matter what order they are in. Any help is appreciated, and thanks in advance.
          stmt.executeUpdate("CREATE TABLE HardDrive (HardDriveID VARCHAR(10),"           + " HardDriveName VARCHAR(30), HardDriveSize VARCHAR(6), Price CURRENCY)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD3000HLFS','Western Digital VelociRaptor','300 GB',229.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST31000528AS','Seagate Barracuda','1 TB',99.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST3250310AS','Seagate Barracuda','250 GB',47.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD10EADS','Western Digital Caviar Green','1 TB',89.99)");

    What did I tell you about not using Access?
    This is exactly why. This is an Access related issue, and one that has been discussed many times previously on this site.
    Choose. Another. Database.

  • Problem Inserting into object view with OracleXmlSave

    Gurus,
    I'm trying to insert into an object view with
    multiple collections of objects representing a master/detail relationship and a CLOB column, but I've this error:
    oracle.xml.sql.OracleXMLSQLException: Error Interno
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1967)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1060)
    at onix.interface_isbn.OnixXmlLoader.doInsert(OnixXmlLoader.java:165)
    at onix.interface_isbn.OnixXmlLoader.setLoader(OnixXmlLoader.java, Compiled Code)
    at onix.interface_isbn.OnixXmlLoader.<init>(OnixXmlLoader.java:23)
    at onix.interface_isbn.correrLoader.main(correrLoader.java:77)
    I'm using OracleXmlSave with insertXML method to do this.
    Is There any limitations to do that? (example
    number of tables into the view, columns datatype).
    I'd appreciate any comments
    Thank

    No known limitations. Please post the sample DDL to create your object types and object view, along with an example of the example XML document you're trying to insert.

  • Problem inserting into DB from XML using XSQL

    Hi everyone!
    I try to load an XML document into a DB table, for the moment i only get access to a MySQL DB server, but i hope to use ORACLE soon. My problem is the next one:
    when i try to execute an insert query against the DB server it always fails, i get no problem doing another operation like select and so on. I have try in several ways:
    1. From a XSQL page using the tags xsql:insert-request, in the case the error looks like:
    Action xsql:insert-request
    Message org.gjt.mm.mysql.jdbc2.Connection
    2. I also have try the MoreoverIntoNews java examples, and the problem seem similar:
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
    org.gjt.mm.mysql.jdbc2.Connection
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1967)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1060)
    at MoreoverIntoNewsstory.main(MoreoverIntoNewsstory.java:43)
    How can i fix this problem?
    I also have realize that when i remove from the CLASSPATH the file "classes12.zip" then i
    get next exception:
    java.lang.NoClassDefFoundError: oracle/sql/CLOB
    Then it seems that the XML-SQL utilities (XSU) are only to work with Oracle and not with other DB engine.
    Thanks in advance.
    Marcos.

    Is there a solution to this problem? Does anyone have any suggestions?

  • Queries to retrieve records (using Coldfusion) into arrays

    I have been reading about Coldfusion and Flex/Flash Builder integration, I am quite the beginner here. So far, I was able to follow the examples I found at Adobe's website. Those tutorials show how to bind the query results into forms. What I want to do is to run a query that will return multiple records, and I would like to store those records in an array. In other words I want to access each of the elements of each object by iterating
    Here is an example (I am only putting the relevant part of the code here) of what I could achieve with binding so far
                protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
                    getEmployeeDataByRegionResult.token = salesTarget.getEmployeeDataByRegion(/*Enter value(s) for */ 'Central');
              <s:CallResponder id="getEmployeeDataByRegionResult"/>
        <mx:DataGrid x="477" y="118" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getEmployeeDataByRegionResult.lastResult}">
            <mx:columns>
                <mx:DataGridColumn headerText="PHONE" dataField="PHONE"/>
                <mx:DataGridColumn headerText="FIRSTNAME" dataField="FIRSTNAME"/>
                <mx:DataGridColumn headerText="YTD" dataField="YTD"/>
                <mx:DataGridColumn headerText="Q1GOAL" dataField="Q1GOAL"/>
                <mx:DataGridColumn headerText="EMAIL" dataField="EMAIL"/>
                <mx:DataGridColumn headerText="LASTNAME" dataField="LASTNAME"/>
            </mx:columns>
        </mx:DataGrid>
    So instead of this, I basically want to load the results into an array, so that I can iterate through the records as I want. A mysql query in php type of query is exactly what I am looking for. For example
    $result = mysql_query("SELECT id, name FROM mytable WHERE .... ");
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        printf("ID: %s  Name: %s", $row[0], $row[1]); 
    Thank you

    hi,
    this thread may interest you
    http://forums.adobe.com/message/2834411#2834411
    David.

  • JDBC- How Update record using preparedStatement() into  MS Access?

    Actually i got an error when i update the record,The setString() Parameter are stored in terms of arrays .
    The Error is
    ErrorSQL3.java.sql.SQLException:[Microsoft][ODBC Microsft Access Driver] Syntax Error in UPDATE Statement

    Actually i got an error when i update the record,The
    setString() Parameter are stored in terms of arrays
    The Error is
    ErrorSQL3.java.sql.SQLException:[Microsoft][ODBC
    Microsft Access Driver] Syntax Error in UPDATE
    Statement
    Believe the error message - your SQL syntax is wrong.
    Either fix it or post what you have and get some advice.
    %

  • INSERT INTO with SELECT CASE

    Hi all,
    I've this problem: insert into Table_A some values from Table_B... with one derivated/calculated filed.
    Example
    INSERT INTO Table_A (id_part, vendtype, origin, proven, desc)
    SELECT id_p, vendt, origin, proven, <calculate/derivated_field_desc>
    FROM Table_BThe rules for calculate the field desc inserted on Table_A are 1. IF vendt='V' AND origin='N' AND proven!='04' THEN ---> desc='TRANSFER'
    2. IF vendt='M' AND origin='N' AND proven!='04' THEN ---> desc='IMPORTED'
    3. IF proven='04' THEN ---> desc='BAD'So what I use in <calculate/derivated_field_desc> on my INSERT INTO statement??
    Can I use a SELECT CASE WHEN... or only DECODE is a right solution?
    Edited by: trebbia on 15-nov-2010 12.51

    Ok,
    I prefer use select case when... because trasform my rules in DECODE statement is more difficult
    So I write: INSERT INTO Table_A (id_part, vendtype, origin, proven, desc)
    SELECT id_p, vendt, origin, proven, SELECT CASE WHEN vendt='V' AND origin='N' AND proven!='04' THEN 'TRANSFER'
                                                    WHEN vendt='M' AND origin='N' AND proven!='04' THEN 'IMPORTED'
                                                    WHEN proven='04 THEN 'BAD'
                                                    END
    FROM Table_BObtain this error:
    40/56 PL/SQL: ORA-00936: missing expression
    33/1 PL/SQL: SQL Statement ignored
    PS: I use '<' '>' and not '!=' in my code... here not prompted correctly '<''>'
    Edited by: trebbia on 15-nov-2010 13.04
    Edited by: trebbia on 15-nov-2010 13.06

  • APEX 4.0 install error - insert into wwv_flow_flash_map_regions

    Hi guys,
    just to let you know, I have just tried to install apex_4.0.zip into my local 11.2 instance on Windows7.
    I was hitting the following problem:
    insert into wwv_flow_flash_map_regions(id,file_id,region_id,region_name,centroid_x,centroid_y) values(223,9,'DNK-VBR','V
    iborg','9.06804513931274','56.6578197479248')
    FEHLER in Zeile 1:
    ORA-01722: Ungnltige Zahl
    After setting
    set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252 before starting sqlplus and then running the apexins.sql script it worked fine.
    My NLS settings in the registry are as follows:
    NLS_LANG=GERMAN_GERMANY.WE8MSWIN1252
    Cheers,
    Dietmar.

    New files will be available between 11:30 - 12 PT that will fix this issue. Please download again after that time.
    -- Sharon

  • Using combination of insert into and select to create a new record in the table

    Hello:
    I'm trying to write a stored procedure that receives a record locator parameter
    and then uses this parameter to locate the record and then copy this record
    into the table with a few columns changed.
    I'll use a sample to clarify my question a bit further
    -- Create New Amendment
    function create_amendment(p_mipr_number in mipr.mipr_number%TYPE, p_new_amendment_number in mipr.amendment_number%TYPE)
    return integer is
    new_mipr_id integer;
    begin
    THIS is causing me grief See comments after this block of code
    insert into mipr
    (select mipr_id from mipr where mipr_number=p_mipr_number),
    (select fsc from mipr where mipr_number=p_mipr_number),
    45,
    (select price from mipr where mipr_number=p_mipr_number),
    practical,
    (select part_number from mipr where mipr_number=p_mipr_number);
    THe above will work if I say the following
    insert into mipr
    (select * from mipr where mipr_number=p_mipr_number);
    BUt, Of course this isn't what I want to do... I want to duplicate a record and change about 3 or 4 fields .
    How do I use a combination of more than one select and hard coded values to insert a new record into the table.
    /** Ignore below this is fine... I just put a snippet of a function in here ** The above insert statement is what I need help with
    select (mipr_id) into new_mipr_id from mipr where mipr_number=p_mipr_number + amendment_number=(select max(amendment_number) + 1);
    return new_mipr_id;
    end;
    THANK YOU IN ADVANCE!
    KT

    function create_amendment(p_mipr_number in mipr.mipr_number%TYPE)
    return integer is
    new_mipr_id integer;
    tmp_number number;
    tmp_mipr_id integer;
    begin
    tmp_number :=(select max(amendment_number) from mipr where mipr_number=p_mipr_number);
    Question:
    tmp_number :=1; works..
    tmp_number doesn't work with the select statement?
    Obviously I'm a novice! I can't find anything in my book regarding tmp variables... What should I look under is tmp_number a
    variable or what? In my Oracle book, variable means something different.
    Thanks!
    KT
    I have the following code in my stored procedure:
    Good luck,
    Eric Kamradt

  • Problem inserting records in table using cursors

    hi all
    i have a block in which i m trying to take records from a table pass it to a procedure which in turn calls some procedures
    and than the procesed records are dumped into another table
    this is my code
    set serveroutput on
    declare
    lastcall date;
    srcip varchar2(50);
    username varchar2(50):='9204';
    duration number;
    callto varchar2(50);
    accountid varchar2(50);
    calltime date;
    subscriberid varchar2(50);
    country varchar2(50);
    cost varchar2(50);
    CURSOR process_cdr
              IS
    SELECT
              srcip,
              username,
              callto,
              calltime,
              duration
    FROM rawcdr
    WHERE     calltime>lastcall;
    begin
    select max(calltime_gmt) into lastcall from
    processed_cdr;
    open process_cdr;
    fetch process_cdr into srcip,username,callto,calltime,duration;
    dbms_output.put_line(callto);
    if (instr(callto,'00')=5) then
    callto:=SUBSTR(REPLACE(callto,SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 3, 50);
    dbms_output.put_line(callto);
    elsif (instr(callto,'011')=5) then
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 4, 50);
    dbms_output.put_line(callto);
    else
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') +1 , 50);
    end if;
    process_call(srcip,username,duration,callto,accountid,subscriberid,country,cost);
    dbms_output.put_line(cost);
    dbms_output.put_line('trying to insert');
    insert into processed_cdr values(accountid,subscriberid,srcip,username,callto,country,calltime,duration,cost) ;
    dbms_output.put_line('inserted successfully');
    FETCH process_cdr INTO srcip, username, callto, calltime, duration;
    close process_cdr;
    end;
    now the problem is that
    records are not getting inserted nor an error is shown
    i guess i m not that much familiar with cursors
    and thats creating prob
    please help

    Hallo,
    but you haven't a loop ! :-)
    Try this,
    (not tested)
    set serveroutput on
    declare
    lastcall date;
    srcip varchar2(50);
    username varchar2(50):='9204';
    duration number;
    callto varchar2(50);
    accountid varchar2(50);
    calltime date;
    subscriberid varchar2(50);
    country varchar2(50);
    cost varchar2(50);
    CURSOR process_cdr
    IS
    SELECT
    srcip,
    username,
    callto,
    calltime,
    duration
    FROM rawcdr
    WHERE calltime>lastcall;
    begin
    select max(calltime_gmt) into lastcall from
    processed_cdr;
    open process_cdr;
    LOOP
    fetch process_cdr into srcip,username,callto,calltime,duration;
    EXIT WHEN process_cdr%NOTFOUND;
    dbms_output.put_line(callto);
    if (instr(callto,'00')=5) then
    callto:=SUBSTR(REPLACE(callto,SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 3, 50);
    dbms_output.put_line(callto);
    elsif (instr(callto,'011')=5) then
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 4, 50);
    dbms_output.put_line(callto);
    else
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') +1 , 50);
    end if;
    process_call(srcip,username,duration,callto,accountid,subscriberid,country,cost);
    dbms_output.put_line(cost);
    dbms_output.put_line('trying to insert');
    insert into processed_cdr values(accountid,subscriberid,srcip,username,callto,country,calltime,duration,cost) ;
    dbms_output.put_line('inserted successfully');
    /* Second fetch is not needed
    --FETCH process_cdr INTO srcip, username, callto, calltime, duration; */
    END LOOP;
    close process_cdr;
    COMMIT; -- eventually
    end;You didn't answered - do you do COMMIT elsewhere ?
    I placed COMMIT also, if you don't need it, you can comment it
    Regards
    Dmytro

  • Insert into another table using record

    Hi all, i am reading from TableA , need to sort the records and insert the sorted order in table B, and need some help with the coding, would appreciate if anyone can help.
    I am using records
    create or replace procedure ZZ AS
    DECLARE
    CURSOR GEN_CUR IS
         select *
         FROM TABLE_A;
            ORDER BY field_1 ASC;
         info_rec GEN_CUR%ROWTYPE;
         BEGIN
              open GEN_CUR;
              LOOP
                   FETCH gen_cur INTO info_rec;
                   EXIT WHEN gen_cur%NOTFOUND;
                   -- i need to insert the record into table_B. table_B's fields are identical to table_A, but am unsure of the code.
              END LOOP;
              CLOSE gen_cur;
         END;Message was edited by:
    learningoracle

    From Oracle 9.2 onwards we can do clever things with records:
    SQL> select * from tab1
      2  /
    K F
    Z X
    A X
    SQL> declare
      2     r tab1%ROWTYPE;
      3  begin
      4     for r in ( select * from tab1 order by key ) loop
      5       insert into tab12 values r;
      6     end loop;
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SQL> select * from tab12
      2  /
    K F
    A X
    Z X
    SQL> But as K Richards has pointed out you can do this with a straight INSERT ... SELECT statement...
    SQL> roll
    Rollback complete.
    SQL> insert into tab12
      2  select * from tab1 order by key
      3  /
    2 rows created.
    SQL> select * from tab12
      2  /
    K F
    A X
    Z X
    SQL> Note that sort order is only guaranteed when we use an ORDER BY clause.
    Cheers, APC

  • Problem with using INSERT INTO script

    Hi guys,
    I was trying to duplicate a table with the following script:
    CREATE TABLE TAB3(
    KEYATTR     NUMBER(3)     NOT NULL,
    BODY1     CHAR(1000)     NOT NULL,
    BODY2      CHAR(1000)     NOT NULL,
    BODY3     CHAR(1000)     NOT NULL,
         CONSTRAINT TAB3_PKEY PRIMARY KEY(KEYATTR) )
    INSERT INTO TAB3
         SELECT      *           
         FROM system.table3
         ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) DESC, KEYATTR DESC
    However, when I execute the script, I keep getting a 'missing right parenthesis' error. Any idea what went wrong?

    You don't need braces.
    Just
    INSERT INTO TAB3
    SELECT *
    FROM system.table3
    ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) DESC, KEYATTR DESCshould work.

  • Problem inserting a gif into a blob field in a table with sqldev / forms6i

    Problem solved - For those that might be interested, the errors don't make much sense - the problem was with the gif. Seems that these 28 gifs plus the new scans were saved from the scanner with
    GIF - LZW, Transparent color: 255
    Converting them to Black and white allowed them to be loaded.
    If anyone understands why, I'd like to know
    glenn
    I was previously having a problem deleting a row with a blob and it was suggested that I create the table using rowdependencies - which I did as follows.
    CREATE TABLE "MDD"."MDD_FIGURE2"
    (     "FG_FIGURENAME" VARCHAR2(18 BYTE),
         "FG_FIGURE" BLOB,
         CONSTRAINT "FG_FIGURENAME_NN" CHECK ("FG_FIGURENAME" IS NOT NULL) ENABLE
    ) ROWDEPENDENCIES;
    Then I copied my data from my previous table with the following - and everything came across
    INSERT INTO MDD_FIGURE2 (fg_figurename, fg_figure)
    SELECT FIG_FIGNAME, FIG_FIGURE FROM MDD_FIGURE;
    mdd_figure2 was then renamed to mdd_figure
    The table, Mdd_Figure, already contains some 2000+ .gifs that were successfully loaded with Forms 6i (yes, I know it is old, but I am stuck with having to use it). All the .gifs I am loading are from scans and all are less than 64k. However, 28 .gifs would not load. When I insert the .gif into the field and committed the form, the status message tells me a record was written but when I check it, the blob is empty.
    So, when I try to insert one of these problem .gifs in SqlDeveloper, I open the new mdd_figure table, select the blob field, open the edit dialog, set it to figure, select the .gif that I want to load and then save it. The blob field changes from NULL to BLOB, but it is empty. When I try to commit, I get the following error from SqlDev.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAlAAz' AND ORA_ROWSCN = '358136842'
    One error saving changes to table "MDD"."MDD_FIGURE":
    Row 14: ORA-01410: invalid ROWID
    I use rollback to restore the record to it's previous state.
    If I load one of the successfully loaded .gifs into the same field, it loads perfectly as follows.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAoAAp' AND ORA_ROWSCN = '358136522'
    Commit Successful
    It appears the 28 gifs have a problem. I've re-scanned them, with the same results. They are just small scanned line map images from our earlier publications. They view properly in several different graphics programs and I can't find anything wrong with them.
    I notice that the ROWID's are different while the ORA_ROWSCN's are the same - but what is the significance of that?
    Any suggestions as to what is happening and what I can do about it?
    Thanks for any help you can give me.
    glenn
    (Database is 10R2 and sqldev is the most recent one)
    Edited by: gconley on Sep 25, 2008 9:51 PM

    solved it myself - problem was with the gif

Maybe you are looking for

  • HTMLDB_ITEM report with 'Drill Down'

    I have created a report using the HTMLDB_ITEM Package and I would like to link to a form to add more detail. I have tried to create this using the tools but it assigns the value of the hyperlink to #column heading# which is not working. Am I missing

  • Can i print from iPad wireless to my printer w/o getting an Air printer?

    I have a router that can print from my PC or from my Lenovo laptop wirelessly to a Canon printer that is wired to the router via an ethernet cable. is there some way to get the iPad to see the printer without having to buy on of those Air Printers? i

  • ITunes free songs are not free

    The weekly song says "free" but to download it one must enter a credit card number. This is not free. I must pay for the song by providing priveledged information that has nothing to do with the transaction. Why must I provide potential access to my

  • Should I do a fresh install?

    Hey guys, I purchased my unibody macbook (Intel core 2 duo 2.4 GHz, 4GB ram, 256 SSD, NVIDIA GeForce 9400M 256MB, running 10.7.2) in April of 2009 and have been using it exclusively ever since. Recently, my computer has begun to slow down quite a bit

  • Is it possible to launch native app through third party app.

    I am making the app in which I want to launch the others app,I am able to launch the third party app but not the mobile native app. Is it possible to launch native app through third party app. Thanks in advance. Solved! Go to Solution.