Syntax error in For Loop statement

Hello
Normally my FOR staements have not been a problem as only access one table. I the example below I am accessing three table and therefore I get a Syntax error.
I only wish to select the "Product" recored but need the other table to enable the select the right results.
FOR product_rec IN (SELECT * from PRODUCT, PRODUCT_GROUP,PROD_PROD_GROUP
where PRODUCT_GROUP.PRODUCT_GROUP_KEY = PROD_PROD_GROUP.PRODUCT_GROUP_KEY
and PROD_PROD_GROUP.PRODUCT_KEY = PRODUCT.PRODUCT_KEY
and product.supplier_key = company_no
and PROD_PROD_GROUP.MULTI_WEB_DIS = 1
order by PROD_PROD_GROUP.MULTI_WEB_SEQ)
Can anyone let the correct syntx for this statement.
Thanks
Pete

Like Dom said:
FOR product_rec IN (SELECT PRODUCT.* from PRODUCT, PRODUCT_GROUP,PROD_PROD_GROUP
where PRODUCT_GROUP.PRODUCT_GROUP_KEY = PROD_PROD_GROUP.PRODUCT_GROUP_KEY
and PROD_PROD_GROUP.PRODUCT_KEY = PRODUCT.PRODUCT_KEY
and product.supplier_key = company_no
and PROD_PROD_GROUP.MULTI_WEB_DIS = 1
order by PROD_PROD_GROUP.MULTI_WEB_SEQ) Or what he meant by "nice to have", use aliases:
select p.*
from
  product p,
  product_group pg,
  prod_prod_group ppg
where
  pg.product_group_key = ppg.product_group_key
  and ppg.product_key = p.product_key
  and p.supplier_key = company_no
  and ppg.multi_web_dis = 1
order by
  ppg.multi_web_seqAlso, note that company_no is not aliased in the above query. If this is a column, it should be aliased as well (either with the full table name or the alias if you switch to using them). If it is a PL/SQL variable, it is fine as is.
Edited by: cmartin2 on Feb 2, 2011 1:56 PM

