sub descendants {
my ($org_name, $dbh) = @_;
- my $sql = 'SELECT aou.shortname FROM (SELECT * FROM actor.org_unit_descendants((SELECT id FROM actor.org_unit WHERE shortname = \'' . $org_name . '\'))) x JOIN actor.org_unit aou ON aou.id = x.id JOIN actor.org_unit_type aout ON aout.id = aou.ou_type WHERE aout.can_have_vols IS TRUE;';
+ my $sql = 'SELECT aou.shortname FROM (SELECT * FROM actor.org_unit_descendants((SELECT id FROM actor.org_unit WHERE shortname = ?))) x JOIN actor.org_unit aou ON aou.id = x.id JOIN actor.org_unit_type aout ON aout.id = aou.ou_type WHERE aout.can_have_vols IS TRUE;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_name);
my @valid_orgs;
while (my @row = $sth->fetchrow_array) {
push @valid_orgs, @row;
sub get_parent_name {
my ($org_id) = @_;
- my $sql = 'SELECT shortname FROM actor.org_unit WHERE id = ' . $org_id . ';';
+ my $sql = 'SELECT shortname FROM actor.org_unit WHERE id = ?;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_id);
my $r;
while (my @row = $sth->fetchrow_array) {
$r = $row[0];
sub get_org_id {
my ($org_name) = @_;
- my $sql = 'SELECT id FROM actor.org_unit WHERE shortname = \'' . $org_name . '\';';
+ my $sql = 'SELECT id FROM actor.org_unit WHERE shortname = ?;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_name);
my $r;
while (my @row = $sth->fetchrow_array) {
$r = $row[0];
sub get_full_name {
my ($org_id) = @_;
- my $sql = 'SELECT name FROM actor.org_unit WHERE id = ' . $org_id . ';';
+ my $sql = 'SELECT name FROM actor.org_unit WHERE id = ?;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_id);
my $r;
while (my @row = $sth->fetchrow_array) {
$r = $row[0];
sub get_post_code {
my ($org_id) = @_;
- my $sql = 'SELECT post_code FROM actor.org_address WHERE org_unit = ' . $org_id . ' AND post_code IS NOT NULL ORDER BY address_type = \'MAILING\' LIMIT 1;';
+ my $sql = 'SELECT post_code FROM actor.org_address WHERE org_unit = ? AND post_code IS NOT NULL ORDER BY address_type = \'MAILING\' LIMIT 1;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_id);
my $r;
while (my @row = $sth->fetchrow_array) {
$r = $row[0];
sub get_patron_count {
my ($org_id) = @_;
- my $sql = 'SELECT COUNT(id) FROM actor.usr WHERE home_ou = ' . $org_id . ' AND deleted IS FALSE AND active IS TRUE;';
+ my $sql = 'SELECT COUNT(id) FROM actor.usr WHERE home_ou = ? AND deleted IS FALSE AND active IS TRUE;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_id);
my $r;
while (my @row = $sth->fetchrow_array) {
$r = $row[0];
sub get_address {
my ($org_id) = @_;
- my $sql = 'SELECT street1 || \' \' || street2 || \';\' || city || \';\' || state FROM actor.org_address WHERE org_unit = ' . $org_id . ' AND post_code IS NOT NULL ORDER BY address_type ~* \'MAILING\' LIMIT 1;';
+ my $sql = 'SELECT street1 || \' \' || street2 || \';\' || city || \';\' || state FROM actor.org_address WHERE org_unit = ? AND post_code IS NOT NULL ORDER BY address_type ~* \'MAILING\' LIMIT 1;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_id);
my $r;
while (my @row = $sth->fetchrow_array) {
$r = $row[0];
,COUNT(DISTINCT circs_out.id)
,COUNT(DISTINCT onorder.id)
FROM
- (SELECT id, call_number FROM asset.copy WHERE circ_lib = ' . $org_id . ' AND deleted IS FALSE) ac
+ (SELECT id, call_number FROM asset.copy WHERE circ_lib = ? AND deleted IS FALSE) ac
LEFT JOIN
(SELECT id, target_copy FROM action.circulation WHERE xact_start > now() - interval \'1 week\') circs ON circs.target_copy = ac.id
LEFT JOIN
JOIN
reporter.super_simple_record ssr ON ssr.id = acn.record
LEFT JOIN
- (SELECT id, current_copy FROM action.hold_request WHERE pickup_lib = ' . $org_id . ' AND capture_time IS NOT NULL AND fulfillment_time IS NULL) holds ON holds.current_copy = ac.id
+ (SELECT id, current_copy FROM action.hold_request WHERE pickup_lib = ? AND capture_time IS NOT NULL AND fulfillment_time IS NULL) holds ON holds.current_copy = ac.id
GROUP BY 1, 2
;';
my $sth = $dbh->prepare($sql);
- $sth->execute();
+ $sth->execute($org_id, $org_id);
my @holdings;
while (my @row = $sth->fetchrow_array) {
push @holdings, {