Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Stange behaviour in the inserts.

Avatar

Former Community Member
Hello

I have trying to insert a data into sql server.

I use this code:



var db;

var rd;

db = xfa.sourceSet.cd;

rd = xfa.record.cd;

var sql = 'insert into t1 (text) values(\'t1\');'

console.println(sql);

db.resolveNode("#command").query.select.value = sql;

db.open();



And the sql of my data connection is "select * from t1".



the I execute this I obtain this error "it isn't literal, this is my translation" GeneralError: Error in the operation.

XFAObject.open:8:XFA:myform[0].#subform[0].button[0]:click

Operation failure of ado2xfa. It can't find the element of the collection that correspond with the name or the ordinal asked.



If I change the sql for "select * from t1 insert into t1 (text) values(\'t1\');" this works, but I don't want to use this because, this worls in sql server but not works in oracle, that is the real platform.



It seems that designer hope receive a value of the select and with the insert doesn't receive data.



Thanks a lot for your help



----------------------------------

Hosting Association

The low cost quality hosting

http://www.hostingassociation.biz

----------------------------------
2 Replies

Avatar

Former Community Member
Hello



I have fixed the problem. But with this solution I don't know if the insert has been executed correctly. someone know how fix it?



The solution is use try and catch, and ignore the errors.

try{

var db;

var rd;

db = xfa.sourceSet.cd;

rd = xfa.record.cd;

var sql = 'insert into t1 (text) values(\'t1\');'

console.println(sql);

db.resolveNode("#command").query.select.value = sql;

db.open();

}catch(e)

{

}

Avatar

Former Community Member
Do you know how to handle errors in FormCalc?