Home sql ORA-01722: INVALID NUMBER

ORA-01722: INVALID NUMBER

Author

Date

Category

Good day to everyone. I do not see at all where I wrote incorrectly … Help find an error in the SQL script, please.
P.S.: The error issues without specifying an incorrect line or something else. If someone asks.

select distinct
 'Childal',
 child.id
 child.municid,
 DateEnd,
 (select adoptaccesspackage.getrealchildfio (child.id, child.municid, 1) from dual) as name,
 (select adoptaccesspackage.getrealchildbirthday (child.id, child.municid, 1) from dual) AS date_nival,
 Coalesce (
  (SELECT T.USTR.
   from (Select Q.ustr, Q.Datebegin, Q.Childid, Q.municid
      From (Select Childid, Municid, 'Oboy' As Ustr, DateEnd, DateBegin
         From guardian.
         WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
         Union Select Childid, Municid, 'Pre-Okek' AS Ustr, DateEnd, DateBegin
            From prevguardian
            WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
            Union Select Childid, Municid, 'Favorite Family' As Ustr, DateEnd, DateBegin
               from Foster.
               WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
               Union Select Childid, Municid, 'Adoption' As Ustr, DateEnd, DateBegin
                  from adopt.
                  WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
                  Union Select Childid, Municid, 'Patronage' As Ustr, DateEnd, DateBegin
                     From Patronat.
                     WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
                     Union Select Childid, Municid, 'Institutions for Orphans and Children Remained B / P' As Ustr, DateEnd, DateBegin
                        FROM INTERNAT.
                        WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
                        Union Select Childid, Municid, 'Temporary Institutions' As Ustr, DateEnd, DateBegin
                           From TemporaryHouse.
                           WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
                           Union Select Childid, Municid, 'Cardridge' As Ustr, DateEnd, DateBegin
                              From Patronag.
                              WHERE DATEBEGIN IS NOT NULL AND (DATEEND IS NULL OR DATEEND IS NOT NULL AND TO_DATE (DATEEND, 'DD.MM.YYYY') & GT; SYSDATE)
        ) Q.
      Order by to_date (q.datebegin, 'dd.mm.yyyy') Desc
     ) T.
   Inner Join Child.
   ON T.CHILDID = Child.ID
   Where Rownum & lt; = 1 and t.municid = child.municid),
  'No acting device'
 ) AS device,
 (Select UtilsfunctionPackage.getNameRegion (Child.municid, 0) from Dual) as area
From Child
Inner Join (
 (
  SELECT CHILDID, MUNICID, DATEEND
  From (Select Mu.Childid, Mu.municid, Mu.Datebegin, Mu.DateEnd
     From (Select Childid, Municid, Datebegin, DateEnd
        From guardian.
        Where DateBegin Is Not Null
        Union Select Childid, Municid, DateBegin, DateEnd
           From PrevGuardian WHERE DateBegin Is Not Null
           Union Select Childid, Municid, DateBegin, DateEnd
              from Foster.
              Where DateBegin Is Not Null 
union select childid, municid, datebegin, dateend
                 from adopt
                 where datebegin is not null
                 union select childid, municid, datebegin, dateend
                    from patronat
                    where datebegin is not null
                    union select childid, municid, datebegin, dateend
                       from internat
                       where datebegin is not null
                       union select childid, municid, datebegin, dateend
                          from temporaryhouse
                          where datebegin is not null
                          union select childid, municid, datebegin, dateend
                             from patronag
                             where datebegin is not null
     ) mu, child
     where child.municid = mu.childid and
       mu.municid = child.municid and
       mu.datebegin is not null and
       to_date (mu.datebegin, 'dd.mm.yyyy') = to_date ('02 .08.2017 ',' dd.mm.yyyy ')
    )
 )
) z
on z.childid = child.id and
  z.municid = child.municid
inner join people
on people.id = child.peopleid and
  people.municid = child.municid
where child.param & lt; & gt; 1 and
   child.municid in ('{BA986261-AC49-4F7B-AC0D-8B4A6AFD9364}', '{FE00E848-55B3-4E7F-8E15-8DB24F132A45}')
order by 5 asc;

Answer 1

I found the problem in my sql query.

child.municid = mu.childid
  VARCHAR2 vs NUMBER

The different types are here. Many thanks to everyone who wrote to me in the comments!

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions