Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: pl/sql help.....again

Re: pl/sql help.....again

From: clint <c_macnichol_at_hotmail.com>
Date: Wed, 02 Apr 2003 12:38:23 GMT
Message-ID: <3RAia.12316$Jf.1221664@ursa-nb00s0.nbnet.nb.ca>


Thanks for the help...

Would this approach make sense if i was going to set up a TRIGGER to initiate only when info is entered in a table....them I want it to make the caculations and fill in the other table?

"Anurag Varma" <avdbi_at_hotmail.com> wrote in message news:Clgia.777$Vz1.514_at_news01.roc.ny.frontiernet.net...
> I agree, a sql statement should work better.
>
> To the OP, if you define v_refund as NUMBER(6), that means you are
defining it to be an integer.
> So 0.01 * 12 will be equal to 0!
> Define it with proper precision ... e.g. NUMBER(6,2) and you should not
get a zero. In fact you should
> define it as expense_log.refund%type
>
> Anurag
>
> "Niall Litchfield" <n-litchfield_at_audit-commission.gov.uk> wrote in message
news:3e89908a$0$4846$ed9e5944_at_reading.news.pipex.net...
> > It looks like you want to loop through the cursor and calculate the
refund
> > value for each record in the cursor. Look up cursor for loops in the
docs or
> > any pl/sql reference and this should get you started.
> >
> > having said that if this is a production piece of code why would you use
> > pl/sql at all, a simple sql statement will perform better.
> >
> >
> > --
> > Niall Litchfield
> > Oracle DBA
> > Audit Commission UK
> > "clint" <c_macnichol_at_hotmail.com> wrote in message
> > news:HUfia.11803$Jf.1153190_at_ursa-nb00s0.nbnet.nb.ca...
> > > hello,
> > >
> > > I have created a series of tables.......as part of that I am trying
to
> > > create a pl/sql script...that will take some information from one
> > > table....manipulate it and insert it into another table....
> > >
> > > The calculation always equals zero...what am i doing wrong?
> > >
> > > here is my pl/sql script...
> > >
> > > DECLARE
> > > CURSOR c_MILEAGE_CAL IS
> > > SELECT EMPLO_ID, NUM_MILES, MIL_ALLOWANCE, ENTRY_DATE, DESCR
> > > FROM MILE_LOG;
> > > V_EMPLOID MILE_LOG.EMPLO_ID%TYPE :=20029;
> > > V_NUM_MILES MILE_LOG.NUM_MILES%TYPE;
> > > V_CENTSPERMILE MILE_LOG.MIL_ALLOWANCE%TYPE;
> > > V_DATE DATE;
> > > V_DESCR MILE_LOG.DESCR%TYPE;
> > > V_REFUND NUMBER(6);
> > > BEGIN
> > > OPEN c_MILEAGE_CAL;
> > > FETCH c_MILEAGE_CAL INTO
> > > V_EMPLOID, V_NUM_MILES, V_CENTSPERMILE, V_DATE, V_DESCR;
> > >
> > > /* I just want to calculate this simple equation*/
> > > V_REFUND := V_NUM_MILES * V_CENTSPERMILE;
> > >
> > > INSERT INTO EXPENSE_LOG
> > > VALUES(EXPLOG_COUNT_SEQ.NEXTVAL,V_EMPLOID,V_EMPLOID
,V_REFUND,V_DATE,
> > > V_DESCR, V_NUM_MILES );
> > > CLOSE c_MILEAGE_CAL;
> > > COMMIT;
> > > END;
> > >
> > >
> > >
> >
> >
>
>
Received on Wed Apr 02 2003 - 06:38:23 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US