Similar Messages

  • Where is the syntax error in my Insert statement?

    It says that there is a syntax error in my insert statement, pointing to the .ExecuteNonQuery() at the end:
    'Defining the activity ID from the datatable
    Dim ActivityID As Integer = DataTableActivities.Rows(0).Item(0)
    'Defining the calories from the datatable
    Dim calories As Decimal = (DataTableActivities.Rows(0).Item(3)) * (DurationNum.Value / 60)
    'Insert statement to add new training events
    Dim SqlQueryActivityInsert As String = "INSERT INTO tblTraining (RunnerID, ActivityID, Full_Name, Time, Calories_Burnt, Date) VALUES (@RunnerID, @ActivityID, @Full_Name, @Time, @Calories, @Date)"
    Dim SqlCommandActivity As New OleDbCommand
    With SqlCommandActivity
    .CommandText = SqlQueryActivityInsert
    .Parameters.AddWithValue("@RunnerID", LoginForm.UserIDlbl.Text)
    .Parameters.AddWithValue("@ActivityID", ActivityID)
    .Parameters.AddWithValue("@Full_Name", LoginForm.Full_Namelbl.Text)
    .Parameters.AddWithValue("@Time", DurationNum.Value)
    .Parameters.AddWithValue("@Calories", calories)
    .Parameters.AddWithValue("@Date", WeekPicker.Value)
    .Connection = conn
    .ExecuteNonQuery()

    Viorel is right.  The 'Date' field is probably throwing it off.  Date is a reserved word. 
    https://www.drupal.org/node/141051
    Putting square brackets [] around the field name should get it working for you.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • "Syntax error in the MDX statement " in Process chain failure??Urgent pls

    Hi Experts,
    could any one suggest me the procedure to rectify the below problems in process chain?
    1."Syntax error in the MDX statement "
    2."Error when getting data (Error when getting data (AXI))"
    Rgds,
    BH

    In which case it'll be that Access has a different date format to MySQL, and you're trying to push the string "'25-Apr-12 10:55 PM" into Access, which it's not understanding. To get around this, you need to treat your variable as a true date/time object, rather than a formatted string.
    CFQueryParams should be used on absolutely every database platform, they'll stop your website being vulnerable to SQL Injection attacks for one, which at the moment you're wide open to. Replace your query with something like this:
    <cfquery name="input_comments" datasource="#DSN#" username="#DSNUSER#" password="#DSNPASS#">
          INSERT INTO comments(
                             commenter,
                             comment,
                             datetime,
                             post_id
                   VALUES(
                             <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.commenter#" />,
                             <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.comment#" />,
                             now(),
                             <cfqueryparam cfsqltype="cf_sql_numeric" value="#form.post_id#" /> )
    </cfquery>
    The QueryParams will handle the data types for you, and should pass values around more safely and with fewer issues. Assuming you just want to store the current date and time you don't even need to get ColdFusion involved, as databases have their own functions for this. I believe Access' version is simply NOW(), so I've put that in your query.
    Give the above a go.

  • Statement error in for loop noobq

    Hi
    Could anyoe tell me why this wont work? Its supposed to count upp to tal in the first one and then count down from tal in the second and its the second one that dont work. I get a statement error for the text i put in between stars (supposed to be bold but i dont know..)
    thanks
    class r?knaa {
        public static void main(String[] args) {
            new r?knaa().run();
        void run() {
         int tal = Keyboard.nextInt ("Ange ett tal ? s? ska vi r?kna...(^_^): ");
         for (int upp = 1; upp <= tal; upp = upp + 1) {
             System.out.print ( upp+ " " );
         System.out.println (" ");
         System.out.println (" ");
         for (*tal*; tal > 0; tal = tal -1 ){
             System.out.print ( tal+ " " );
    }Edited by: gibitlib on Feb 19, 2010 3:02 PM

    jverd wrote:
    sharkura wrote:
    I assumed that it would decrement after the block of statements associated with the while loop, as is true with the for loop.Not sure what you mean by "as is true with the for loop", but I'm catching a hint of a very common misconception about the post-inc/dec operators.
    A LOT of people think that post-inc/dec means "last step in the statement" or "after everything else has been done" or something like that. That kind of thiiking is just black magic hocus pocus and serves no purposeI don't think I thiik like that, Jeff. I've never used a post-inc operator in a while loop. Certainly, if I felt a need to do so, I would test it, and try to understand why it works the way it does. Empirically, I know that given the following for loop:
    for ( int i = 0; i < limit; i++ )
      ... some statements
    }the incrementation of i occurs after the statements in the block execute. It may be specific to the for loop that the third statement in the for loop executes after the block of statements, in which case
    for ( int i = 0; i < limit; ++i )
      ... some statements
    }would work the same, and you can bet I will test that.
    I did make an assumption last night, and did not test it. That is not typical of me. I do resent somewhat the accusation of black magic hocus pocus. My last statement in that post was:
    sharkura wrote:
    I'll have to play with this some.Implicit in that remark was my intent to read more about pre/post decrementation and experiment until I more fully understood it. You have pointed out my lack of complete understanding, and, odd as it may seem, I appreciate that. I do log into these forums, partly, to improve my understanding of java.
    {?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • PNA Guided Calibration: GPIB write error in for loop

    Hi,
    I have a LabVIEW program that creates a Guided Power Calibration on a PNA.
    After initializing everything properly, I have a for loop that loops through all the manual steps that the user must go through (ex: Connect Channel A of Power meter to Port 1" "Connect male Short to port 1" etc).
    The problem is, the program displays an error at the first command: sens:corr:coll:guid:acq STAN1
    I says there is an error with the GPIB Write function.
    Here are the commands I send:
    SYSTRES
    DISPlay:WINDow2TATE ON
    CALCulate2ARameterEFine:EXT 'MyMeas',S21
    DISPlay:WINDow2:TRACe1:FEED 'MyMeas'
    CALC1AREL 'CH1_S11_1'
    SENS:FREQTAR 2e9
    SENS:FREQTOP 4e9
    SENSWEOINTS 3
    SENS:CORR:COLL:GUID:CONNORT1 'APC 2.4 male'
    SENS:CORR:COLL:GUID:CONNORT2 'APC 2.4 male'
    SENS:CORR:COLL:GUID:CKITORT1 '85056D'
    SENS:CORR:COLL:GUID:CKITORT2 '85056D' 
    SENSe:CORRection:COLLect:GUIDedSENsor1 ON
    SYSTem:COMMunicateSENsor gpib, "13"   
    SENSe:CORRection:COLLect:GUIDedSENsor1OWer:LEVel -20
    sens:corr:coll:guid:init
    sens:corr:coll:guid:steps?
    //for loop from 1 to total_number_of_steps
    sens:corr:coll:guid:desc? <step#>
    sens:corr:coll:guid:acq STAN<step#>
    The program quits right at the first step, when I send "sens:corr:coll:guid:acq STAN1", although the command is executed.
    Also, the VBScript with the same commands works fine.
    Can anybody help me? I've been stuck for a while now.
    I attached the block diagram of the for loop.
    Thanks in advance,
    Nicolas
    Attachments:
    Guided cal for loop.vi ‏27 KB

    Sending SENS:corr:coll:guid:acq STAN1 \n gives me a different error: -101 "Invalid Character".
    From my different attempts at figuring this out, I thought the problem would come from LabVIEW, since the vbscript with the same commands works on the PNA.
    I also modified the for loop because I thought each iteration should be linked to the previous one with the error wire (see attached).
    I still have the same issue, only the first iteration is executed, then the program quits.
    Attachments:
    Guided cal for loop.vi ‏28 KB

  • Logic error in for loop

    I have a JSP form which list modules that student can take. Some of these modules have prerequisite and some do not.
    In order to successfully register a student, I have a number of requirements e.g. must not be already register; the registration date must not have passed etc.
    My problem is in my code logic. For example, when a student selects a module, which does not have a prerequisite, and a module, which has a prerequisite and click on the Register button, an Error.jsp page is displayed because he has not satisfied the prerequisite for the second module.
    What the program does is that it registers the first module which dose not has a prerequisite and display the Error.jsp page.
    This is confusing for the user because they expect to do the process again and do not know that the first module has been register successfully.
    Here is my code
    private int enroll()throws SQLException,IOException
          // Get the check box values
          String checkboxNames[] = request.getParameterValues( "checkbox" );
          moduleVector = (Vector) session.getAttribute( "moduleVector" );
          //Get the student bean
          studentBean = (StudentBean) session.getAttribute( "studentBean" );
          boolean isEnrolled = false;
          String studentId = studentBean.getStudentId();
          int maxModule = Integer.parseInt(studentBean.getMaxModule());
          for (int i = 0; i < checkboxNames.length; i++) {
            String moduleId = checkboxNames;
    // First, make sure that this student is not already
    // enrolled for this module, and he/she has never
    // taken and passed the module before.
    isEnrolled = srsBean.isEnrolledIn( moduleId, studentId );
    if (isEnrolled){
    session.setAttribute("pre_enrolled", moduleId);
    return PREVIOUSLY_ENROLLED;
    // Now we make sure that the registration date has not
    // already passed
    Calendar rightNow = Calendar.getInstance();
    int rightNowMonth = rightNow.MONTH;
    int rightNowDay = rightNow.DAY_OF_MONTH;
    if ( rightNowMonth > Constants.REGISTER_DATE_MONTH ) {
    return PASSED_REGISTER_DATE;
    }else if( rightNowMonth == Constants.REGISTER_DATE_MONTH ) {
    if ( rightNowDay > Constants.REGISTER_DATE_DAY ) {
    return PASSED_REGISTER_DATE;
    int noModule = srsBean.noModuleEnrolledIn( studentId );
    // Now we make sure we don't erroll student on more
    // modules that the are allowed to do.
    if (!(noModule < maxModule)){
    // convert maxModule into string so we can use setAttribute
    String max = String.valueOf(maxModule);
    session.setAttribute("exceed_max_no", max);
    return EXCEEDED_MAX_NO_MODULE;
    // if there are any prerequisites for this module, check
    // to ensure that the student has completed them.
    if ( srsBean.hasPrerequisites(moduleId)) {
    Enumeration e = srsBean.getPrerequisites(moduleId);
    while ( e.hasMoreElements() ) {
    String pre = (String) e.nextElement();
    // See if the Student's Transcript reflects
    // successful completion of the prerequisite.
    if (!srsBean.verifyCompletion(moduleId, studentId)){
    session.setAttribute("prereq_not_sat", moduleId);
    return PREREQ_NOT_SATISFIED;
    // if we made it to here in the code, we're ready to
    // officially enroll the student.
    srsBean.enroll( studentId, moduleId );
    return SUCCESSFULLY_ENROLLED;
    How can i fix this problem ?

    1. well first check whether all modlues can be registered..
    2. you need to remove that in your for loop
    srsBean.enroll( studentId, moduleId );
    3. if all conditions are satisfied.
    for (int i = 0; i < checkboxNames.length; i++) {       
      String moduleId = checkboxNames<i>;
      srsBean.enroll( studentId, moduleId );
    }4. put the above code before
    return SUCCESSFULLY_ENROLLED;

  • Handle Error in for Loop and finish the iteration

    I am using a for Loop now i encounter an error.
    i want to handle this error but after that carry on with iteration of the loop.
    Any Parallel to "Continue" in JAVA or any other solution for this...
    Please Suggest.

    You can use pl/sql block with exception inside the loop
    Re: Continue beyond expcetion in proc...
    Message was edited by:
    jeneesh

  • DML Error logging for Update statement

    Hello,
    I am facing a problem with regard to DML Error logging with Update statement .
    oracle : 10.2
    I am executing following DML update:
    BEGIN
    UPDATE
    table_1  a
    SET a.Exp_DATE =a.EFF_DATE
    WHERE  a.col_a1 != (SELECT b.colb1
                         FROM table_2  b
                         WHERE  a.msisdn =b.msisdn )
    LOG ERRORS INTO table_1_ERR REJECT LIMIT UNLIMITED;                        
    END ;    I was expecting that "ORA-01427: single-row subquery returns more than one row" would be captured in LOG error table "table_1_err"
    but instead I got run time error and whole dml was rolled back.
    Please let me know whether this exception is not captured by DML error logging.
    Thanks,
    Abhishek

    *Oracle logs the following errors during DML operations:** Column values that are too large.
    * Constraint violations (NOT NULL, unique, referential, and check constraints).
    * Errors raised during trigger execution.
    * Errors resulting from type conversion between a column in a subquery and the corresponding column of the table.
    * Partition mapping errors.
    >
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/transform.htm#sthref777

  • When purchasing on Apple TV, gives error "Only for United States customers"

    I am a United States customer and I have my Apple TV in the US and it works fine along with the new update that I got last night.
    It is connected via ethernet 100mbs lan and 'sees' my iTunes 7.6 on my computer (Windows XP) just fine.
    Sync works... plays YouTube just fine... all is great EXCEPT!!!!
    I cannot make ANY purchases from my Apple TV... is says something like:
    "...only for United States customers"
    and then it bombs out.
    Anyone else have this issue?

    Thank for you the quick reply...
    Yes, I have setup to default to the USA...
    And I have also setup Apple TV to connect to the US Itunes store.
    I have not changed anything, but it seemed to correct itself just a minute ago.
    Weird.
    I changed nothing, then it starting working by itself.
    Bug?

  • Error in for loop

    I have this small code snippet but its always giving errors. I have included the java.util.Random package in the import statement as well
            for (int i = 0; i < 100; i++)
                char c = (char) (Math.random() * 26 + ?a?);  // FIRST ERROR IS ON THIS LINE
                switch(c)
                case ?a?:
                case ?e?:
                case ?i?:
                case ?o?:
                case ?u?:
                    System.out.println(?Vowel?); break;
                case ?y?:
                case ?w?:
                    System.out.println(?Sometimes a vowel?); break;
                default:
                    System.out.println(?Not a vowel?);
            }What exactly is the problem i am unable to figure out?

    Hi, we probably share the share the same problem , any ideas please? i have try the code given in this post but with no success
    goldfish

  • Oracle + Unix question , Error validation for SQL statements in co process

    Hi,
    If I use co process in a shell script , what is the best way to do the error validation of the execution of any sql statements . I was trying to change the following code to make use of co process concept. When I tried echo $? after the execution of a "wrong statements"
    it is still giving Zero output ( meaning success)
    <<<<<<<<<<<<<<<<<<<<<<<<<<<
    cat ${CFG_DIR}/srs_indx.lst | egrep -v '^#' | egrep -v '^[    ]*$' | while read x
    do
    echo " Processing values :: pre $pre tbl $tbl indx $indx tblspc $tblspc cols $cols param $param" >> ${LOGS_DIR}/srs_indx.log
    sqlplus ${BIZSTG} << EOT >> ${LOGS_DIR}/srs_indx.log
    set verify on timing on term on echo on feedback on serveroutput on
    WHENEVER SQLERROR CONTINUE
    drop index $indx;
    WHENEVER SQLERROR EXIT FAILURE
    alter session set query_rewrite_enabled = true;
    create $pre index $indx on $tbl ($cols)
    tablespace $tblspc
    $param;
    exit
    EOT
    RC=$?
    if ( test $RC -ne 0 )
    then
         ERR_MSG="ERROR in creating index $indx for table $tbl from srs_indx.ksh of $ENVIR : $APP by `whoami`@`hostname` on `date` "
         echo $ERR_MSG >> ${LOGS_DIR}/srs_indx.log
         process_warning ${LOGS_DIR}/srs_indx.log
         exitstat=1
    else
         echo "$indx created at `date`" >> ${LOGS_DIR}/srs_indx.log
    fi
    done
    >>>>>>>>>>>>>>>>>>>>
    Any help will be appreciated .
    with thanks and regards
    Ranjeesh K R

    Hi,
    Thanks for the response, I guess people misunderstood my question .
    My question was about "error handling in case of CO PROCESS". For those who don't know about this, in case CO PROCESS you just need to login once to Oracle. In my above code It is logging in & out for each entry in the list. CO process statements may look Similar to SQL statements in pro*C. In PRO*C we use EXEC, but here print -p statements..
    a sample is given for those who are new to co process.
    sqlplus -s /nolog |& # Open a pipe to SQL*Plus
    print -p -- 'connect user/password@instance'
    print -p -- 'set feed off pause off pages 0 head off veri off line 500'
    print -p -- 'set term off time off'
    print -p -- "set sqlprompt ''"
    print -p -- "select sysdate from dual;"
    read -p SYSDATE
    print -p -- "select user from dual;"
    read -p USER
    print -p -- "select global_name from global_name;"
    read -p GLOBAL_NAME
    print -p -- exit
    echo SYSDATE: $SYSDATE
    echo USER: $USER
    echo GLOBAL_NAME: $GLOBAL_NAME
    But I got stuck during error handling of these SQL statements, especially the $? / $* returns 0 even after an erroneus execution.
    Regards

  • Custom Error Message For Session State Violation

    Hi,
    Can anyone tell me is there a way to have a custom error message whenever there is a session state protection violation ?
    Currently it throws an error message as follows:
    "Session state protection violation: This may be caused by manual alteration of a URL containing a checksum or by using a link with an incorrect or missing checksum. If you are unsure what caused this error, please contact the application administrator for assistance"
    Can i have a custom message here ? An image, or a custom text for a more friendly end-user message
    Thank you very much,
    Srikumar S

    Version of database? Version of APEX? Browsers involved? More information you provide, better response from people here...
    Thank you,
    Tony Miller
    Ruckersville, VA

  • WLST script is throwing errors under for loop

    I'm new to wlst and getting the below errros while running the script. the name variable within cd command does not replaced with right value and abort the error. I would appropriate if some can point me to right direction.
    cat serverName2.py
    connect('test','test123','t3://test-app-dev-a:12619')
    domainRuntime()
    svrs = adminHome.getMBeansByType('Server')
    for s in svrs:
    name = s.getName()
    cd('/ServerRuntimes/'+'name')
    ls()
    disconnect()
    java weblogic.WLST serverName2.py
    getting the below errors
    Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
    For more help, use help(domainRuntime)
    No stack trace available.
    Problem invoking WLST - Traceback (innermost last):
    File "<iostream>", line 170, in cd
    WLSTException: 'Error cding to the MBean'

    You should remove quotes for name.
    cat serverName2.py
    connect('test','test123','t3://test-app-dev-a:12619')
    domainRuntime()
    svrs = adminHome.getMBeansByType('Server')
    for s in svrs:
    name = s.getName()
    cd('/ServerRuntimes/'+ name )
    ls()
    disconnect()
    Thanks,
    Krishna.

  • Syntax error in INSERT STATEMENT

    A problem on the date part of the query but why I don´t
    know, Thanks for any pointers,
    TIA
    <cfquery name="update1" datasource="trevor_SecurityDB">
    INSERT INTO imagesproducts
    (title, info, date)
    VALUES ( '#form.title#', '#form.info#', '#DateFormat(Now())#'
    </cfquery>
    Error Occurred While Processing Request
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
    INSERT INTO statement.
    The error occurred in uploadmember.cfm: line 28
    26 : INSERT INTO imagesproducts
    27 : (title, info, date)
    28 : VALUES ( '#form.title#', '#form.info#',
    '#DateFormat(Now())#' )
    29 : </cfquery>
    30 :
    SQL INSERT INTO imagesproducts (title, info, date) VALUES (
    'News test', 'Testing news info', '12-Jul-07' )
    DATASOURCE trevor_SecurityDB
    VENDORERRORCODE -3502
    SQLSTATE 42000

    Perhaps it is a reserved word issue with the date column,
    since
    date is an ODBC Reserved Keyword. You might try enclosing it
    within brackets [ ].
    <cfquery name="update1" datasource="trevor_SecurityDB">
    INSERT INTO imagesproducts
    (title, info, [date])
    VALUES ( '#form.title#', '#form.info#', '#DateFormat(Now())#'
    </cfquery>
    Or, if that doesn't help, you might try using a cfqueryparam
    tag for the '#DateFormat(Now())#' value using a cfsqltype =
    "CF_SQL_TIMESTAMP" (assuming a date/time datatype on the column).
    Also, you might look into using one of the CreateODBCDateTime() or
    CreateODBCDate() functions.
    Phil

  • [Microsoft][ODBC Microsoft Access Driver] Syntax error

    I am new to Java. I have tried to write a simple program insert table in Access2002. However, I got the following error,
    ERROR: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    My code is as follows,
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    import java.text.*;
    public class dateconv3 {
    public static void main (String[] args) {
    //Setting up the JDBC-ODBC bridge connection
    String DRIVER_NAME = "sun.jdbc.odbc.JdbcOdbcDriver";
    String CONNECTION_URL = "jdbc:odbc:book1";
    // The JDBC Connection Object
    Connection con = null;
    // The JDBC PreparedStatement object
    PreparedStatement ps = null;
    boolean rc = false;
    try { // try under for loop
    // Get an connection
    Class.forName(DRIVER_NAME).newInstance();
    con = DriverManager.getConnection(CONNECTION_URL);
    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy/mm/dd");
    java.util.Date currentTime_1 = new java.util.Date();
    String dateString = formatter.format(currentTime_1);
    ParsePosition pos = new ParsePosition(0);
    java.util.Date currentTime_2 = formatter.parse(dateString, pos);
    java.sql.Date dCurDate=new java.sql.Date(currentTime_2.getTime());
    System.out.println(dCurDate);
    String userid = "1";
    String booktitle = "Java Servlet Programming";
    int amount = 202;
    String sqltxt="INSERT INTO TRANSLOG ( userid, booktitle, date, amount ) VALUES (?,?,?,?)";
    // Create a statement object that we can execute queries with
    ps = con.prepareStatement(sqltxt);
    ps.setString(1, userid);
    ps.setString(2, booktitle);
    System.out.println(currentTime_2);
    java.sql.Date sqlDate = new java.sql.Date(currentTime_2.getTime());
    System.out.println(sqlDate);
    ps.setDate(3, sqlDate);
    ps.setInt(4, amount);
    System.out.println("INSERT into translog table");
    // Execute the statement
    ps.execute();
    rc = true;
    } catch (Exception ex) {
    // Sent the error
    System.out.println("ex.getMessage() print: " + ex.getMessage());
    } finally {
    try {
    if (ps != null) {
    ps.close();
    if (con != null) {
    // Put the connection back into the pool
    con.close();
    } catch (Exception ex) {
    // Ignore any error here
    The Access has been set to the date format yyyy/mm/dd and I got the following result.
    java dateconv3
    2001-01-04
    Thu Jan 04 00:56:00 CST 2001
    2001-01-04
    INSERT into translog table
    ex.getMessage() print: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    Please advise. I got frustrated with such a silly question. Anybody can help me to resolve it.
    Patrick

    INSERT INTO TRANSLOG ( userid, booktitle, date, amount ) VALUES (?,?,?,?)I don't have Access on my computer at home here, but it is quite possible that "date" is a reserved word in Access's version of SQL. If you can change the column name, I'd recommend you do that. Otherwise try changing your SQL code to this:
    INSERT INTO TRANSLOG ( userid, booktitle, [date], amount ) VALUES (?,?,?,?)
    But be warned that this [trick] doesn't work with other databases.

Maybe you are looking for