Book a Demo

Author Topic: PostgreSQL and recursive SQL  (Read 3862 times)

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
PostgreSQL and recursive SQL
« on: January 21, 2022, 08:35:58 am »
Hello, I need to make a recursive query in a template fragment into PostgreSQL. I found out that EA is doggedly refusing all SQL statements that don't start with SELECT (oh well, guys, there is 2022 AD!). I also found here in past discussions that I can wrap up the WITH RECURSIVE with SELECT (allegedly working with MySQL). Well, it doesn't work at all with PostgreSQL. Do you have any experience with this SQL server?

Pure SQL statement:

WITH RECURSIVE requirements_tree (depth) AS
(
   SELECT 0, object_id, name, alias, stereotype, note, ea_guid
     FROM T_OBJECT
      WHERE OBJECT_TYPE = 'Requirement'
        AND PACKAGE_ID = 110
        AND PARENTID = 0
   UNION ALL
   SELECT depth+1, T.object_id, T.name, T.alias, T.stereotype, T.note, T.ea_guid
     FROM requirements_tree rt
      JOIN T_OBJECT T ON T.parentid = rt.object_id
) SEARCH DEPTH FIRST BY OBJECT_id SET ordercol
SELECT *
   FROM requirements_tree
ORDER BY ordercol


If I use select envelope:

SELECT * FROM (
WITH RECURSIVE requirements_tree (depth) AS
(
   SELECT 0, object_id, name, alias, stereotype, note, ea_guid
     FROM T_OBJECT
      WHERE OBJECT_TYPE = 'Requirement'
        AND PACKAGE_ID = 110
        AND PARENTID = 0
   UNION ALL
   SELECT depth+1, T.object_id, T.name, T.alias, T.stereotype, T.note, T.ea_guid
     FROM requirements_tree rt
      JOIN T_OBJECT T ON T.parentid = rt.object_id
) SEARCH DEPTH FIRST BY OBJECT_id SET ordercol
SELECT *
   FROM requirements_tree
   ) as Result
ORDER BY ordercol


I get error: operator does not exist: integer || integer.

Ok, I temporarily removed 0 and depth from the SELECT, but then I got error: column rt.object_id does not exist.

That is pretty awkward situation.



qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: PostgreSQL and recursive SQL
« Reply #1 on: January 21, 2022, 08:54:36 am »
No, but they mangled your name in this forum as well (like I said in the em-dash thread: there are more suspicious UTF chars  out there...).

q.

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Re: PostgreSQL and recursive SQL
« Reply #2 on: January 21, 2022, 09:07:12 am »
I know. I tried to change it, but got error that the e-mail was incorrect. It is not. But I am not surprised. I have been seeing Chinees character in EA since yesterday as I migrated to Windows 11. This tool makes me frustrated.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: PostgreSQL and recursive SQL
« Reply #3 on: January 21, 2022, 09:15:58 am »
I'm using W11 also (forced to do that since I have an ARM computer) but have not seen Chinese. But in my models there's just plain English (ASCII). You should report that bug. And pray to see a fix :-/

Not sure who's using PostgreSQL. The SQL-Pope (Geert) is with MS SQL what I read from his posts... Maybe you could mail Sparx (along with the bug report).

q.

Jan Prochaska

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: PostgreSQL and recursive SQL
« Reply #4 on: March 21, 2022, 07:57:01 am »
Hello,
We are developing a document generator for EA called RepoDoc (https://repodoc.archimetes.com)
It can execute several passes of repository within a single document generation run.
I'd like to learn more about your case, I think RepoDoc could handle this.
Kind regards,
Jan