I am facing an issue, The between keyword throws error while running.
PFD:
I am using:
var m_fro_date=new Date(somedate);
var currentInsertDate=new Date(somedate2);
LABKEY.Query.executeSql({
schemaName: 'DEMOSCHEMA',
sql: 'SELECT * FROM ' + Importantdata+
+'where import_date between {ts \''+m_fro_date+'\'}' +' and {ts \'' +currentInsertDate+'\' }',
success: function(data){
alert("YES!!");
}
});
Error message box says unexpected token "between".
Please help
Regards
Atul |
|
Jon (LabKey DevOps) responded: |
2017-07-14 11:15 |
Hi Atul,
Have you tried to redo the query with actual hard values to make sure that it works?
For example:
LABKEY.Query.executeSql({
schemaName: 'DEMOSCHEMA',
sql: "SELECT * FROM QUERYNAME WHERE import_date BETWEEN '2017-01-01' AND '2017-02-01'",
success: function(data){
alert("YES!!");
}
});
If the above works, then I would recommend slightly modifying your code as such:
var m_fro_date=new Date(somedate);
var currentInsertDate=new Date(somedate2);
LABKEY.Query.executeSql({
schemaName: 'DEMOSCHEMA',
sql: "SELECT * FROM " + Importantdata + " WHERE import_date BETWEEN {ts \"+ m_fro_date + "\ }" + " and {ts \" +currentInsertDate+"\ }",
success: function(data){
alert("YES!!");
}
});
Regards,
Jon |
|
atul sharma responded: |
2017-07-17 01:14 |
Dear Jon,
It still throws "Unexpected Token Between" error.
More Over I have tried with '>' and '< 'special characters but throws error as "Unexpected Token >" .
I have tried this too.
LABKEY.Query.selectRows({
schemaName: 'DEMOSCHEMA',
queryName: 'QUERYNAME',
success: onSuccess,
filterArray: [
LABKEY.Filter.create('Import_date', ['2017-01-01', '2017-02-01'], LABKEY.Filter.Types.BETWEEN)
]
});
function onSuccess(data)
{
alter("Success");
}
This piece of code throws "Internal Server Error". (PFA)
Please Help.
Regards
Atul |
|
|
Matthew Bellew responded: |
2017-07-18 15:42 |
Hi Atul, going back to your original code here could you try using variable for your generated SQL and then printing it out (or looking at it in the debugger).
e.g.
var sql = 'SELECT * FROM ' + Importantdata+
+'where import_date between {ts \''+m_fro_date+'\'}' +' and {ts \'' +currentInsertDate+'\' }';
console.log(sql);
LABKEY.Query.executeSql({
schemaName: 'DEMOSCHEMA',
sql: sql,
success: function(data){
alert("YES!!");
}
});
It would be helpful to know the exact SQL you are generating. |
|
|
|