Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : INSERT does not work with javaSearch Forum

Forum Home > FlexODBC - ODBC Driver for DataFlex Embedded DBMS > FlexODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 INSERT does not work with java 
 Author   Message 
  Ivan 
  
 Group: Members 
 Posts: 3 
 Joined: 2008-09-17 
 Profile
 Posted : 2008-09-17 23:13:06

Greetings,

i have an issue while using flex ODBC with java through NetBeans. the code below is the SQL statement that i am applying, then the function below it is the java function that i have in my file, and the last thing is the error i get when running the program. i would appreciate any help in identifying why it would give me such an error and whether my sql statement is correct although i know it is.

Thank you,

Ivan Khedhr

INSERT INTO "F29" ( "DEPLETE", "CATEGORY", "STKDESC", "INVACCTN") VALUES ('A', 'A', 'A', 22)

 public void sqlCommand3() {
  PreparedStatement ps;
 
  try {
   ps = conn.prepareStatement("insert into \"F29\" ( \"DEPLETE\", \"CATEGORY\", \"STKDESC\", \"INVACCTN\") VALUES ('A', 'A', 'A', 22)");
   ps.executeUpdate();
   
   ps.close();
   ps = null;

  } catch (Exception e) {
   e.printStackTrace();
   ps = null;
  }
 }

java.sql.SQLException: [FlexODBC] Column not found: DEPLETE
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
Closing
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
        at sun.jdbc.odbc.JdbcOdbc.SQLPrepare(JdbcOdbc.java:4831)
        at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(JdbcOdbcConnection.java:475)
        at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(JdbcOdbcConnection.java:443)
        at fw.dft.DataFlexMain.sqlCommand3(DataFlexMain.java:189)
        at fw.dft.DataFlexMain.main(DataFlexMain.java:18)

i am certain that the column in question exists in the file i am trying to insert data into. Thank you in advance.

 

 
Ivan Khedhr 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-09-18 07:59:41

Regarding:

INSERT INTO "F29" ( "DEPLETE", "CATEGORY", "STKDESC", "INVACCTN") VALUES ('A', 'A', 'A', 22)

If you get Error: [FlexODBC] Column not found: DEPLETE
 
Try running VB Demo (found in the FlexODBC program group) and look at the columns in the table by doing
 
SELECT *.* Top 1 from F29
 
or find the F29.tag file on your disk (most likely in the data folder) as it has the column names in it.
 
If F29.tag has:
 
@STKN
@DEPLETE
CATEGORY
STKDESC
....
.....
......
INVACCTN
 
remove the @ to make the column visible. And yes to have to have a columnname for every value you want to insert and no you don't have to insert all 80 columns, just the ones required by the table index setup to create a unique/valid record.

 

  Top 
  Ivan 
  
 Group: Members 
 Posts: 3 
 Joined: 2008-09-17 
 Profile
 Posted : 2008-09-19 05:48:04

Thanks for your reply Tom.

The error below is what i got after doing what you told me to.

"insert into \"F29\" ( \"DEPLETE\", \"CATEGORY\", \"STKDESC\", \"INVACCTN\") VALUES ('Y', 'Franks', 'Abcde', 22)"

java.sql.SQLException: [FlexODBC][FLEXERR] Duplicate records not allowed in file

Because of these errors we thought it would be better and easier to try the update command.

When trying to update the data, my update runs ok but the table doesn't get updated. below is the code and error for the update.

"update \"F29\" SET \"DEPLETE\"='Franks' WHERE \"STKN\"='1'" ------- the result i get after running this update command (without any errors) is below.

|1| |OPTION Q508 HT750| |N| |BATTERY| |NiMH Ultra-High Capacity Battery|

Please advise.

Thank you,

Ivan Khedhr

 

 
Ivan Khedhr 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-09-22 08:49:14
Duplicate records not allowed in file means there's already a record in the table with the same data. DataFlex tables have indexes that require data to be unique. I suggest you add additional columns to the insert statement and try to locate DFFILE to examine the structure of the indexes of the table. 

  Top 
  Ivan 
  
 Group: Members 
 Posts: 3 
 Joined: 2008-09-17 
 Profile
 Posted : 2008-09-23 01:43:11

Thanks Tom.

we are going to look into that, but what about the update statement? how come it doesn't work?

 

 
Ivan Khedhr 
 
  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to