I have a file I need to process. Based on a value in the file, I need to check in the database if it finds based on the key, then generate an UPDATE statement with values from the current row in the file, otherwise INSERT statement with values from the current row in the file.
the output files can be two different (for example inserts.sql and updates.sql) files. I am doing this using sqlite. I am thinking of creating the process like this.
FileInput-->SQLiteInput-->MAP-->FileOutputARFF
would this work?
Thanks,
Ravi
You have the single- and double-quotes the wrong way round after context.parama. The single-quote must be inside the double-quoted string. My careless mistake above...
"Exception in component tMSSqlInput_1
java.sql.SQLException: Conversion failed when converting datetime from character string."
This eror comes when i execute the talend job and the parameters are string,if they are passed as date the job runs with success.
The code in tmssqlinput_1 (parama/b are string if they are dates no issue)
"select * from fn_sas_ext(
'" + TalendDate.parseDate("yyyy-MM-dd",context.parama) +" '
,
'" + TalendDate.parseDate("yyyy-MM-dd",context.paramb) +" '
)"
Please guide
Why are you now using parseDate?! If parama and paramb are strings (in the correct yyyy-MM-dd format) then just use them directly to construct the SQL statement.
Thanks Alevy ,i have to take dates from the user input as dd/mm/yyyy and then pass the dates to mssqlinput in (mm/dd/yyyy) as this format is default for ms sqlserver ,i have taken string as input but it gives error "java.lang.RuntimeException: java.text.ParseException: Unparseable date: "01-02-2011"" please guide, thanks.
If it's stating 'Unparseable date: "01-02-2011"' then it's clearly not in dd/mm/yyyy format.
You need to understand what you're trying to do, which is to construct a SQL statement that looks the same as if you were using it directly in SQL Server.
To that end, if you have a String date, it must be in the correct format to append to the rest of the SELECT statement. If it is not in the correct format, you need to parse it to a Date (using it's actual format) and then format it back to a String in the correct format. Obviously, if you already have a Date you only need to format it to a String in the correct format.
e.g. '" + TalendDate.formatDate("yyyy-MM-dd",TalendDate.parseDate("dd/MM/yyyy",context.parama)) + "'
Alevy sir , I want to pass input parameters to toraclesp without using tfixedflowinput, i have declared two context variables as paramA,paramB.Please guide,thanks in advance.
one more issue ,is oracle global temporary table no use in talend as the data cannot be inserted in another table in the same job,e.g i have a table tbl_stag which is GTT and in the same job through a procedure i am trying to insert into another table but no rows inserted into normal table.please guide.