Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLSQL : Parse error when creating a "aggregate" type #4335

Open
TCHO-BREIZH opened this issue Nov 21, 2024 · 1 comment
Open

PLSQL : Parse error when creating a "aggregate" type #4335

TCHO-BREIZH opened this issue Nov 21, 2024 · 1 comment

Comments

@TCHO-BREIZH
Copy link

TCHO-BREIZH commented Nov 21, 2024

e.g. : Concat columns function

CREATE OR REPLACE TYPE cx_string_concat AS OBJECT (
   ps_string_so_far   VARCHAR2 (32767),
   ps_delimiter       VARCHAR2 (10),    --if 10 characters isn't enough for a delimeter, too bad
   STATIC FUNCTION odciaggregateinitialize (po_sctx IN OUT cx_string_concat)
      RETURN NUMBER,
   MEMBER FUNCTION odciaggregateiterate (
      self   IN OUT   cx_string_concat,
      val    IN       VARCHAR2
   )
      RETURN NUMBER,
   MEMBER FUNCTION odciaggregateterminate (
      self              IN       cx_string_concat,
      ps_returnvalue    OUT      VARCHAR2,
      pn_flags          IN       NUMBER
   )
      RETURN NUMBER,
   MEMBER FUNCTION odciaggregatemerge (
      self   IN OUT     cx_string_concat,
      po_ctx2   IN      cx_string_concat
   )
      RETURN NUMBER
);
/

CREATE OR REPLACE TYPE BODY cx_string_concat
IS
   STATIC FUNCTION odciaggregateinitialize (po_sctx IN OUT cx_string_concat)
      RETURN NUMBER
   IS
   BEGIN
      po_sctx := cx_string_concat (NULL, ';');
      RETURN odciconst.success;
   END;
   MEMBER FUNCTION odciaggregateiterate (
      self   IN OUT   cx_string_concat,
      val    IN       VARCHAR2
   )
      RETURN NUMBER
   IS
   BEGIN
      self.ps_string_so_far := self.ps_string_so_far || self.ps_delimiter || val;
      RETURN odciconst.success;
   END;
   MEMBER FUNCTION odciaggregateterminate (
      self          IN       cx_string_concat,
      ps_returnvalue   OUT      VARCHAR2,
      pn_flags         IN       NUMBER
   )
      RETURN NUMBER
   IS
   BEGIN
      ps_returnvalue := self.ps_string_so_far||self.ps_delimiter;
      RETURN odciconst.success;
   END;
   MEMBER FUNCTION odciaggregatemerge (
      self   IN OUT   cx_string_concat,
      po_ctx2      IN       cx_string_concat
   )
      RETURN NUMBER
   IS
   BEGIN
      RETURN odciconst.success;
   END;
END;
/

CREATE OR REPLACE FUNCTION concatcol (ps_string VARCHAR2)
   RETURN VARCHAR2 AGGREGATE
   USING cx_string_concat;
/

Issues :

line 5:52 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 5:59 extraneous input 'cx_string_concat' expecting {')', ','}
line 8:13 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 8:22 extraneous input 'cx_string_concat' expecting {')', ','}
line 9:13 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 13:24 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 14:33 extraneous input 'VARCHAR2' expecting {')', ','}
line 15:24 extraneous input 'IN' expecting {'GRANT', 'REVOKE', ','}
line 16:3 extraneous input ')' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 18:10 extraneous input 'FUNCTION' expecting {'GRANT', 'REVOKE', ','}
line 19:24 no viable alternative at input 'OUT     cx_string_concat'
line 20:16 extraneous input 'IN' expecting {'GRANT', 'REVOKE', ','}
line 21:3 extraneous input ')' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 23:0 extraneous input ')' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 28:52 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 28:59 extraneous input 'cx_string_concat' expecting {')', ','}
line 36:13 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 36:22 extraneous input 'cx_string_concat' expecting {')', ','}
line 37:13 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 46:20 extraneous input 'IN' expecting {'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 47:32 extraneous input 'VARCHAR2' expecting {')', ','}
line 48:23 extraneous input 'IN' expecting {'GRANT', 'REVOKE', ','}
line 49:3 extraneous input ')' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT',...
line 51:3 extraneous input 'IS' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 57:22 no viable alternative at input 'OUT   cx_string_concat'
line 58:19 extraneous input 'IN' expecting {'GRANT', 'REVOKE', ','}
line 59:3 extraneous input ')' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 61:3 extraneous input 'IS' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
line 65:0 extraneous input 'END' expecting {<EOF>, 'ABORT', 'ABS', 'ACCESS', 'ACCESSED', 'ACCOUNT', ...
@kaby76
Copy link
Contributor

kaby76 commented Nov 21, 2024

Please edit your above comment to use Fenced Code Blocks around your code so we can see and copy the example using a simple click instead of select, then copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants