くわこのpermission denied.

WEBエンジニアの僕がぶつかった技術的な問題や発見

PostgreSQLで配列の要素数を出力する

f:id:mask0702:20150701135528p:plain

PostgreSQLで配列の要素数を出力したくて、
PostgreSQL integer[] count」とかでググったら
PostgreSQL: Documentation: 9.1: intarray

こんな感じでicount()っていうの見つけたので

SELECT id, icount(hoge) from hoge_table;

ってやったら
No function matches the given name and argument types. You might need to add explicit type casts.

▂▅▇█▓▒░(’ω’)░▒▓█▇▅▂うわぁぁぁぁぁぁぁぁぁぁ!

なんか多分contribモジュールとかが足りないのかもしれない。
PostgreSQL Deep Dive: contribモジュールを使ってみよう


で、これ入れていいか先輩に聞いたら「array_length(hoge, 1) で良くね?」って言われて解決を見ました笑


PostgreSQL全機能バイブル

PostgreSQL全機能バイブル