Home
Analytics
Evaluating Scripting Error
timofei
I have done several searches on the forums but I still remain unclear on this issue, any help or direction would be very helpful.
Question:
I received this error:
There are errors evaluating script "df = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
df2 = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
var myStartDate = df.parse(params["incidentStartDate"].value);
var myEndDate = df2.parse(params["incidentEndDate"].value);
When trying to run this script:
df = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
df2 = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
var myStartDate = df.parse(params["incidentStartDate"].value);
var myEndDate = df2.parse(params["incidentEndDate"].value);
if (params != null) {
this.queryText = "SELECT * FROM INCIDENTS WHERE INCIDENTS.ID = " + params;
} else {
this.queryText = "SELECT * FROM INCIDENTS WHERE
INCIDENTS.START >= " + myStartDate + " AND INCIDENTS.END <= " + myEndDate + " AND INCIDENT.INCIDENT_TYPE = " + params;
}
Thanks
Find more posts tagged with
Comments
mwilliams
Hi timofei,
Can you expand the entire error out and post it in here? Thanks.
timofei
The following items have errors:
ReportDesign (id = 1):
- There are errors evaluating script "df = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
df2 = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
var myStartDate = df.parse(params["incidentStartDate"].value);
var myEndDate = df2.parse(params["incidentEndDate"].value);
if (params != null) {
this.queryText = "SELECT * FROM INCIDENTS WHERE INCIDENTS.ID = " + params;
} else {
this.queryText = "SELECT * FROM INCIDENTS WHERE INCIDENTS.START >= " + myStartDate + " AND INCIDENTS.END <= " + myEndDate + " AND INCIDENT.INCIDENT_TYPE = " + params;
}":
{1}.
Error.ScriptEvaluationError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script
"df = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
df2 = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy");
var myStartDate = df.parse(params["incidentStartDate"].value);
var myEndDate = df2.parse(params["incidentEndDate"].value);
if (params != null) { this.queryText = "SELECT * FROM INCIDENTS WHERE INCIDENTS.ID = " + params;
} else {
this.queryText = "SELECT * FROM INCIDENTS WHERE INCIDENTS.START >= " + myStartDate + " AND INCIDENTS.END <= " + myEndDate + " AND INCIDENT.INCIDENT_TYPE = " + params;
}":{1}. at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:77) at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:196) at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleBeforeOpen(DataSetScriptExecutor.java:82) at org.eclipse.birt.data.engine.impl.DataSetRuntime.beforeOpen(DataSetRuntime.java:523) at org.eclipse.birt.data.engine.impl.QueryExecutor.dataSetBeforeOpen(QueryExecutor.java:198) at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:309) at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:498) at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.produceQueryResults(PreparedDataSourceQuery.java:189) at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:177) at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(PreparedOdaDSQuery.java:143) at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:479) at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:114) at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:248) at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1736) at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:77) at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62) at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:42) at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:45) at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:33) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:63) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:90) at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:101) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:151) at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:72) at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:954) at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:933) at org.eclipse.birt.report.service.actionhandler.BirtGetPageAllActionHandler.__execute(BirtGetPageAllActionHandler.java:132) at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90) at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47) at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143) at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleGetPageAll(BirtDocumentProcessor.java:183) at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112) at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66) at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397) at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186) at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454) at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281) at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699) at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:225) at javax.servlet.http.HttpServlet.service(HttpServlet.java:616) at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:112) at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180) at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:269) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1530) at org.mortbay.http.HttpContext.handle(HttpContext.java:1482) at org.mortbay.http.HttpServer.service(HttpServer.java:909) at org.mortbay.http.HttpConnection.service(HttpConnection.java:820) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred: There are errors evaluating script "__bm_beforeOpen()":Wrapped java.text.ParseException: Unparseable date: "0007-01-01" (<inline>#4).. See next exception for more information.There are errors evaluating script "__bm_beforeOpen()":Wrapped java.text.ParseException: Unparseable date: "0007-01-01" (<inline>#4). at org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:118) at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:717) at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:76) at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:71) ... 70 moreCaused by: org.eclipse.birt.core.exception.CoreException: There are errors evaluating script "__bm_beforeOpen()":Wrapped java.text.ParseException: Unparseable date: "0007-01-01" (<inline>#4). at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:300) at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:261) at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:713) ... 72 more
mwilliams
timofei,
What do the parameter dates look like? The problem you're having is with the parse.
ParseException: Unparseable date: "0007-01-01"
timofei
I input 01-Jan-09, it gets parsed to 01/01/2009. Am I missing something from my parsing script?
mwilliams
timofei,
Your formats need to match for the parse to work. If you're entering '01-Jan-09', your date format needs to be 'dd-MMM-yy'.
timofei
That doesn't seem to work. I get the same error with those changes. I have even tried use the parameter itself "params.value" in the query with the same error.
What would be the appropriate script to use? I need when an id is selected it display that incident, but if the user supplies a range of dates for incident "ie incidentStartDate, and incidentEndDate" and a incident type. Here is some code that I though would work, any more help would be greatly appreachiated.
if ( params[incidentId].value != null)
{
this.query = "select * from incident where incident.id = " + params.value;
} else {
this.query = select * from incident where incident.incidentStartDate >= " + params[incidentStartDate] + " AND incident.EndDate <= " + params[incidentEndDate] + " and incident.type = " + params[incidentType];
}
Thanks Again.
mwilliams
timofei,
Besides the missing " before the second select statement, which is probably a typo, it looks fine.
If you're getting the same error as before that is talking about the unparseable date, then somewhere your simpledateformat and your string entered date are not in the same format. In the error you posted, the date that didn't work was 0007-01-01, not the 01-Jan-09 date that you said you were using, so if you have the 0007-01-01 entered somewhere, the parse won't work.
timofei
I am still getting errors, so I started over everything works fine until I try to put the date parameters in the else condition. At that point I get "expected DATE got Number". None of the parameters are set as number they are all set as date. Is there a site of examples with multiple parameters, with multiple queries, under one report? Oh Yeah I get "missing In or out parameter at index" what even is that error?
mwilliams
timofei,
If you can create an example with the sample database where you encounter this issue, that would be great. This way I could see everything for myself. i.e. how it's set up, what it does when it runs, etc. Thanks.
timofei
Here is the .rptdesign file. Currently I am getting the Missing In or out parameter. THANKS A BUNCH FOR JUST HELPING.
mwilliams
timofei,
Sorry for not asking before, but what version of BIRT are you using, so I can open this in the correct version?
timofei
2.3.1.v2008630-2207w31191_19 is my version and build number.
timofei
MWilliams, where you able to see what I am doing incorrectly?
mwilliams
timofei,
I don't see anything wrong at first glance. Not being able to run the design makes debugging difficult. If you can include flat files of data for me to replace the datasets with so I can run the report, that may help. Or, if you can recreate this issue with the sample database and post that report in here, I'll be able to run that and see the issue.
To double check, you're not using the parse anymore, you're just having a problem with the date parameter not being recognized as a date?
timofei
I will create a flat data file for you to use. No parse didn't work for me, really just need a parameter "date" to be compared to a date in oracle db.
mwilliams
timofei,
Just looking at your report, I don't see any problems with the way it's set up. If you don't need the Time for your parameter value, you could just try using the Date type parameter rather than the DateTime type. That is a possibility, but I don't see why that would matter in this case.
timofei
Here is a flat file of some sample data. I make it less complicated, I only included one table "incident_record". I saved the file .txt but it really is a .csv with commas being the separator. Below you will see my updated query that should work with this data. Again it seems to get stuck only on comparing date fields, when doing a scripted query. If I try the compare in a regular query it works just fine.
Again thanks if you can provide any assistance please let me know.
This is the main query
select
incRECDB.incREC_incident_record.incident_id as ID,
incRECDB.incREC_incident_record.incident_start as star,
incRECDB.incREC_incident_record.incident_end as end1,
incRECDB.incREC_incident_record.atms_operator as oper,
incRECDB.incREC_incident_record.information_source as sour,
incRECDB.incREC_incident_record.primary_number_of_lanes as p,
incRECDB.incREC_incident_record.number_blocked_lanes as b,
incRECDB.incREC_incident_record.internal_notes as inotes,
incRECDB.incREC_incident_record.public_notes as pnotes,
ROUND((incRECDB.incREC_INCIDENT_RECORD.INCIDENT_END - incRECDB.incREC_INCIDENT_RECORD.INCIDENT_START) * 24, 2) AS TIMEDIFF,
from
incRECDB.incREC_INCIDENT_RECORD
scripted query first condition:
this.query = "select
incRECDB.incREC_incident_record.incident_id as ID,
incRECDB.incREC_incident_record.incident_start as star,
incRECDB.incREC_incident_record.incident_end as end1,
incRECDB.incREC_incident_record.atms_operator as oper,
incRECDB.incREC_incident_record.information_source as sour,
incRECDB.incREC_incident_record.primary_number_of_lanes as p,
incRECDB.incREC_incident_record.number_blocked_lanes as b,
incRECDB.incREC_incident_record.internal_notes as inotes,
incRECDB.incREC_incident_record.public_notes as pnotes,
ROUND((incRECDB.incREC_INCIDENT_RECORD.INCIDENT_END - incRECDB.incREC_INCIDENT_RECORD.INCIDENT_START) * 24, 2) AS TIMEDIFF,
from
incRECDB.incREC_INCIDENT_RECORD
where
incRECDB.incREC_incident_record.incident_id =" + params["incidentID"];
second query condition (this is the date condition)
select
incRECDB.incREC_incident_record.incident_id as ID,
incRECDB.incREC_incident_record.incident_start as star,
incRECDB.incREC_incident_record.incident_end as end1,
incRECDB.incREC_incident_record.atms_operator as oper,
incRECDB.incREC_incident_record.information_source as sour,
incRECDB.incREC_incident_record.primary_number_of_lanes as p,
incRECDB.incREC_incident_record.number_blocked_lanes as b,
incRECDB.incREC_incident_record.internal_notes as inotes,
incRECDB.incREC_incident_record.public_notes as pnotes,
ROUND((incRECDB.incREC_INCIDENT_RECORD.INCIDENT_END - incRECDB.incREC_INCIDENT_RECORD.INCIDENT_START) * 24, 2) AS TIMEDIFF,
from
incRECDB.incREC_INCIDENT_RECORD
where
incRECDB.incREC_incident_record.incident_record >= "+params["incidentStart"] + " and incRECDB.incREC_incident_record.incident_end <= "+params["incidentEnd"];
timofei
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>timofei,<br />
<br />
Just looking at your report, I don't see any problems with the way it's set up. If you don't need the Time for your parameter value, you could just try using the Date type parameter rather than the DateTime type. That is a possibility, but I don't see why that would matter in this case.</p></blockquote>
<br />
I did think of that, just to see if I broke anything I tried that earlier. No luck still the same problems, but I do need the time with the date.
mwilliams
timofei,
I guess I really wasn't thinking much. Your issue is with the scripting of the query on the dataSet with your date parameter. Using a flat file won't help me too much.
I'll try to recreate a similar issue with the sample database.