Explanation:
I have an android application that was made using ADT (Android Developer Tools)
I use the bank sqlite in it and eventually I perform some operations as insert
or update
and also some select
's.
Problem:
When performing a certain insert
after running .execSQL()
on the bank, I am having the following error as an exception:
Empty bindArgs.
Code used:
Bank statement in onCreate()
:
SQLiteDatabase db_r3Att = this.openOrCreateDatabase("r3Att.db3", SQLiteDatabase.CREATE_IF_NECESSARY, null );
Insertion code:
Cursor c = db_r3Att.rawQuery("select PEDIDO,REGISTRO,TIPOPED,NRNOTA,CLIENTE,NOME,ESPECIE,CONDICAO,OBSV1,OBSV2,TRANSMITIR,DATA,HORA,ENVIAR,SITUACAO,DBREGISTRO,EMPRESA,TROCA,SIMPLES,EBONIFICACAO,PERCDESC,VLRDESC,VLRLIQUIDO from PEDIDO_IMP" , null);
c.moveToFirst();
while( !c.isAfterLast() ){
//incrementa o max
cPedidoMax++;
Integer cPedido = c.getInt(c.getColumnIndex("PEDIDO"));
Integer cRegistro = c.getInt(c.getColumnIndex("REGISTRO"));
String cTipoPed = c.getString(c.getColumnIndex("TIPOPED"));
String cNrNota = c.getString(c.getColumnIndex("NRNOTA"));
Integer cCliente = c.getInt(c.getColumnIndex("CLIENTE"));
String cNome = c.getString(c.getColumnIndex("NOME"));
String cEspecie = c.getString(c.getColumnIndex("ESPECIE"));
String cCondicao = c.getString(c.getColumnIndex("CONDICAO"));
String cObs1 = c.getString(c.getColumnIndex("OBSV1"));
String cObs2 = c.getString(c.getColumnIndex("OBSV2"));
Integer cTransmitir = c.getInt(c.getColumnIndex("TRANSMITIR"));
String cData = c.getString(c.getColumnIndex("DATA"));
String cHora = c.getString(c.getColumnIndex("HORA"));
Integer cEnviar = c.getInt(c.getColumnIndex("ENVIAR"));
Integer cSituacao = c.getInt(c.getColumnIndex("SITUACAO"));
Integer cDBRegistro = c.getInt(c.getColumnIndex("DBREGISTRO"));
Integer cEmpresa = c.getInt(c.getColumnIndex("EMPRESA"));
String cTroca = c.getString(c.getColumnIndex("TROCA"));
String cSimples = c.getString(c.getColumnIndex("SIMPLES"));
String cBonificacao = c.getString(c.getColumnIndex("EBONIFICACAO"));
float cPercentualDesconto = c.getFloat(c.getColumnIndex("PERCDESC"));
float cValorDesconto = c.getFloat(c.getColumnIndex("VLRDESC"));
float cValorLiquido = c.getFloat(c.getColumnIndex("VLRLIQUIDO"));
sb.append("INSERT INTO PEDIDO (PEDIDO,REGISTRO,TIPOPED,NRNOTA,CLIENTE,NOME,ESPECIE,CONDICAO,OBSV1,OBSV2,TRANSMITIR,DATA,HORA,ENVIAR,SITUACAO,DBREGISTRO,EMPRESA,TROCA,SIMPLES,EBONIFICACAO,PERCDESC,VLRDESC,VLRLIQUIDO,ID_PEDIDO_EXT)");
sb.append(" VALUES ("+cPedidoMax+","+cRegistro+",'"+cTipoPed+"','"+cNrNota+"',"+cCliente+",'"+cNome+"','"+cEspecie+"','"+cCondicao+"','"+cObs1+"','"+cObs2+"',"+cTransmitir+",'"+cData+"','"+cHora+"',"+cEnviar+","+cSituacao+","+cDBRegistro+","+cEmpresa+",'"+cTroca+"','"+cSimples+"','"+cBonificacao+"',"+cPercentualDesconto+","+cValorDesconto+","+cValorLiquido+","+cPedido+");");
db_r3.execSQL(sb.toString(),null);
c.moveToNext();
}
c.close();
Important Note:
1 - I'm pretty sure that select
is working and is fetching the data and populating the variables.
2 - I checked the syntax of insert
and even tried to run manually in the database and it worked.
So the error lies in something I did and not in the syntax, so do not worry about the giant string there in the code.
Question:
How to resolve this type of error?