Can anyone explain this code to me?

Can anyone explain the following PLSQL code?

  • create or replace FUNCTION CLAIM_DASHBOARD_1_FUNC(dt date) RETURN talicpack.claim_dashboard_1_table PIPELINED AS mytype talicpack.claim_dashboard_1_type; i number := 12; BEGIN mytype.year1 := to_char(dt,'yyyy'); select to_char(to_date(to_char(i),'mm'),'mon'), (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a1, (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a2, (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a3, (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a4, (select count(*) from lf$app_claim where to_char(CLAIMFINALIZEDDATE,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a5, (select count(*) from lf$app_claim where to_char(CLAIMFINALIZEDDATE,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a6, (select count(*) from lf$app_claim where to_char(CLAIMFINALIZEDDATE,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… as a8, (select count(*) from lf$app_claim where months_between(to_date(to_char(to_char(t… and (claimfinaldecision = 'Pending' or claimfinaldecision is null) as a9, (select count(*) from lf$app_claim where months_between(to_date(to_char(to_char(t… and (claimfinaldecision = 'Pending' or claimfinaldecision is null) as a10, into mytype.month,mytype.c1,mytype.c2,mytype.… from dual; pipe row(mytype); i := 1; while (i < 12) loop select to_char(to_date(i,'mm'),'mon'), (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim,lf$app_seec_claim where lf$app_claim.canonicalid = lf$app_seec_claim.parentcanonicalid and to_char(registrationdate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim where to_char(claimfinalizeddate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim where to_char(claimfinalizeddate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim where to_char(claimfinalizeddate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count(*) from lf$app_claim where to_char(claimfinalizeddate,'monyyyy') = to_char(to_char(to_date(i,'mm'),'mon')||… (select count

  • Answer:

    I have no idea. Why don't you ask the author. Also your post is incomplete: it only shows the topmost lines of the code and most lines are truncated. The first statement is a select from dual that includes a batch of subselects that look like they repeat, but I assume do not (your text is truncated). That seems to return a bunch of counts of claims in various conditions that relate to the month/year passed as parameter. Then there is a loop that looks like it repeats that same query for each month in a year, but there is no way to know which one (maybe the one passed as argument ?). Again your code is incomplete. The function is a pipelined function, hence the use of the PIPE ROW function. This enables the function to return a table of results. To use the result, you would do something like that: select ... from table (CLAIM_DASHBOARD_1_FUNC(current_date));

arjun raju at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.