craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Events/Actions Post New Topic   Post A Reply
Can't force an insert sql action with a save() command printer friendly version
next newest post | next oldest post
Author Messages
jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Thursday, January 3, 2008 @ 18:25:42  

I have a compound insert sql for a specific table. In order to get everything in all the referenced tables I have the following:

qTable.addInsertSql("INSERT INTO TABLE_GROUPS " +
" ( GRP_FK_OPERATOR_OPR_IID, " +
" GRP_NAME, " +
" GRP_START_DATETIME, " +
" GRP_STOP_DATETIME, " +
" GRP_COMMENT ) " +
" values (?,?,?,?,?)",
"2,4,7,8,9");

qTable.addInsertSql("UPDATE TABLE_GROUPS SET" +
" GRP_FK_REFERENCE_CHANNELS_RFC_IID = " +
" ( SELECT RFC_IID FROM TABLE_REFERENCE_CHANNELS " +
" WHERE RFC_FK_MV_CHANNELS_MVC_CHANNEL = ?) " +
" WHERE GRP_IID = (SELECT MAX (GRP_IID) FROM TABLE_GROUPS) ",
"6");

It works fine IF (and only if) I select another row in the table. If I do a qTable.save() that is triggered by some other action (button press, focus lost, etc) it doesn't do the insert. I have the debug trace on and can watch when it actually executes the insert. It tells me Executing sql INSERT INTO TABLE_GROUPS ...... followed by the Executing sql UPDATE TABLE_GROUPS SET GRP_FK_REFERENCE_CHANNELS_RFC_IID .....

What am I missing in order to force the insert so I don't have to rely on the user selecting another row (btw, I tried setting qTable.setDatabaseUpdateMode(DBTable.UPDATE_DATABASE_ON_CELL_EXIT) and that doesn't work either)? There must be some logic inside the .save() command that determines its not time yet to do the insert action.

Thanks

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Saturday, January 5, 2008 @ 20:53:42  

I tried your changes in AddModifyDeleteTable.java sample and it works when save() is called. Do you have a databaseChangeListener with beforeInsert implemented?

when you call save() do you see any debug messages?

Can you try to reproduce this problem in AddModifyDeleteTable.java ?

jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Saturday, January 5, 2008 @ 22:37:35  

I do have a databaseChangeListener but I dont have beforeInsert implimented. Could it be a problem with the default (non implimented) action for the databaseChangeListener? I'll try and impliment the beforeInsert Monday. The action I have for unused functions simalier to:

public void afterInsert(int row) {
super.afterInsert(row);
}

Is that correct?

Regarding the 'call save()' I didn't see any actions at all when debug was turned on.

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, January 6, 2008 @ 17:44:29  

if you have not implemented beforeInsert(), it is ok no need to implement it. calling super method does not really make any difference.

I need a small code where you can reproduce this issue. Can you try to reproduce in AddModifyDeleteTable.java?

jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Monday, January 7, 2008 @ 16:55:49  

I found the problem. It was a classic cut and paste error. Actually I was doing the save in the wrong table because the cut and paste index variable was wrong. Once I got that sorted out all the other issues cleared up too. Actually, I didn't find the error until I implimented the 'beforeInsert()' clause and tired to look at what was and wasn't inserted. Thanks for your help. Sometimes its very usefull to just to write down the question and ponder the response because it forces you to think about the problem from some different perspective.

Also, I was sure I never would have gotten the error to show in AddModifyDeleteTable.java :)

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Tuesday, January 8, 2008 @ 22:08:44  

Glad to know you identified the problem.

We are going to add debug statements when the before() methods are cancelled by users. this should help.

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios