Advertisement
Guest User

Untitled

a guest
Mar 10th, 2013
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement