SHOW:
|
|
- or go back to the newest paste.
1 | CREATE TABLE bank_transactions | |
2 | ( | |
3 | id serial NOT NULL, | |
4 | transaction_date date, | |
5 | amount numeric(20,2), | |
6 | customer_id integer NOT NULL, | |
7 | deleted boolean DEFAULT false, | |
8 | CONSTRAINT bank_transactions_pkey PRIMARY KEY (id ) | |
9 | ); | |
10 | ||
11 | WITH RECURSIVE bank(id,amount) AS ( | |
12 | SELECT ARRAY[id],amount::numeric FROM bank_transactions | |
13 | UNION ALL | |
14 | SELECT b1.id||ARRAY[borg.id],b1.amount+borg.amount | |
15 | FROM bank AS b1 LEFT JOIN | |
16 | bank_transactions AS borg ON borg.id>ALL(b1.id) | |
17 | ) | |
18 | SELECT * from bank LIMIT 100; | |
19 | ||
20 | ERROR: recursive query "bank" column 2 has type numeric(20,2) in non-recursive term but type numeric overall | |
21 | LINE 6: SELECT ARRAY[id],amount::numeric FROM bank_transactions | |
22 | ^ | |
23 | HINT: Cast the output of the non-recursive term to the correct type. | |
24 | ||
25 | ********** Error ********** | |
26 | ||
27 | ERROR: recursive query "bank" column 2 has type numeric(20,2) in non-recursive term but type numeric overall | |
28 | SQL state: 42804 | |
29 | Hint: Cast the output of the non-recursive term to the correct type. | |
30 | Character: 140 |