exception: mismatched input '[' in rule "checkTicketExpired"]
why????
rule "checkTicketExpired"
when
$r: RuleResult(holder instanceof Ticket)
$ticket: Ticket() from $r.holder
Ticket(LocalDateTime.now() > expireAt) from $ticket break[expire]
then
then[noting]
.....
then[expire]
.....
then[unAffect]
....
end
I'm having a problem, whenever I try to run the code below and select the statement 2 to insert a tool and put a random tool name I get the error message : ProgrammingError('column "inserttool' does not exist\nLine 1: insert tools(tool_name, rental_days) values(#insertTool, '2') .
Here is the code :
if Menu == "2":
cursor = connection.cursor()
InsertTool = raw_input("Please insert the tool that you want to add.\n")
insert_tool = """insert into tools(tool_name, rental_days) values(#InsertTool, '2')"""
try:
cursor.execute( insert_tool);
connection.commit();
print("Tool is succesfully inserted!")
except Exception as e:
connection.rollback();
print("Exception Occured : ",e)
connection.close();
try this.
if Menu == "2":
cursor = connection.cursor()
InsertTool = raw_input("Please insert the tool that you want to add.\n")
insert_tool = """insert into tools(tool_name, rental_days) values(%s, %s)"""
val = (InsertTool, "2")
try:
cursor.execute(insert_tool, val);
connection.commit();
print("Tool is succesfully inserted!")
except Exception as e:
connection.rollback();
print("Exception Occured : ",e)
connection.close();
While executing insert and update command in oracle 11g I'm getting below error.
val stmt = con.createStatement()
//Insert
val query1 = "insert into audit values('D','abc','T','01-NOV-18','Inprogress')"
stmt.executeUpdate(query1)
//Update
val query2 = "Update audit Set status='test' where where product= = 'D'"
stmt.executeUpdate(query2)
I'm getting below error
//Error while updating record
Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1036)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1845)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1810)
at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:294)
at com.oracle.OracleConnection$.main(OracleConnection.scala:21)
at com.oracle.OracleConnection.main(OracleConnection.scala)
Process finished with exit code 1
Any help will be appreciated. Thanks in advance
You have two where and two = in your update query.
val query2 = "Update audit Set status='test' where product='D'"
I am using Typehandler to map a List<Dep> to oracle array of ... here is the setPArameter method in the handler :
public void setParameter(PreparedStatement ps, int i, List<Dep> parameter, JdbcType jdbcType)
throws SQLException {
Connection connection = ps.getConnection();
// StructDescriptor structDescriptor = StructDescriptor.createDescriptor("MEMS_ARR", connection);
Struct[] structs = null;
if(parameter != null && parameter.size() >0) {
structs = new Struct[parameter.size()];
for (int index = 0; index < parameter.size(); index++)
{
Dep dep = parameter.get(index);
Object[] params = new Object[7];
params[0] = dep.getOrder();
params[1] = dep.getIdTp;
params[2] = dep.getId();
params[3] = " ";
params[4] = " ";
params[5] = " ";
params[6] = " ";
// STRUCT struct = new STRUCT(structDescriptor, ps.getConnection(), params);
structs[index] = connection.createStruct("MEMS", params);
}
// ArrayDescriptor desc = ArrayDescriptor.createDescriptor("MEMS_ARR", ps.getConnection());
// ARRAY oracleArray = new ARRAY(desc, ps.getConnection(), structs);
}else {
parameter = new ArrayList<DependentDTO>();
structs= new Struct[0];
}
this.parameter = parameter;
Array oracleArray = ((OracleConnection) connection).createOracleArray("MEMS_ARR", structs);
ps.setArray(i, oracleArray);
}
and here is the MEMS type :
create or replace TYPE MEMS AS OBJECT
( MEM1 NUMBER(2,0),
MEM2 VARCHAR2(1),
MEM3 VARCHAR2(15),
MEM4 VARCHAR2(60),
MEM5 VARCHAR2(1),
MEM6 VARCHAR2(40),
MEM7 VARCHAR2(10)
);
and here is the portion of the xml mapping file that uses the Typehandler :
#{nat,javaType=String,jdbcType=VARCHAR,mode=IN}, --nat
**#{deps,javaType=List,jdbcType=ARRAY,mode=IN,jdbcTypeName=MEMS_ARR,typeHandler=com.my.package.MyHandler}, --mems**
#{res,javaType=String,jdbcType=VARCHAR,mode=OUT} --res
the error log is as follows :
Error querying database. Cause: java.sql.SQLException: ORA-06550: line 31, column 5: PLS-00103: Encountered the symbol "" when expecting one of the following: . ( ) , * # % & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || indicator multiset member submultiset The symbol "(" was substituted for "" to continue. ORA-06550: line 44, column 4: PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) , * % & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset ### The error may exist in file [E:\path\to\mapper\ADao.xml] ### The error may involve my.package.ADao.mthodToCall -Inline ### The error occurred while setting parameters ### SQL: {call MY_PROC( ... , --nat?, **--mems? --res**)}
As you can see in the logs, the mems is replaced by empty string or is merged with the next arg res ... the comma is not there
Also kindly note that I already debugged inside the mybatis code and realized that the mapping setParameter method is called and the input List is mapped correctly to the oracle array ... the issue happens at the time of real calling
The issue actually was that I simply missed one comma between two previous parameters ... but the error pointed to the wrong parameter to look at
I'm writing a script to insert a GUID into a SQL table. In order to stop duplicates, I have made the table GUID column unique.
So now I need to catch the violation and ignore if its a duplicate and continue the script. So write the new GUIDS but ignore the duplicates.
What would be the best way to catch and deal with the violation?
I've seen a few options on this site, but none work for me, most fail with The Catch block is missing its statement block. or other errors.
Example of the catch block I've been trying
catch(SqlException ex)
{
sqlException = ex.InnerException as System.Data.SqlClient.SqlException;
if (sqlException.Number == 2601 || sqlException.Number == 2627)
{
ErrorMessage = "Cannot insert duplicate values.";
}
else
{
ErrorMessage = "Error while saving data.";
}
}
and the errors:
At D:\Software Approval Requests\GetApprovalRequestsNew2.ps1:15 char:6
+ catch (UpdateException ex)
+ ~
The Catch block is missing its statement block.
At D:\Software Approval Requests\GetApprovalRequestsNew2.ps1:18 char:32
+ if (innerException != null && innerException.Number == 2627 || innerExceptio ...
+ ~~
The token '&&' is not a valid statement separator in this version.
At D:\Software Approval Requests\GetApprovalRequestsNew2.ps1:18 char:65
+ if (innerException != null && innerException.Number == 2627 || innerExceptio ...
+ ~~
The token '||' is not a valid statement separator in this version.
At D:\Software Approval Requests\GetApprovalRequestsNew2.ps1:23 char:28
+ if (innerException != null && (innerException.Number == 2627 || innerException.N ...