When I run this code, I have error with the sql executed on file myQuery.sql
val sqlString = Source.fromFile(**myQuery.sql**).getLines.mkString
var psmt: PreparedStatement = dbc.prepareStatement(sqlString)
var result = psmt.executeQuery()
psmt.close()
myQuery.sql contains big merge query :
MERGE INTO xxxxxx e
USING (SELECT * from ..................)
ON (condition.............)
WHEN MATCHED THEN
UPDATE SET ................
WHEN NOT MATCHED THEN
INSERT (.................)
VALUES (..................)
The error is: Error Msg = ORA-00969: key word ON is missing
But in the query, I have ON key word with condition surrounded by parenthesis
When I execute the query in oracle I don’t have errors
There is any syntax , I shoud resperct il query file ?
With mkString, all lines from the file are concatenated into a single string without any separator. Is your THEN at the beginning of a new line without indentation?
Try adding a separator as argument to mkString, e.g. to add a space between each pair of lines: