Rebuild complex excel function in sql

Hello everyone,

I need help with the rebuild of an excel function in sql for oracle. You find this function below. It is an ADDITION to the Dutch Elfproef .
(see general examples on : - Check Dutch bank account number or citizen service number with Eleven test ).

I tried for 2 long times, but get stuck so PLEASE your help.

Ther is an excel version available at: toad - pCloud
In the excel on page examples are some numbers for testing including good/wrong ('=fout'). these numbers are below too.

I would be very glad to have an sql statement / funtion / package to check some thousends of existing numbers in an oracle database. The second goal is to make a constraint.

Again: the REGULAR Dutch Elfproef WON'T fit! I need this specific formula build in Excel.

Thanx al lot in advance! Harry.

note: Formula is in Dutch. Meaning > IF((when(value(part)----



Might want to post to a more appropriate forum, such as StackOverflow or similar, as ToadWorld focuses on Toad product usage and product capabilities.

However, trying to be helpful here.
Rather than attempt to create your elfproef formula in SQL syntax within the query, I would personally rather define a callable function or procedure in Oracle PL/SQL that will accomplish the above.

Here's a nice discussion thread, with sample code using both SQL and PL/SQL syntax that you can draw inspiration from:

Hope this helps.

Hello Gary,

Yes it helped. A lot! Thanx for that.

I did not make it to get a function, but with the below I did find the errors in our data.

Thanx again from Netherlands.

(and will post StackOverflow next time).

select sub2.controle, sub2.cri, sv2.subjectnr, sv2.subjectnaam, sv2.gbageboorte, trunc(ttopvoer) opvoerdatum
select sub1.*
, case when sub1.restant = 0 then 'Good'
when sub1.restant = 10 AND TO_NUMBER(SUBSTR(sub1.cri, 9, 1)) = 0 then 'Good'
else 'False'
end controle
select cri
, mod
(to_number(substr(Lpad(cri,9,0),1,1))*9) +
(to_number(substr(Lpad(cri,9,0),2,1))*8) +
(to_number(substr(Lpad(cri,9,0),3,1))*7) +
(to_number(substr(Lpad(cri,9,0),4,1))*6) +
(to_number(substr(Lpad(cri,9,0),5,1))*5) +
(to_number(substr(Lpad(cri,9,0),6,1))*4) +
(to_number(substr(Lpad(cri,9,0),7,1))*3) +
(to_number(substr(Lpad(cri,9,0),8,1))2) +
,11) restant
from sjm_fulsubject sv
where 1=1
and indvervallen = 'N'
group by cri
) sub1
where 1=1
) sub2
, sjm_fulsubject sv2
where 1=1
and sub2.cri = sv2.cri
and sub2.controle != 'Good'