Advertisement
Guest User

uh oh

a guest
Feb 7th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 5.31 KB | None | 0 0
  1. open-ils.cstore 2014-02-07 17:11:55 [ERR :5399:oils_sql.c:5585:1391810952544220] open-ils.cstore: Error WITH query [SELECT * FROM action.hold_request_permit_test( '8', '1', '2905', '1', '1' ) AS "action.hold_request_permit_test" ;]: 0 ERROR:  COLUMN reference "pickup_ou" IS ambiguous
  2. LINE 5: ...     LEFT JOIN actor.org_unit_ancestors_distance( pickup_ou ...
  3.                                                              ^
  4. DETAIL:  It could refer TO either a PL/pgSQL variable OR a TABLE COLUMN.
  5. QUERY:  SELECT                 m.*
  6.       FROM  config.hold_matrix_matchpoint m
  7.             /*LEFT*/ JOIN permission.grp_ancestors_distance( requestor_object.profile ) rpgad ON m.requestor_grp = rpgad.id
  8.             LEFT JOIN permission.grp_ancestors_distance( user_object.profile ) upgad ON m.usr_grp = upgad.id
  9.             LEFT JOIN actor.org_unit_ancestors_distance( pickup_ou ) puoua ON m.pickup_ou = puoua.id
  10.             LEFT JOIN actor.org_unit_ancestors_distance( request_ou ) rqoua ON m.request_ou = rqoua.id
  11.             LEFT JOIN actor.org_unit_ancestors_distance( item_cn_object.owning_lib ) cnoua ON m.item_owning_ou = cnoua.id
  12.             LEFT JOIN actor.org_unit_ancestors_distance( item_object.circ_lib ) iooua ON m.item_circ_ou = iooua.id
  13.             LEFT JOIN actor.org_unit_ancestors_distance( user_object.home_ou  ) uhoua ON m.user_home_ou = uhoua.id
  14.       WHERE m.active
  15.             -- Permission Groups
  16.          -- AND (m.requestor_grp        IS NULL OR upgad.id IS NOT NULL) -- Optional Requestor Group?
  17.             AND (m.usr_grp              IS NULL OR upgad.id IS NOT NULL)
  18.             -- Org Units
  19.             AND (m.pickup_ou            IS NULL OR (puoua.id IS NOT NULL AND (puoua.distance = 0 OR NOT m.strict_ou_match)))
  20.             AND (m.request_ou           IS NULL OR (rqoua.id IS NOT NULL AND (rqoua.distance = 0 OR NOT m.strict_ou_match)))
  21.             AND (m.item_owning_ou       IS NULL OR (cnoua.id IS NOT NULL AND (cnoua.distance = 0 OR NOT m.strict_ou_match)))
  22.             AND (m.item_circ_ou         IS NULL OR (iooua.id IS NOT NULL AND (iooua.distance = 0 OR NOT m.strict_ou_match)))
  23.             AND (m.user_home_ou         IS NULL OR (uhoua.id IS NOT NULL AND (uhoua.distance = 0 OR NOT m.strict_ou_match)))
  24.             -- Static User Checks
  25.             AND (m.juvenile_flag        IS NULL OR m.juvenile_flag = user_object.juvenile)
  26.             -- Static Item Checks
  27.             AND (m.circ_modifier        IS NULL OR m.circ_modifier = item_object.circ_modifier)
  28.             AND (m.marc_type            IS NULL OR m.marc_type = COALESCE(item_object.circ_as_type, rec_descriptor.item_type))
  29.             AND (m.marc_form            IS NULL OR m.marc_form = rec_descriptor.item_form)
  30.             AND (m.marc_bib_level       IS NULL OR m.marc_bib_level = rec_descriptor.bib_level)
  31.             AND (m.marc_vr_format       IS NULL OR m.marc_vr_format = rec_descriptor.vr_format)
  32.             AND (m.ref_flag             IS NULL OR m.ref_flag = item_object.REF)
  33.             AND (m.item_age             IS NULL OR (my_item_age IS NOT NULL AND m.item_age > my_item_age))
  34.       ORDER BY
  35.             -- Permission Groups
  36.             CASE WHEN rpgad.distance    IS NOT NULL THEN 2^(2*weights.requestor_grp - (rpgad.distance/denominator)) ELSE 0.0 END +
  37.             CASE WHEN upgad.distance    IS NOT NULL THEN 2^(2*weights.usr_grp - (upgad.distance/denominator)) ELSE 0.0 END +
  38.             -- Org Units
  39.             CASE WHEN puoua.distance    IS NOT NULL THEN 2^(2*weights.pickup_ou - (puoua.distance/denominator)) ELSE 0.0 END +
  40.             CASE WHEN rqoua.distance    IS NOT NULL THEN 2^(2*weights.request_ou - (rqoua.distance/denominator)) ELSE 0.0 END +
  41.             CASE WHEN cnoua.distance    IS NOT NULL THEN 2^(2*weights.item_owning_ou - (cnoua.distance/denominator)) ELSE 0.0 END +
  42.             CASE WHEN iooua.distance    IS NOT NULL THEN 2^(2*weights.item_circ_ou - (iooua.distance/denominator)) ELSE 0.0 END +
  43.             CASE WHEN uhoua.distance    IS NOT NULL THEN 2^(2*weights.user_home_ou - (uhoua.distance/denominator)) ELSE 0.0 END +
  44.             -- Static User Checks       -- Note: 4^x is equiv to 2^(2*x)
  45.             CASE WHEN m.juvenile_flag   IS NOT NULL THEN 4^weights.juvenile_flag ELSE 0.0 END +
  46.             -- Static Item Checks
  47.             CASE WHEN m.circ_modifier   IS NOT NULL THEN 4^weights.circ_modifier ELSE 0.0 END +
  48.             CASE WHEN m.marc_type       IS NOT NULL THEN 4^weights.marc_type ELSE 0.0 END +
  49.             CASE WHEN m.marc_form       IS NOT NULL THEN 4^weights.marc_form ELSE 0.0 END +
  50.             CASE WHEN m.marc_vr_format  IS NOT NULL THEN 4^weights.marc_vr_format ELSE 0.0 END +
  51.             CASE WHEN m.ref_flag        IS NOT NULL THEN 4^weights.ref_flag ELSE 0.0 END +
  52.             -- Item age has a slight adjustment to weight based on value.
  53.             -- This should ensure that a shorter age limit comes first when all else is equal.
  54.             -- NOTE: This assumes that intervals will normally be in days.
  55.             CASE WHEN m.item_age            IS NOT NULL THEN 4^weights.item_age - 86400/EXTRACT(EPOCH FROM m.item_age) ELSE 0.0 END DESC,
  56.             -- Final sort on id, so that if two rules have the same sorting in the previous sort they have a defined order
  57.             -- This prevents "we changed the table order by updating a rule, and we started getting different results"
  58.             m.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement