I am a Rails newbie and would really appreciate if someone converted these SQLs to complete modules for rails. I know its a lot to ask but I can't just use find_by_sql for all of them. Or can I?
These are the SQLs (they run on MS-SQL):
SELECT STANJA_NA_DAN_POSTAVKA.STA_ID,
STP_DATE,
STP_TIME,
STA_OPIS,
STA_SIFRA,
STA_POND FROM STANJA_NA_DAN_POSTAVKA
INNER JOIN STANJA_NA_DAN ON(STANJA_NA_DAN.STA_ID=STANJA_NA_DAN_POSTAVKA.STA_ID)
WHERE ((OSE_ID=10)AND (STANJA_NA_DAN_POSTAVKA.STP_DATE>={d '2010-03-30'})
AND (STANJA_NA_DAN_POSTAVKA.STP_DATE<={d '2010-03-30'}))
SELECT ZIGI_OBDELANI.OSE_ID,
ZIGI_OBDELANI.DOG_ID AS DOG_ID,
ZIGI_OBDELANI.ZIO_DATUM AS DATUM,
ZIGI_PRICETEK.ZIG_TIME_D AS ZIG_PRICETEK,
ZIGI_KONEC.ZIG_TIME_D AS ZIG_KONEC
FROM (ZIGI_OBDELANI
INNER JOIN ZIGI ZIGI_PRICETEK
ON ZIGI_OBDELANI.ZIG_ID_PRICETEK = ZIGI_PRICETEK.ZIG_ID )
INNER JOIN ZIGI ZIGI_KONEC ON ZIGI_OBDELANI.ZIG_ID_KONEC = ZIGI_KONEC.ZIG_ID
WHERE (ZIGI_OBDELANI.OSE_ID = 10)
AND (ZIGI_OBDELANI.ZIO_DATUM >= {d '2010-03-30'})
AND (ZIGI_OBDELANI.ZIO_DATUM <= {d '2010-03-30'})
AND (ZIGI_PRICETEK.ZIG_VELJAVEN <> 0)
AND (ZIGI_KONEC.ZIG_VELJAVEN <> 0)
ORDER BY ZIGI_OBDELANI.OSE_ID, ZIGI_PRICETEK.ZIG_TIME ASC
These SQLs are daily working hours and I got them as is. Also I got Database with it which (as you can see from the SQL-s) is not in Rails conventions. As a P.S.:
Things like STP_DATE>={d'2010-03-30'}) are of course dates (in Slovenian date notation) and will be replaced with a variable (date), so that the user could choose date from and date to.
All of this data will be shown in the same page in the table,so maybe all in one module? Or many?; if this helps, maybe.
So can someone help me? Its for my work and its my 1st project and I am a Rails newbie and the bosses are getting inpatient(they are getting quite loud actually)
Thank you very very much!
So again I would really apreciate if someone could do a relevant model part for at least one of the complicated SQLs. I will read all the data in one controller and in one action. All will be done in one run.