i have a table with these columns and the values are coming in these tables from a csv file at a regular interval of n minutes ( by cron the load infile command) :
ID (PK) status first last value 1 Q 12 15 low 2 Q 12 15 low 3 O 12 15 High
now whenever next data comes , it should first check whether ID is present in table , if it is then it simply update that ID's corresponding field , and if new ID come , it simply insert the data.
For this i have created a procedure :
create procedure test.testproc (IN no int , IN status varchar(10)) begin if exists (select id from test.testproc where id = no) then update baseline set status=status where id=no; else insert into tname(id,status) value(no,status); end if; end$$
Now what i want to know :
should i create two tables for this i.e one is a temporary table and one main table ? ** i'm 100% confuse here what should i do here
how should i automate all these i.e data comes from a csv file , then my load infile script runs, then my above procedure should execute and checking that if ID already present it will simply update else it will insert.
OR , if you have any other process , please tell