Link to home
Start Free TrialLog in
Avatar of lizzzard
lizzzardFlag for Netherlands

asked on

stored procedure... please help..

HI,

I have to write a stored procedure, but I'm not very good at it...obviously.
For myself I made an example of what it should do. It's in a kind of fake-language, but it should show what the problem is:

@DATE_F : DATETIME
@OBJ : CHAR(3)
@DATE_B : DATETIME
@AAN : TINYINT

for each record in BES where BES.OBJ=@OBJ and AAN_T=@AAN and BES.DATB='01/01/1901'
do

if BES.DATF='01/01/1901'
      {BES.DATF = @DATE_F }
endif

if BES.BEDF - BES.ONIN > 0
      {BES.CLI_TEL = 1
       BES.DATB = @DATE_F
       BES.BEDB = BES.BEDF - BES.ONIN
       if BES.BWB = '3' then
            {BES.AAN_T = BES.AAN_T + 1}}
endif

done

Now... how should I write my sp to accomplish this?
Thanks for any advice..

Regards, Alex
ASKER CERTIFIED SOLUTION
Avatar of Dumpling
Dumpling

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lizzzard

ASKER

Sorry  I forgot to mention that the @-variables are parameters I will pass frommy application. Does that change the idea?
Avatar of Dumpling
Dumpling

Lizzzard,

Nope. It's not a problem. Syntax is CREATE PROC myproc (@DATE_F DATETIME, @OBJ CHAR(3), @DATE_B DATETIME , @AAN TINYINT ).

Hope that helps.

D.

Thanks,

I will try, you'll hear from me soon.