MySQL Forums
Forum List  »  Stored Procedures

Re: Display all the records from table using cursor
Posted by: kaji Pasa
Date: September 25, 2017 06:24PM

Peter Brawley Wrote:
-------------------------------------------------------
> > if b.title_sci=b.title, then we get cc=0
>
> get it, or set it? If the former,
> what guarantees that the rule is followed?
***The logic before this table gets populated will guarantees it will be 0 or 1, How this is done is we check in before base table gets populated. if b.issn1=b.issn2 or b.issn=b.eissn then we set CC=0 . ISSN will be checked first and then we we did not find the match, we check title. So if title is also not match we set cc=1. Hence for cc<> 0 we conclude that title and issn both does not match so we have to see in the master table.


*****Now for only this records(b.cc<> 0) we implement our repository to check if there is still match.

***.b.issn1=b.issn2 or b.issn=b.eissn or if b.title_sci=b.title then cc will be 0 else cc will be 1.

>
> > if b.title_sci<>b.title then we have to see the
> master

**** saying this we do not have match on issn and title both(as issn is checked first then title is checked), so lookup in the master to get this row from master and update the base table.
>
> That contradicts what you wrote before: if
> base.title_sci = base.title or b.issn1=b.issn2 or
> b.issn=b.eissn then this is match and CC=0 else
> cc=1. Which is correct?

********* if base.title_sci = base.title or b.issn1=b.issn2 or b.issn=b.eissn then this is match and CC=0 ,, so no need to go in master,
but if that condition in not met then b.cc<>0 so go to master
>
> > if in master this m.title_sci is dog and for the
> same row m.title= cat
>
> Loose language yields errors. Especially when
> writing specs, be literal. Do you mean: if
> m.title_sci <> m.title?

*************What i try to say here is master will have the record in this pattern m.title<>m.title_scn but though m.title<>m.title_scn in master the m.cc value will tell us this is a match as m.cc=0
>
> > then this is match as per the master(a way we
> say this is match
> > though the colunm doesnt match in base table )
> > .Hence i need to update cc for this row in the
> base table to zero which indicates this is a
> match.
>
> You seem to mean to say this is a condition for
> (i) setting b.cc=0 and (ii) consulting the
> corresponding master row. Is that correct?

********YES. if b.cc<>0, consult the master and update the b.cc based on m.cc for this row.

>
> You've given apparently inconsistent variants of
> the condition for setting b.cc=0 and updating the
> master version of the row. We're writing
> pseudocode for a requirement. It needs to be
> unambiguous. Here's your requirement as I
> understand it so far, unresolved issues I've so
> far identified are in comments:
>
>
> in a join of b to m on (title_sci, title, issn1,
> issn2, issn, eissn, databas) ...
> 
> if b.title_sci=b.title or b.issn1=b.issn2 or
> b.issn=b.eissn then
> set b.cc=0                   -- WHAT IF B.CC=1?
********If we get the above conditions(here title and issn  of base is compared with base  ) then, this will make the cc of base to zero so we do not have to bother for this row.

But if B.cc=1, go to master to see the same row (b.title_sci=m.title_sci,b.title=m.title,b.issn1=m.issn1, b.issn=m.issn,b.eissn=m.eisssn) .then get the m.cc value to b.cc  (here b.cc0<> and m.cc = 0 then update b.cc=0 )

*******In the repository, we will not have the rows for which  b.cc=0 in the base .Since B.cc=0 is a match we dont have to go for the repo to *****validate.and master does not have this row.

> if m.cc=0 then 
> ???                        -- YOU SAID SET
> SET b,cc=0 BUT IT ALREADY IS


*****If there is b.cc=0 its a match.
> else if m.title <> m.title_sci
> set .cc=0                  -- OR M.CC?

****** the values in the master is not not updated in any case.It is used only to update the base. i will just see the value in master if b.cc<>0 and get the value from master to base table.
 if B.cc<> 0,   goto master fetch the row, update the base for that record.
***********(a condition can be added to check if b.cc<> 0 and b.cc=m.cc then leave it else  update the base )
> end if
> else
> set b.cc=1
> end if
>
>
> Please put you corrected spec inside a pair of
> BBCode
> code tags (the 1st tag is the word "code", the 2nd
> is "/code", each surrounded by square brackets).

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Display all the records from table using cursor
680
September 25, 2017 06:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.