0

I try to run a recursive query to get shortest paths where the id should occure once in a path at most. The view I am using looks like:

pkp_symmetric(
    personknows numeric(20,0),
    personisknown numeric(20,0),
    creation timestamp)

When running

with recursive temp(persStart, persNext, pfad, tiefe, pcycle ) 
            as 
            (select pkp.personknows, pkp.personIsKnown, array[pkp.personKnows], 1, false 
            from pkp_symmetric pkp--pidstart, pidstart, pidstart
            union all 
            select p.personknows, p.personisknown, t.pfad|| t.persNext, t.tiefe + 1, p.personknows = ANY(t.pfad)  
            from pkp_symmetric p join  temp t 
            on p.personknows = t.persNext where not pcycle )

            select * from temp t 

I get the following error:

SQL Error [42804]: ERROR: recursive query "temp" column 3 has type numeric(20,0)[] in non-recursive term but type numeric[] overall
  Hinweis: Cast the output of the non-recursive term to the correct type.
  Position: 119
  SQL Error [42804]: ERROR: recursive query "temp" column 3 has type numeric(20,0)[] in non-recursive term but type numeric[] overall
  Hinweis: Cast the output of the non-recursive term to the correct type.
  Position: 119
    SQL Error [42804]: ERROR: recursive query "temp" column 3 has type numeric(20,0)[] in non-recursive term but type numeric[] overall
  Hinweis: Cast the output of the non-recursive term to the correct type.
  Position: 119
      SQL Error [42804]: ERROR: recursive query "temp" column 3 has type numeric(20,0)[] in non-recursive term but type numeric[] overall
  Hinweis: Cast the output of the non-recursive term to the correct type.
  Position: 119
        ERROR: recursive query "temp" column 3 has type numeric(20,0)[] in non-recursive term but type numeric[] overall
  Hinweis: Cast the output of the non-recursive term to the correct type.
  Position: 119
        ERROR: recursive query "temp" column 3 has type numeric(20,0)[] in non-recursive term but type numeric[] overall
  Hinweis: Cast the output of the non-recursive term to the correct type.
  Position: 119

I would appreciate to get some help. Best regards.

1 Answer 1

1

Dealing with bounded data types in arrays is a bit tricky. It seems the only way to get this to work is a clumsy:

select pkp.personknows, pkp.personisknown, array[]::numeric[] || pkp.personknows
...

in the non-recursive part.

I have no idea why array[personknows]::numeric[] doesn't achieve the same thing.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried, but this does not work for me. I still get the same error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.