text:
Sustainable futures across the curriculum
- Introduction
- Activity 1
- Activity 2
- Activity 3
- Activity 4
- Activity 5
- Reflection
Education for Sustainable Development involves a comprehensive approach to educational reform. It extends beyond the boundaries of individual school subjects and requires the attention of teachers, educational administrators, planners and curriculum agencies.
Integrating the objectives, concepts and learning experiences of Education for Sustainable Development into syllabuses and teaching programmes is an important part of such reform, indeed:
A basic premise of education for sustainability is that just as there is a wholeness and interdependence to life in all its forms, so must there be a unity and wholeness to efforts to understand it and ensure its continuation. This calls for both interdisciplinary inquiry and action. It does not, of course, imply an end to work within traditional disciplines. A disciplinary focus is often helpful, even necessary, in allowing the depth of inquiry needed for major breakthroughs and discoveries.
Source: UNESCO (1997) Educating for a Sustainable Future: A Transdisciplinary Vision for Concerted Action, paragraph 89.
This module illustrates ways in which Education for Sustainable Development can be integrated into and across twelve different school subjects or areas of the curriculum. It also explores ways in which Education for Sustainable Development is relevant to all educational objectives and how it can be integrated into the celebrations in the school calendar.
- To appreciate the importance of both the formal and informal curriculum in promoting Education for Sustainable Development;
- To understand ways in which general educational objectives, interdisciplinary teaching methods, different subjects and various celebrations in the school calendar may be used to help reorient the curriculum of a school towards sustainability; and
- To promote across-the-curriculum approaches to Education for Sustainable Development.
- What is the curriculum?
- Interdisciplinary teaching and learning
- Integrating through educational objectives
- Infusing through learning experiences in all subject areas
- Celebrations in the school calendar
- Reflection
Breiting, S. and Meyer, M. and Morgensen, F. (2005) Quality Criteria for ESD-Schools: Guidelines to Enhance the Quality of Education for Sustainable Development, EU-COMENIUS 3 network 'School Development through Environmental Education' (SEED).
Dandell, K., Ohman, J and Ostman, L. (2005) Education for Sustainable Development: Nature, School and Democracy, Studentlitteratu, Lund.
Fien, J. (2002) Education and Sustainability: Reorienting Australian Schools for a Sustainable Future, Tela Papers, No. 8. Australian Conservation Foundation, Melbourne.
Hren, B. and Birney, A. (2004) Pathways: A Development Framework for School Sustainability, WWF, Godalming, Surrey.
Reid, A. et al. (2008) Participation and Learning: Perspectives on Education and the Environment, Health and Sustainability, Springer, Dortrecht.
Scott, W. and Gough, S. (2003) Sustainable Development and Learning, Framing the Issues, Routledge Falmer, London.
Sterling, S. (2002) Sustainable Education: Re-visioning Learning and Change, Green Books, Bristol.
Sterling, S. et al (2005) Linking Thinking: New Perspectives on Thinking and Learning for Sustainability, WWF Scotland.
Wals, A., Shallcross, T., Robinson, J. and Pace, P. (Eds) (2006) Creating Sustainable Environments in Our Schools, Trentham Books, Stoke-on-Trent, Staffordshire.
This module was written for UNESCO by Bernard Cox, John Fien and Clayton White from activities and material in Learning for a Sustainable Environment (UNESCO – ACEID). It also draws on the work of the Environmental Education Curriculum Initiative in South Africa and its publication, School Environmental Policy and Management Plan.
What is the curriculum?
Begin by opening your learning journal for this activity.
This module focuses on the different ways in which schools and teachers can ensure that Education for Sustainable Development is integrated across all aspects of the school curriculum.
A Model of Curriculum
The different aspects of school life are illustrated in this model of the school curriculum. All the elements in this curriculum model affect the educational experiences of young people in schools.
Click on the different elements of the school curriculum in this model to investigate how they may contribute towards a sustainable future.
The Curriculum Experience
If the curriculum is defined as 'the sum of all the formal and informal teaching and learning experiences provided by a school', then Education for Sustainable Development cannot just be added to the curriculum as a new subject. Rather, it is a dimension to be emphasised in every aspect of school life.
Whether the curriculum actually achieves this goal or not will be affected by many issues. While these often extend beyond the responsibilities of a single school or teacher, there are many things that schools and teachers can do, including the following few activities:
- Interdisciplinary teaching and learning (Activity 2);
- Integration through educational objectives (Activity 3);
- Infusion into learning experiences in all subjects (Activity 4); and
- Celebrations in the school calendar (Activity 5).
Q1: In your learning journal, identify:
- Which two of these activities would you find most easy to do? Why?
- Which two would you find most difficult? Why?
These answers will be used in the concluding activity.
Interdisciplinary teaching and learning
Meaningful learning requires students to integrate ideas from many different perspectives rather than compartmentalise what they learn into discrete 'boxes' of knowledge. As a result, teachers need to be flexible and skilled in accessing and integrating knowledge from different sources and disciplines.
Solving society's problems requires inputs from many disciplines or specialisations. Just as a variety of specialists need to work together to solve problems in the world outside the classroom, disciplines should not be separated unnecessarily inside the classroom either.
It is possible for teachers to emphasise interdisciplinary teaching and learning in their own classes, e.g. through the topics and examples they choose. This activity provides an example of how this can be done. However, it is also important that teachers work in a co-ordinated and co-operative way so that students are given the opportunity to integrate knowledge across subjects and across the years of schooling.
An Interdisciplinary Case Study
Consider this case study of a class investigation of local traffic problems.
Traffic had been very bad outside a school for a long time. So, a teacher and her class of 12-year old students carried out an investigation into the need for a pedestrian crossing to make it safer for people to cross the road. The students first decided to carry out a survey to count the numbers of vehicles travelling in both directions. They calculated the average speed of the vehicles, the percentage of those exceeding the speed limit and the percentage of drivers that would have been unable to stop within a reasonable distance. The students also counted the number of pedestrians crossing and identified peak times. The results of the traffic survey were displayed in the form of bar charts and graphs.
The findings were compared with the local authority's guidelines for the provision of pedestrian crossings. The students then wrote a report on the degree of risk involved in crossing the road to reach the school and the best location for the pedestrian crossing. They included data, figures, photographs and plans in their reports.
The response of the local authority to date has not been encouraging. So, the students are now working with the local neighbourhood association to press their case for action.
Source: Adapted from Gough, N. (1992) Blueprints for Greening Schools, Gould League, Melbourne, pp. 86.
Integrating through educational objectives
Begin by opening your learning journal for this activity.
An over-loaded curriculum is a concern of many teachers. Increasingly, teachers are feeling that there is not enough time to cover all the additional material being put into the curriculum. As a result, many feel that covering the content of key subjects, such as language, mathematics, science and social studies, must come ahead of cross-curriculum themes such as Education for Sustainable Development.
However, there is another way of looking at this problem.
Many educational objectives, especially in the areas of attitudes and skills, are common across most subjects in the curriculum. Teaching about sustainability emphasises critical and creative thinking, problem solving, decision making, analysis, co-operative learning, leadership, and communication skills. As a result, it is a very good way of achieving educational objectives without adding to the problem of curriculum overload.
Examples of across-the-curriculum objectives that can be served by Education for Sustainable Development include:
Attitudes and Values
- Care for the community.
- Respect for the beliefs and opinions of others.
- Respect for evidence and rational argument.
- Tolerance and open-mindedness.
- Communication skills
- For example:
- Expressing views through different media; and
- Arguing clearly and concisely.
- Numeracy skills
- For example:
- Collecting, classifying and analysing data; and
- Interpreting statistics.
- Study skills
- For example:
- Retrieving, analysing, interpreting and evaluating information from a variety of sources; and
- Organising and planning a project.
- Problem solving skills
- For example:
- Identifying causes and consequences of problems; and
- Forming reasoned opinions and developing balanced judgements.
- Personal and social skills
- For example:
- Working co-operatively with others; and
- Taking individual and group responsibility.
- Information technology skills
- For example:
- Collecting information and entering it into a database; and
- Simulating an investigation using information technology.
Source: Adapted from Monroe, M. and Cappaert, D. (1994) Integrating Environmental Education into the School Curriculum, National Consortium for Environmental Education and Training, University of Michigan, Ann Arbor, pp. 3-5.
Analysing the Case Study
Read the case study about the student investigation of local traffic problems again.
Q2: Identify an example in the local traffic teaching unit to illustrate how the skills and attitudes, so important in learning for a sustainable future, were included in the learning experiences of the students.
Q3: What other learning experiences could have been integrated into this unit to enhance student learning?
Infusing through learning experiences in all subject areas
Begin by opening your learning journal for this activity.
Ideally, Education for Sustainable Development should permeate the entire school curriculum, with every subject area, at every year level, dealing with aspects of sustainability in some way.
Some subjects, by their very nature, present greater opportunities for such infusion than others, but all subjects have a very important role to play.
The Contributions of Existing School Subjects
This activity illustrates that Education for Sustainable Development can be infused into a wide range of subject areas.
Read examples of the ways in which objectives and themes that promote learning for a sustainable future can be reflected in a wide range of subjects across the curriculum.
- Agricultural Studies
- Home Economics
- The Arts
- Mathematics
- Commerce and Business Studies
- Manual Arts and Technology
- First Language Studies
- Religious Education
- Second Language Studies
- Science
- Health and Physical Education
- Social Studies
Source: Adapted from Gough, N. (1992) Blueprints for Greening Schools, Gould League, Melbourne, pp. 80-81.
Match the learning experiences with the appropriate subject areas where they might be taught.
Q4: Identify three subject areas you like to teach. For each one, list at least three learning experiences that could be developed to infuse learning for a sustainable future.
See a completed table of learning experiences and the twelve subject areas.
Teaching about the Earth Charter
The Earth Charter is a declaration of the interdependence of all living and non-living things on Earth. It is also a statement about the principles and values needed to build a global partnership for sustainable development.
The focus of the Earth Charter is sustainable human development. How might the principles and values in the Earth Charter be taught through different subjects in the school curriculum?
Review a summary of the relevance of the Earth Charter to teaching in the following subject areas:
Celebrations in the school calendar
Begin by opening your learning journal for this activity.
International bodies such as the United Nations have obtained the agreement of governments around the world to designate certain days and weeks as times of celebration and remembrance for particular issues. Education is the key purpose of these days and many provide opportunities to educate for a sustainable future.
A regular programme of celebrations in the School Calendar is a powerful way of promoting interest in a sustainable future.
Q5: Which days are celebrated in your School Calendar? List the days that would be culturally appropriate and locally relevant to include in your School Calendar of celebratory days?
- February 2 – World Wetlands Day
- March 23 – World Meteorological Day
- April 7 – World Health Day
- May 1 – Workers' Day
- May 15 – International Day of Families
- May 18 – International Day of Museums
- June 5 – World Environment Day
- June 17 – World Day to Combat Desertification
- July 11 – World Population Day
- August 9 – International Day of the World's Indigenous People
- September 8 – International Literacy Day
- September 16 – International Day for the Preservation of the Ozone Layer
- September 17-19 – Clean Up the World
- September 21 – International Day of Peace
- October 5 – World Teachers' Day
- October 16 – World Food Day
- October 24-30 – Week for Disarmament and Development
- November 20 – Universal Children's Day
- December 10 – Human Rights Day
Source: Adapted from A Year of Special Days: Justice, Peace and the Environment, Share-Net, Howick, South Africa, 1999.
Q6: List three skills you have that you could use to encourage others in your school to include the celebrations of these 'days' into the School Calendar.
Q7: Identify three colleagues you believe would be willing to join a working party to achieve this. What skills do they bring?
Research other International Days observed by the United Nations system.
Begin by opening your learning journal for this activity.Completing the module: Look back through the activities and tasks to check that you have done them all and to change any that you think you can improve now that you have come to the end of the module.
Activity 1 illustrated twelve ways in which the objectives and themes of Education for Sustainable Development can be integrated as an across-the-curriculum perspective.
This module has focused on only four of these:
- Interdisciplinary teaching and learning (Activity 2);
- Integration through educational objectives (Activity 3);
- Infusion into learning experiences in all subjects (Activity 4); and
- Celebrations in the school calendar (Activity 5).
Q8: Which one of these four would be (i) the easiest and (ii) the most difficult to implement in your school? Why?
Developing a School Policy
Integrating education requires a comprehensive school policy and the co-operation of all teachers in the school, as well as students, parents and the wider community.
Six steps could be followed in the policy development process:
- Appoint a co-ordinator
- Publish draft policy
- Convene a policy committee
- Implement action plans
- Undertake a school audit process
- Evaluate and review
Q9: List the steps you would follow in building support for a decision to develop a Policy on Education for Sustainable Development in your school.


text:
Discharge Information
Your physician will determine when you are able to leave the hospital. Physicians make their rounds in the morning, so discharge times are generally no later than 11 a.m. Your nurse will give discharge instructions and any prescriptions needed for your recovery. Discharge time and instructions are personalized to your particular procedure and how well you are recovering. Please note that prescriptions need to be filled at an outside pharmacy.
If you have questions or concerns about your discharge, please speak with your nurse or social worker.

subset: commoncrawl


text:
DOCTOR WHO Season 1 Episode 6 : Dalek
Location: Utah, Earth Date: 2012 Enemy: Dalek The Doctor and Rose find themselves in an underground museum in Utah in the year 2012. The museum houses all kinds of extra-terrestrial artefacts the only living exhibit being one of the Doctor's oldest enemies - a Dalek. But soon after, it escapes from its "torture chamber," and goes on a killing spree. Will Rose be one of the victims?
Episode Guide
Season 01
Season 02
Season 03
Season 04
Season 05
Season 06
Season 07
Season 08
Season 09
Season 10
Season 11
Season 12


text:
When Apple makes it rain, it makes it pour. In addition to releasing iOS 6 and OS X 10.8.2, the company updated a homescreen's worth of its own iOS apps on Wednesday, including Cards, iPhoto, GarageBand, iMovie, Keynote, Podcasts, Airport Utility, iBooks, iTunes U, Find My Friends, and Find My iPhone.
New in Cards 2.0 is native support for the iPad, so that you can now send your 100 percent letterpress missives from iOS devices of any size. Other new options in the app include the ability to send cards to multiple recipients at once, new holiday designs, new layouts for adding up to three photos to a single card, better image sharpening, integration with iPhoto, and—unsurprisingly enough—support for the iPhone 5's taller screen.
iPhoto gets bumped to version 1.1 and gains several new features. The app now supports the iPod touch (fourth generation and newer); the Help system also gets several new tips. New ink effects can be applied to images, and the existing tilt-shift and gradient effects can be rotated. Also new: You can edit images up to 36.5 megapixels within the app if you're using a third-generation iPad. The "Updating Library" message should appear less frequently, Apple says, and you can save multiple photos to your device's Camera Roll at one time.
Other iPhoto additions include smarter automated cropping, which leverages face detection to try to prevent cropping right in the middle of your yapper. You can create tag albums by adding custom tags to photos, and you can share photos and videos to Facebook leveraging iOS 6's built-in Facebook single sign-on option. Locations and friend tags can now be set when posting photos to Facebook, and comments and locations can be set on individual photos when sharing a group of photos on the service.
You can share iPhoto photos to Cards, iMovie, and other apps. There are numerous new options for Journals, as well.
Finally, several changes aid photo navigation: An overlay displaying month and year appears as you scroll through photos—much as it does in iPhoto on the Mac. You can sort photos by date and filter them in more ways, and thumbnail grids can now expand to multiple rows in portrait mode.
iMovie gets updated to version 1.4, and it gains three new trailer options. Photos that you add to trailers automatically animate with Apple's beloved Ken Burns effect.
Other new features include the ability to use the Precision Editor on the iPad to create split audio edits, an option to play clips in the Video Browser before adding them to a project, the ability to create a slideshow with photos from iPhoto for iOS, and inline coaching tips when you tap the Help icon. You can also now export videos in 1080p high definition to Facebook, YouTube, Vimeo, and CNN iReport. And audio records you capture within a project now appear in the Audio Browser.
GarageBand gets in on the update action, too. Version 1.3 lets you create custom ringtones and alerts for your iPhone, iPad, or iPod touch, if you're running iOS 6 or later. You can also import songs from the Music library on your iOS device. And, provided you're using an iPhone 4S, iPad 2, or fourth-generation iPod touch or newer, you can play or record with GarageBand in the background while using other apps.
Smaller updates
Keynote 1.6.2 gains but two small features: support for iOS 6, and the ability to open presentations in another app. AirPort Utility 1.1.1, iBooks 2.2, and Remote 2.4 similarly gain iOS 6 support.
Podcasts 1.1 gets iOS 6 support, including a pull-to-refresh option for checking for new podcasts. It also adds subscription syncing via iCloud, a setting to limit downloading to Wi-Fi, a setting to toggle between playing podcasts newest first or the opposite, and various performance and stability improvements. iTunes U 1.3 gets iOS 6 support, gains a new single day view, and fixes a problem with Closed Captioning.
All the updates are available, of course, via the App Store.
Updated repeatedly around 2:50 p.m. and 3:20 p.m. ET with details on more app updates from Apple.


text:
The Olympus Pro Photographer Showdown (PPS) is one of the most highly anticipated segments of the annual World Ski & Snowboard Festival (WSSF) in Whistler, BC. This year, in celebration of the 20th annual WSSF, event organizers modified the selection process. Historically, photogs would present formal submissions in the hopes of being selected as contestants. This time around, the WSSF staffers handpicked and invited five photographers: Brian Gaberman, Mattias Fredriksson, Todd Glaser, Reuben Krabbe and Lorenz Holder.
Each produced a slideshow, and between the five of 'em their images showcase predominantly skiing, snowboarding, mountain biking, surfing, skateboarding and mind-boggling scenics.
Local ski and mountain bike photographer, Reuben Krabbe, took home the People's Choice Award this year, earning him a cool $1,000. Lorenz Holder earned Best In Show honors and the $10,000 grand prize that goes hand-in-hand. His award-winning slideshow is posted here for your viewing pleasure.
Related: This slideshow by Reuben Krabbe won the Hot Lapse 72-hr photo showdown; enjoy


text:
Ever since Microsoft announced its Xbox Play Anywhere program—a fancy name for "We're porting all our first-party titles to PC"—the game I've been looking forward to most is Forza Horizon 3. Bombing through the back-country of Australia at 144 frames per second, music thumping, tires squealing, reflections…reflecting.
And after spending most of a night with the game, I can confirm it's gorgeous. The Twelve Apostles look particularly lifelike, white sandstone set against the brilliant blue ocean. I must've taken a dozen screenshots of that area alone.
You're going to need one monster of a PC, though. My home machine is running on an Nvidia GTX 980 Ti (with the brand-new Game Ready drivers) and my jaw dropped when I booted up Forza Horizon 3 and it recommended I run everything on Medium settings. That estimate ended up being a bit conservative—I can eke out an almost-steady 60 frames per second on High—but the fact remains this is one demanding game.
Now, it still looks great on lower settings. Hell, it still looks good on the Xbox One and that's about as low as you can go. Be ready to dial in your settings though, as racing games rely on a steady frame rate more than perhaps any other genre.
To that end developer Playground Games has equipped Forza Horizon 3 with a full bevy of graphics options, far surpassing what we got with Microsoft's Quantum Break and Gears of War: Ultimate Edition earlier this year. Forza even packs a built-in frame rate counter, since external solutions don't play nice with UWP.
I admit I'm a bit frustrated with how many options require a full restart to take effect, however. Anything that affects draw distance or level geometry means closing the game down and waiting for it to load back up again—a lengthy process, even on an SSD, and one that becomes progressively more frustrating the longer you spend trying to nail down your settings. And while MSAA doesn't require a full restart, it does require a load screen that seems to stretch on into eternity.
Loads in general seem slow, actually—both the initial start-up and load-streaming. No matter my frame rate, I seem to see slight stuttering as new areas are pumped in. And worse, you'l encounter sluggish menus, particularly when customizing your car. I spent last night tricking out a 1969 Charger, and it took about twice as long as it should've because each part-swap took a second or two to load in. That's not much in isolation, but repeated a hundred times it's a bit aggravating.
We'll have a lengthier review up soon, and I'm planning to dig into the game's performance quite a bit more over the weekend. This is merely my impressions after two or three hours of playing—I was admittedly pretty worried when Microsoft didn't get PC review code out day-and-date with the Xbox One evaluation copies. As it stands, those fears seem largely baseless. Forza Horizon 3 could use a bit more optimization perhaps, but it's a far cry from broken. Just intimidating.


text: 100 S/s/ch, 4-Channel C Series Universal Analog Input Module—The NI‑9219 is designed for multipurpose testing. With the NI‑9219, you can measure signals from sensors such as strain gages, resistance temperature detectors (RTDs), thermocouples, load cells, and other powered sensors, as well as make quarter-bridge, half-bridge, and full-bridge current measurements, with built-in voltage and current excitation. Each channel is individually selectable, so you can perform a different measurement type on each channel.


text:
DBD::Pg - PostgreSQL database driver for the DBI module
This documents version 2.0.0 of the DBD::Pg module
use DBI;
$dbh = DBI->connect("dbi:Pg:dbname=$dbname", "", "", {AutoCommit => 0});
# For some advanced uses you may need PostgreSQL type values:
use DBD::Pg qw(:pg_types);
# See the DBI module documentation for full details
DBD::Pg is a Perl module that works with the DBI module to provide access to PostgreSQL databases.
This documentation describes driver specific behavior and restrictions. It is not supposed to be used as the only reference for the user. In any case consult the DBI documentation first!
To connect to a database with a minimum of parameters, use the following syntax:
$dbh = DBI->connect("dbi:Pg:dbname=$dbname", "", "");
This connects to the database $dbname on the default port (usually 5432) without any user authentication.
The following connect statement shows almost all possible parameters:
$dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$host;port=$port;" .
"options=$options", "$username", "$password",
{AutoCommit => 0});
If a parameter is not given, the PostgreSQL server will first look for specific environment variables, and then use hard-coded defaults:
parameter environment variable hard coded default
host PGHOST local domain socket
hostaddr PGHOSTADDR local domain socket
port PGPORT 5432
dbname* PGDATABASE current userid
username PGUSER current userid
password PGPASSWORD (none)
options PGOPTIONS (none)
service PGSERVICE (none)
sslmode PGSSLMODE (none)
* Can also use "db" or "database"
The options parameter specifies runtime options for the Postgres backend. Common usage is to increase the number of buffers with the -B option. Also important is the -F option, which disables automatic fsync() call after each transaction. For further details please refer to the PostgreSQL documentation at http://www.postgresql.org/docs/.
For authentication with username and password, appropriate entries have to be made in the pg_hba.conf file. If the username and password entries passed via connect() are undefined (as opposed to being empty), DBI will use the environment variables DBI_USER and DBI_PASS if they exists.
You can also connect by using a service connection file, which is named "pg_service.conf." The location of this file can be controlled by setting the PGSYSCONFDIR environment variable. To use one of the named services within the file, set the name by using either the "service" parameter or the environment variable PGSERVICE. Note that when connecting this way, only the minimum parameters should be used. For example, to connect to a service named "zephyr", you could use:
$dbh = DBI->connect("dbi:Pg:service=zephyr", "", "");
You could also set $ENV{PGSERVICE} to "zephyr" and connect like this:
$dbh = DBI->connect("dbi:Pg:", "", "");
The format of the pg_service.conf file is simply a bracketed service name, followed by one parameter per line in the format name=value. For example:
There are four valid arguments to the "sslmode" parameter, which controls whether to use SSL to connect to the database:
Implemented by DBI, no driver-specific impact.
@driver_names = DBI->available_drivers;
@data_sources = DBI->data_sources('Pg');
This driver supports this method. Note that the necessary database connection to the database "template1" will be made on the localhost without any user authentication. Other preferences can be set with the environment variables PGHOST, PGPORT, DBI_USER, DBI_PASS, and PGSERVICE.
You can also pass in options to add to the connection string as the second argument to data_sources. For example, to specify an alternate port and host:
@data_sources = DBI->data_sources('Pg', 'port=5824;host=example.com');
$rv = $h->err;
Supported by this driver as proposed by DBI. For the connect method it returns PQstatus. In all other cases it returns PQresultStatus of the current handle.
$str = $h->errstr;
Supported by this driver as proposed by DBI. It returns the PQerrorMessage related to the current handle.
$str = $h->state;
Supported by this driver. Returns a five-character "SQLSTATE" code. Success is indicated by a "00000" code, which gets mapped to an empty string by DBI. A code of S8006 indicates a connection failure, usually because the connection to the PostgreSQL server has been lost.
Note that state can be called as either $sth->state or $dbh->state.
The list of codes used by PostgreSQL can be found at: http://www.postgresql.org/docs/current/static/errcodes-appendix.html
Note that these codes are part of the SQL standard and only a small number of them will be used by PostgreSQL.
Common ones to note:
00000 Successful completion
25P01 No active SQL transaction
25P02 In failed SQL transaction
$h->trace($trace_level, $trace_filename);
$h->trace_msg($message_text, $min_level);
This driver supports a variety of driver specific functions accessible via the func method. Note that the name of the function comes last, after the arguments.
$attrs = $dbh->func($table, 'table_attributes');
The table_attributes function is no longer recommended. Instead, you can use the more portable column_info and primary_key methods to access the same information.
The table_attributes method returns, for the given table argument, a reference to an array of hashes, each of which contains the following keys:
NAME attribute name
TYPE attribute type
SIZE attribute size (-1 for variable size)
NULLABLE flag nullable
DEFAULT default value
CONSTRAINT constraint
PRIMARY_KEY flag is_primary_key
REMARKS attribute description
$lobjId = $dbh->func($mode, 'lo_creat');
Creates a new large object and returns the object-id. $mode is a bitmask describing different attributes of the new object. Use the following constants:
Upon failure it returns undef.
$lobj_fd = $dbh->func($lobjId, $mode, 'lo_open');
Opens an existing large object and returns an object-descriptor for use in subsequent lo_* calls. For the mode bits see lo_creat. Returns undef upon failure. Note that 0 is a perfectly correct object descriptor!
$nbytes = $dbh->func($lobj_fd, $buf, $len, 'lo_write');
Writes $len bytes of $buf into the large object $lobj_fd. Returns the number of bytes written and undef upon failure.
$nbytes = $dbh->func($lobj_fd, $buf, $len, 'lo_read');
Reads $len bytes into $buf from large object $lobj_fd. Returns the number of bytes read and undef upon failure.
$loc = $dbh->func($lobj_fd, $offset, $whence, 'lo_lseek');
Changes the current read or write location on the large object $obj_id. Currently $whence can only be 0 (L_SET). Returns the current location and undef upon failure.
$loc = $dbh->func($lobj_fd, 'lo_tell');
Returns the current read or write location on the large object $lobj_fd and undef upon failure.
$lobj_fd = $dbh->func($lobj_fd, 'lo_close');
Closes an existing large object. Returns true upon success and false upon failure.
$ret = $dbh->func($lobjId, 'lo_unlink');
Deletes an existing large object. Returns true upon success and false upon failure.
$lobjId = $dbh->func($filename, 'lo_import');
Imports a Unix file as large object and returns the object id of the new object or undef upon failure.
$ret = $dbh->func($lobjId, $filename, 'lo_export');
Exports a large object into a Unix file. Returns false upon failure, true otherwise.
$ret = $dbh->func('pg_notifies');
Returns either undef or a reference to two-element array [ $table, $backend_pid ] of asynchronous notifications received. Note that this does not check if the connection to the database is still valid - for that, use the c<ping> method. Also note that you may need to commit if not in autocommit mode - new notices will not be picked up while in the middle of a transaction. An example:
$dbh->do("LISTEN abc");
$dbh->do("LISTEN def");
## Hang around until we get the message we want
while (my $notify = $dbh->func('pg_notifies')) {
my ($name, $pid) = @$notify;
print qq{I received notice "$name" from PID $pid\n};
## Do something based on the notice received
$dbh->ping() or die qq{Ping failed!};
$fd = $dbh->func('getfd');
Returns fd of the actual connection to server. Can be used with select() and func('pg_notifies'). Deprecated in favor of $dbh->{pg_socket}.
$hashref = $dbh->private_attribute_info();
$hashref = $sth->private_attribute_info();
Supported by this driver as proposed by DBI.
Supported by this driver as proposed by DBI. A database handle is active while it is connected and statement handle is active until it is finished.
Implemented by DBI, no driver-specific impact. Requires DBI 1.41 or greater.
Not used by this driver.
Implemented by DBI, no driver-specific impact. If set to true, then the disconnect() method will not be automatically called when the database handle goes out of scope (e.g. when exiting after a fork).
Supported by this driver as proposed by DBI. This method is similar to the SQL function RTRIM.
@row_ary = $dbh->selectrow_array($statement, \%attr, @bind_values);
$ary_ref = $dbh->selectrow_arrayref($statement, \%attr, @bind_values);
$hash_ref = $dbh->selectrow_hashref($statement, \%attr, @bind_values);
$ary_ref = $dbh->selectall_arrayref($statement, \%attr, @bind_values);
$hash_ref = $dbh->selectall_hashref($statement, $key_field);
$ary_ref = $dbh->selectcol_arrayref($statement, \%attr, @bind_values);
$sth = $dbh->prepare($statement, \%attr);
WARNING: DBD::Pg now uses true prepared statements by sending them to the backend to be prepared by the PostgreSQL server. Statements that were legal before may no longer work. See below for details.
Prepares a statement for later execution. PostgreSQL supports prepared statements, which enables DBD::Pg to only send the query once, and simply send the arguments for every subsequent call to execute(). DBD::Pg can use these server-side prepared statements, or it can just send the entire query to the server each time. The best way is automatically chosen for each query. This will be sufficient for most users: keep reading for a more detailed explanation and some optional flags.
Statements that do not begin with the word "SELECT", "INSERT", "UPDATE", or "DELETE" will not be sent to be server-side prepared.
Deciding whether or not to use prepared statements depends on many factors, but you can force them to be used or not used by passing the pg_server_prepare attribute to prepare(). A "0" means to never use prepared statements. Setting pg_server_prepare to "1" means that prepared statements should be used whenever possible. This is the default for servers version 8.0 or higher. Servers that are version 7.4 get a special default value of "2", because server-side statements were only partially supported in that version. In this case, it only uses server-side prepares if all parameters are specifically bound.
The pg_server_prepare attribute can also be set at connection time like so:
$dbh = DBI->connect($DBNAME, $DBUSER, $DBPASS,
{ AutoCommit => 0,
RaiseError => 1,
pg_server_prepare => 0 });
or you may set it after your database handle is created:
$dbh->{pg_server_prepare} = 1;
To enable it for just one particular statement:
$sth = $dbh->prepare("SELECT id FROM mytable WHERE val = ?",
{ pg_server_prepare => 1 });
You can even toggle between the two as you go:
$sth->{pg_server_prepare} = 1;
$sth->{pg_server_prepare} = 0;
$sth->{pg_server_prepare} = 1;
In the above example, the first execute will use the previously prepared statement. The second execute will not, but will build the query into a single string and send it to the server. The third one will act like the first and only send the arguments. Even if you toggle back and forth, a statement is only prepared once.
Using prepared statements is in theory quite a bit faster: not only does the PostgreSQL backend only have to prepare the query only once, but DBD::Pg no longer has to worry about quoting each value before sending it to the server.
However, there are some drawbacks. The server cannot always choose the ideal parse plan because it will not know the arguments before hand. But for most situations in which you will be executing similar data many times, the default plan will probably work out well. Programs such as PgBouncer which cache connections at a low level should not use prepared statements via DBD::Pg, or must take extra care in the application to account for the fact that prepared statements are not shared across database connections. Further discussion on this subject is beyond the scope of this documentation: please consult the pgsql-performance mailing list, http://archives.postgresql.org/pgsql-performance/
Only certain commands will be sent to a server-side prepare: currently these include SELECT, INSERT, UPDATE, and DELETE. DBD::Pg uses a simple naming scheme for the prepared statements: dbdpg_#, where "#" starts at 1 and increases. This number is tracked at the database handle level, so multiple statement handles will not collide. If you use your own prepare statements, do not name them "dbdpg_"!
You cannot send more than one command at a time in the same prepare command, by separating them with semi-colons, when using server-side prepares.
The actual PREPARE is not performed until the first execute is called, due to the fact that information on the data types (provided by bind_param) may be given after the prepare but before the execute.
A server-side prepare can also happen before the first execute. If the server can handle the server-side prepare and the statement has no placeholders, it will be prepared right away. It will also be prepared if the pg_prepare_now attribute is passed. Similarly, the <pg_prepare_now> attribute can be set to 0 to ensure that the statement is not prepared immediately, although cases in which you would want this may be rare. Finally, you can set the default behavior of all prepare statements by setting the pg_prepare_now attribute on the database handle:
$dbh->{pg_prepare_now} = 1;
The following two examples will be prepared right away:
$sth->prepare("SELECT 123"); ## no placeholders
$sth->prepare("SELECT 123, ?", {pg_prepare_now => 1});
The following two examples will NOT be prepared right away:
$sth->prepare("SELECT 123, ?"); ## has a placeholder
$sth->prepare("SELECT 123", {pg_prepare_now => 0});
There are times when you may want to prepare a statement yourself. To do this, simply send the PREPARE statement directly to the server (e.g. with "do"). Create a statement handle and set the prepared name via pg_prepare_name attribute. The statement handle can be created with a dummy statement, as it will not be executed. However, it should have the same number of placeholders as your prepared statement. Example:
$dbh->do("PREPARE mystat AS SELECT COUNT(*) FROM pg_class WHERE reltuples < ?");
$sth = $dbh->prepare("SELECT ?");
$sth->bind_param(1, 1, SQL_INTEGER);
$sth->{pg_prepare_name} = "mystat";
The above will run this query:
SELECT COUNT(*) FROM pg_class WHERE reltuples < 123;
Note: DBD::Pg will not escape your custom prepared statement name, so don't use a name that needs escaping! DBD::Pg uses the prepare names dbdpg_# internally, so please do not use those either.
You can force DBD::Pg to send your query directly to the server by adding the pg_direct attribute to your prepare call. This is not recommended, but is added just in case you need it.
There are three types of placeholders that can be used in DBD::Pg. The first is the question mark method, in which each placeholder is represented by a single question mark. This is the method recommended by the DBI specs and is the most portable. Each question mark is replaced by a "dollar sign number" in the order in which they appear in the query (important when using bind_param).
The second method is to use "dollar sign numbers" directly. This is the method that PostgreSQL uses internally and is overall probably the best method to use if you do not need compatibility with other database systems. DBD::Pg, like PostgreSQL, allows the same number to be used more than once in the query. Numbers must start with "1" and increment by one value. If the same number appears more than once in a query, it is treated as a single parameter and all instances are replaced at once. Examples:
Not legal:
$SQL = 'SELECT count(*) FROM pg_class WHERE relpages > $2';
$SQL = 'SELECT count(*) FROM pg_class WHERE relpages BETWEEN $1 AND $3';
$SQL = 'SELECT count(*) FROM pg_class WHERE relpages > $1';
$SQL = 'SELECT count(*) FROM pg_class WHERE relpages BETWEEN $1 AND $2';
$SQL = 'SELECT count(*) FROM pg_class WHERE relpages BETWEEN $1 AND $2 AND reltuples > $1';
$SQL = 'SELECT count(*) FROM pg_class WHERE relpages > $1 AND reltuples > $1';
In the final statement above, DBI thinks there is only one placeholder, so this statement will replace both placeholders:
$sth->bind_param(1, 2045);
While execute requires only a single argument as well:
The final placeholder method is the named parameters in the format ":foo". While this syntax is supported by DBD::Pg, its use is highly discouraged.
The different types of placeholders cannot be mixed within a statement, but you may use different ones for each statement handle you have. Again, this is not encouraged.
If your queries use operators that contain question marks (e.g. some of the native Postgres geometric operators) or array slices (e.g. data[100:300]), you can tell DBD::Pg to ignore any non-dollar sign placeholders by setting the "pg_placeholder_dollaronly" attribute at either the database handle or the statement handle level. Examples:
$dbh->{pg_placeholder_dollaronly} = 1;
$sth = $dbh->prepare(q{SELECT * FROM mytable WHERE lseg1 ?# lseg2 AND name = $1});
Alternatively, you can set it at prepare time:
$sth = $dbh->prepare(q{SELECT * FROM mytable WHERE lseg1 ?-| lseg2 AND name = $1},
{pg_placeholder_dollaronly = 1});
$sth = $dbh->prepare_cached($statement, \%attr);
Implemented by DBI, no driver-specific impact. This method is most useful when using a server that supports server-side prepares, and you have asked the prepare to happen immediately via the pg_prepare_now attribute.
$rv = $dbh->do($statement, \%attr, @bind_values);
Prepare and execute a single statement. Note that an empty statement (string with no length) will not be passed to the server; if you want a simple test, use "SELECT 123" or the ping() function. If neither attr nor bind_values is given, the query will be sent directly to the server without the overhead of creating a statement handle and running prepare and execute.
$rv = $dbh->last_insert_id($catalog, $schema, $table, $field);
$rv = $dbh->last_insert_id($catalog, $schema, $table, $field, \%attr);
Attempts to return the id of the last value to be inserted into a table. You can either provide a sequence name (preferred) or provide a table name with optional schema. The $catalog and $field arguments are always ignored. The current value of the sequence is returned by a call to the CURRVAL() PostgreSQL function. This will fail if the sequence has not yet been used in the current database connection.
If you do not know the name of the sequence, you can provide a table name and DBD::Pg will attempt to return the correct value. To do this, there must be at least one column in the table with a NOT NULL constraint, that has a unique constraint, and which uses a sequence as a default value. If more than one column meets these conditions, the primary key will be used. This involves some looking up of things in the system table, so DBD::Pg will cache the sequence name for subsequent calls. If you need to disable this caching for some reason, (such as the sequence name changing), you can control it via the pg_cache attribute.
Please keep in mind that this method is far from foolproof, so make your script use it properly. Specifically, make sure that it is called immediately after the insert, and that the insert does not add a value to the column that is using the sequence as a default value.
Some examples:
$dbh->do("CREATE SEQUENCE lii_seq START 1");
$dbh->do("CREATE TABLE lii (
foobar INTEGER NOT NULL UNIQUE DEFAULT nextval('lii_seq'),
baz VARCHAR)");
$SQL = "INSERT INTO lii(baz) VALUES (?)";
$sth = $dbh->prepare($SQL);
for (qw(uno dos tres cuatro)) {
my $newid = $dbh->last_insert_id(C<undef>,undef,undef,undef,{sequence=>'lii_seq'});
print "Last insert id was $newid\n";
If you did not want to worry about the sequence name:
$dbh->do("CREATE TABLE lii2 (
foobar SERIAL UNIQUE,
baz VARCHAR)");
$SQL = "INSERT INTO lii2(baz) VALUES (?)";
$sth = $dbh->prepare($SQL);
for (qw(uno dos tres cuatro)) {
my $newid = $dbh->last_insert_id(undef,undef,"lii2",undef);
print "Last insert id was $newid\n";
$rc = $dbh->commit;
Supported by this driver as proposed by DBI. See also the notes about Transactions elsewhere in this document.
$rc = $dbh->rollback;
Supported by this driver as proposed by DBI. Note that this will not issue a "begin" until immediately before the next given command.
$rc = $dbh->disconnect;
$rc = $dbh->ping;
This driver supports the ping method, which can be used to check the validity of a database handle. The value returned is either 0, indicating that the connection is no longer valid, or a positive integer, indicating the following:
Value Meaning
1 Database is idle (not in a transaction)
2 Database is active, there is a command in progress (usually seen after a COPY command)
3 Database is idle within a transaction
4 Database is idle, within a failed transaction
Additional information on why a handle is not valid can be obtained by using the pg_ping method.
$rc = $dbh->pg_ping;
This is a DBD::Pg-specific extension to the ping command. This will check the validity of a database handle in exactly the same way as ping, but instead of returning a 0 for an invalid connection, it will return a negative number. So in addition to returning the positive numbers documented for ping, it may also return the following:
Value Meaning
-1 There is no connection to the database at all (e.g. after C<disconnect>)
-2 An unknown transaction status was returned (e.g. after forking)
-3 The handle exists, but no data was returned from a test query.
In practice, you should only ever see -1 and -2.
$value = $dbh->get_info($info_type);
Supports a very large set (> 250) of the information types, including the minimum recommended by DBI.
$sth = $dbh->table_info( $catalog, $schema, $table, $type );
Supported by this driver as proposed by DBI. This method returns all tables and views visible to the current user. The $catalog argument is currently unused. The schema and table arguments will do a LIKE search if a percent sign (%) or an underscore (_) is detected in the argument. The $type argument accepts a value of either "TABLE" or "VIEW" (using both is the default action).
The TABLE_CAT field will always return NULL (undef).
If your database supports tablespaces (version 8.0 or greater), two additional columns are returned, "pg_tablespace_name" and "pg_tablespace_location", that contain the name and location of the tablespace associated with this table. Tables that have not been assigned to a particular tablespace will return NULL (undef) for both of these columns.
Three additional fields are returned:
pg_schema - the unquoted name of the schema
pg_table - the unquoted name of the table
pg_column - the unquoted name of the column
$sth = $dbh->column_info( $catalog, $schema, $table, $column );
Supported by this driver as proposed by DBI with the follow exceptions. These fields are currently always returned with NULL (undef) values:
Also, five additional non-standard fields are returned:
pg_type - data type with additional info i.e. "character varying(20)"
pg_constraint - holds column constraint definition
pg_schema - the unquoted name of the schema
pg_table - the unquoted name of the table
pg_column - the unquoted name of the column
Note that the TABLE_SCHEM, TABLE_NAME, and COLUMN_NAME fields all return output wrapped in quote_ident(). If you need the unquoted version, use the pg_ fields above.
$sth = $dbh->primary_key_info( $catalog, $schema, $table, \%attr );
Supported by this driver as proposed by DBI. The $catalog argument is currently unused. There are no search patterns allowed, but leaving the $schema argument blank will cause the first table found in the schema search path to be used. An additional field, "DATA_TYPE", is returned and shows the data type for each of the arguments in the "COLUMN_NAME" field.
This method will also return tablespace information for servers that support tablespaces. See the table_info entry for more information.
The five additional custom fields returned are:
pg_tablespace_name - Name of the tablespace, if any
pg_tablespace_location - Location of the tablespace
pg_schema - the unquoted name of the schema
pg_table - the unquoted name of the table
pg_column - the unquoted name of the column
In addition to the standard format of returning one row for each column found for the primary key, you can pass the pg_onerow attribute to force a single row to be used. If the primary key has multiple columns, the "KEY_SEQ", "COLUMN_NAME", and "DATA_TYPE" fields will return a comma-delimited string. If the pg_onerow attribute is set to "2", the fields will be returned as an arrayref, which can be useful when multiple columns are involved:
$sth = $dbh->primary_key_info('', '', 'dbd_pg_test', {pg_onerow => 2});
if (defined $sth) {
my $pk = $sth->fetchall_arrayref()->[0];
print "Table $pk->[2] has a primary key on these columns:\n";
for (my $x=0; defined $pk->[3][$x]; $x++) {
print "Column: $pk->[3][$x] (data type: $pk->[6][$x])\n";
$sth = $dbh->foreign_key_info( $pk_catalog, $pk_schema, $pk_table,
$fk_catalog, $fk_schema, $fk_table );
Supported by this driver as proposed by DBI, using the SQL/CLI variant. There are no search patterns allowed, but leaving the $schema argument blank will cause the first table found in the schema search path to be used. Two additional fields, "UK_DATA_TYPE" and "FK_DATA_TYPE", are returned to show the data type for the unique and foreign key columns. Foreign keys that have no named constraint (where the referenced column only has an unique index) will return undef for the "UK_NAME" field.
@names = $dbh->tables( $catalog, $schema, $table, $type, \%attr );
Supported by this driver as proposed by DBI. This method returns all tables and/or views which are visible to the current user: see table_info() for more information about the arguments. The name of the schema appears before the table or view name. This can be turned off by adding in the pg_noprefix attribute:
my @tables = $dbh->tables( '', '', 'dbd_pg_test', '', {pg_noprefix => 1} );
$type_info_all = $dbh->type_info_all;
Supported by this driver as proposed by DBI. Information is only provided for SQL datatypes and for frequently used datatypes. The mapping between the PostgreSQL typename and the SQL92 datatype (if possible) has been done according to the following table:
| typname | SQL92 |
| bool | BOOL |
| text | / |
| bpchar | CHAR(n) |
| varchar | VARCHAR(n) |
| int2 | SMALLINT |
| int4 | INT |
| int8 | / |
| money | / |
| float4 | FLOAT(p) p<7=float4, p<16=float8 |
| float8 | REAL |
| abstime | / |
| reltime | / |
| tinterval | / |
| date | / |
| time | / |
| datetime | / |
| timespan | TINTERVAL |
| timestamp | TIMESTAMP |
For further details concerning the PostgreSQL specific datatypes please read pgbuiltin.
@type_info = $dbh->type_info($data_type);
$rv = $dbh->quote($value, $data_type);
This module implements its own quote method. In addition to the DBI method it also doubles the backslash, because PostgreSQL treats a backslash as an escape character. You may also quote arrayrefs and received a string suitable for passing into Postgres array columns.
NOTE: The undocumented (and invalid) support for the SQL_BINARY data type is officially deprecated. Use PG_BYTEA with bind_param() instead:
$rv = $sth->bind_param($param_num, $bind_value,
{ pg_type => PG_BYTEA });
Writes debugging information from the PostgreSQL backend to a file. This is not the same as the trace() method and you should not use this method unless you know what you are doing. If you do enable this, be aware that the file will grow very large, very quick. To stop logging to the file, use the pg_server_untrace function. The first argument must be a file handle, not a filename. Example:
my $pid = $dbh->{pg_pid};
my $file = "pgbackend.$pid.debug.log";
open(my $fh, ">$file") or die qq{Could not open "$file": $!\n};
## Run code you want to trace here
Stop server logging to a previously opened file.
Supported by this driver as proposed by DBI. According to the classification of DBI, PostgreSQL is a database in which a transaction must be explicitly started. Without starting a transaction, every change to the database becomes immediately permanent. The default of AutoCommit is on, but this may change in the future, so it is highly recommended that you explicitly set it when calling connect(). For details see the notes about Transactions elsewhere in this document.
PostgreSQL specific attribute. If true, boolean values will be returned as the characters 't' and 'f' instead of '1' and '0'.
The default DBI method is overridden by a driver specific method that returns only the database name. Anything else from the connection string is stripped off. Note that, in contrast to the DBI specs, the DBD::Pg implementation for this method is read-only.
Implemented by DBI, not used by this driver.
PostgreSQL specific attribute. If true, then quotes and backslashes in all parameters will be escaped in the following way:
escape quote with a quote (SQL)
escape backslash with a backslash
The default is on. Note that PostgreSQL also accepts quotes that are escaped by a backslash. Any other ASCII character can be used directly in a string constant.
PostgreSQL specific attribute. If true, then the utf8 flag will be turned for returned character data (if the data is valid UTF-8). For details about the utf8 flag, see Encode. This attribute is only relevant under perl 5.8 and later.
NB: This attribute is experimental and may be subject to change.
Constant to be used for the mode in lo_creat and lo_open.
PostgreSQL specific attribute. Sets the amount of information returned by the server's error messages. Valid entries are 0, 1, and 2. Any other number will be forced to the default value of 1.
A value of 0 ("TERSE") will show severity, primary text, and position only and will usually fit on a single line. A value of 1 ("DEFAULT") will also show any detail, hint, or context fields. A value of 2 ("VERBOSE") will show all available information.
PostgreSQL specific attribute. Returns the version of the PostgreSQL server. If DBD::Pg is unable to figure out the version, it will return a "0". Otherwise, a "3" is returned.
PostgreSQL specific attribute. Indicates which version of PostgreSQL that DBD::Pg was compiled against. In other words, which libraries were used. Returns a number with major, minor, and revision together; version 8.1.4 would be returned as 80104.
PostgreSQL specific attribute. Indicates which version of PostgreSQL that the current database handle is connected to. Returns a number with major, minor, and revision together; version 8.0.1 would be 80001.
PostgreSQL specific attribute. Returns the name of the current database.
PostgreSQL specific attribute. Returns the name of the user that connected to the server.
PostgreSQL specific attribute. Returns the password used to connect to the server.
PostgreSQL specific attribute. Returns the host of the current server connection. Locally connected hosts will return an empty string.
PostgreSQL specific attribute. Returns the port of the connection to the server.
PostgreSQL specific attribute. Returns the default port used if none is specifically given.
PostgreSQL specific attribute. Returns the command-line options passed to the server. May be an empty string.
PostgreSQL specific attribute. Returns the file description number of the connection socket to the server.
PostgreSQL specific attribute. Returns the process id (PID) of the backend server process handling the connection.
$rv = $sth->bind_param($param_num, $bind_value, \%attr);
Allows the user to bind a value and/or a data type to a placeholder. This is especially important when using server-side prepares. See the prepare() method for more information.
The value of $param_num is a number if using the '?' or '$1' style placeholders. If using ":foo" style placeholders, the complete name (e.g. ":foo") must be given. For numeric values, you can either use a number or use a literal '$1'. See the examples below.
The $bind_value argument is fairly self-explanatory. A value of undef will bind a NULL to the placeholder. Using undef is useful when you want to change just the type and will be overwriting the value later. (Any value is actually usable, but undef is easy and efficient).
The %attr hash is used to indicate the data type of the placeholder. The default value is "varchar". If you need something else, you must use one of the values provided by DBI or by DBD::Pg. To use a SQL value, modify your "use DBI" statement at the top of your script as follows:
use DBI qw(:sql_types);
This will import some constants into your script. You can plug those directly into the bind_param call. Some common ones that you will encounter are:
To use PostgreSQL data types, import the list of values like this:
use DBD::Pg qw(:pg_types);
You can then set the data types by setting the value of the pg_type key in the hash passed to bind_param. The current list of Postgres data types exported is:
Data types are "sticky," in that once a data type is set to a certain placeholder, it will remain for that placeholder, unless it is explicitly set to something else afterwards. If the statement has already been prepared, and you switch the data type to something else, DBD::Pg will re-prepare the statement for you before doing the next execute.
use DBI qw(:sql_types);
use DBD::Pg qw(:pg_types);
$SQL = "SELECT id FROM ptable WHERE size > ? AND title = ?";
$sth = $dbh->prepare($SQL);
## Both arguments below are bound to placeholders as "varchar"
$sth->execute(123, "Merk");
## Reset the datatype for the first placeholder to an integer
$sth->bind_param(1, undef, SQL_INTEGER);
## The "undef" bound above is not used, since we supply params to execute
$sth->execute(123, "Merk");
## Set the first placeholder's value and data type
$sth->bind_param(1, 234, { pg_type => PG_TIMESTAMP });
## Set the second placeholder's value and data type.
## We don't send a third argument, so the default "varchar" is used
$sth->bind_param('$2', "Zool");
## We realize that the wrong data type was set above, so we change it:
$sth->bind_param('$1', 234, { pg_type => SQL_INTEGER });
## We also got the wrong value, so we change that as well.
## Because the data type is sticky, we don't need to change it
$sth->bind_param(1, 567);
## This executes the statement with 567 (integer) and "Zool" (varchar)
Experimental support for this feature is provided. The first argument to bind_param_inout should be a placeholder number. The second argument should be a reference to a scalar variable in your script. The third argument is not used and should simply be set to 0. Note that what this really does is assign a returned column to the variable, in the order in which the column appears. For example:
my $foo = 123;
$sth = $dbh->prepare("SELECT 1+?::int");
$sth->bind_param_inout(1, \$foo, 0);
$foo = 222;
The above will cause $foo to have a new value of "223" after the final fetch. Note that the variables bound in this manner are very sticky, and will trump any values passed in to execute. This is because the binding is done as late as possible, at the execute() stage, allowing the value to be changed between the time it was bound and the time the query is executed. Thus, the above execute is the same as:
$rv = $sth->execute(@bind_values);
Executes a previously prepared statement. In addition to UPDATE, DELETE, INSERT statements, for which it returns always the number of affected rows, the execute method can also be used for SELECT ... INTO table statements.
SELECT ... INTO table
The "prepare/bind/execute" process has changed significantly for PostgreSQL servers 7.4 and later: please see the prepare() and bind_param() entries for much more information.
Setting one of the bind_values to "undef" is the equivalent of setting the value to NULL in the database. Setting the bind_value to $DBDPG_DEFAULT is equivalent to sending the literal string 'DEFAULT' to the backend. Note that using this option will force server-side prepares off until such time as PostgreSQL supports using DEFAULT in prepared statements.
DBD::Pg also supports passing in arrays to execute: simply pass in an arrayref, and DBD::Pg will flatten it into a string suitable for input on the backend.
$ary_ref = $sth->fetchrow_arrayref;
@ary = $sth->fetchrow_array;
$hash_ref = $sth->fetchrow_hashref;
$tbl_ary_ref = $sth->fetchall_arrayref;
$rc = $sth->finish;
$rv = $sth->rows;
Supported by this driver as proposed by DBI. In contrast to many other drivers the number of rows is available immediately after executing the statement.
$rc = $sth->bind_col($column_number, \$var_to_bind, \%attr);
$rc = $sth->bind_columns(\%attr, @list_of_refs_to_vars_to_bind);
$rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh);
$blob = $sth->blob_read($id, $offset, $len);
Supported by this driver as proposed by DBI. Implemented by DBI but not documented, so this method might change.
This method seems to be heavily influenced by the current implementation of blobs in Oracle. Nevertheless we try to be as compatible as possible. Whereas Oracle suffers from the limitation that blobs are related to tables and every table can have only one blob (datatype LONG), PostgreSQL handles its blobs independent of any table by using so-called object identifiers. This explains why the blob_read method is blessed into the STATEMENT package and not part of the DATABASE package. Here the field parameter has been used to handle this object identifier. The offset and len parameters may be set to zero, in which case the driver fetches the whole blob at once.
Starting with PostgreSQL 6.5, every access to a blob has to be put into a transaction. This holds even for a read-only access.
See also the PostgreSQL-specific functions concerning blobs, which are available via the func interface.
For further information and examples about blobs, please read the chapter about Large Objects in the PostgreSQL Programmer's Guide at http://www.postgresql.org/docs/current/static/largeobjects.html.
Supported by this driver as proposed by DBI
Supported by this driver. NUMERIC types will return the precision. Types of CHAR and VARCHAR will return their size (number of characters). Other types will return the number of bytes.
Supported by this driver as proposed by DBI. The only type that will return a value currently is NUMERIC.
Not supported by this driver. See the note about Cursors elsewhere in this document.
Supported by this driver as proposed by DBI. If called before execute, the literal values passed in are returned. If called after execute, then the quoted versions of the values are shown.
Returns a hash of all current placeholders. The keys are the names of the placeholders, and the values are the types that have been bound to each one. Placeholders that have not yet been bound will return undef as the value.
Not supported by this driver.
PostgreSQL specific attribute. It returns a reference to an array of integer values for each column. The integer shows the size of the column in bytes. Variable length columns are indicated by -1.
PostgreSQL specific attribute. It returns a reference to an array of strings for each column. The string shows the name of the data_type.
PostgreSQL specific attribute. It returns the OID of the last INSERT command.
PostgreSQL specific attribute. It returns the type of the last command. Possible types are: "INSERT", "DELETE", "UPDATE", "SELECT".
Transaction behavior is controlled via the AutoCommit attribute. For a complete definition of AutoCommit please refer to the DBI documentation.
According to the DBI specification the default for AutoCommit is a true value. In this mode, any change to the database becomes valid immediately. Any BEGIN, COMMIT or ROLLBACK statements will be rejected. DBD::Pg implements AutoCommit by issuing a BEGIN statement immediately before executing a statement, and a COMMIT afterwards.
PostgreSQL version 8.0 introduced the concept of savepoints, which allows transactions to be rolled back to a certain point without affecting the rest of the transaction. DBD::Pg encourages using the following methods to control savepoints:
Creates a savepoint. This will fail unless you are inside of a transaction. The only argument is the name of the savepoint. Note that PostgreSQL DOES allow multiple savepoints with the same name to exist.
Rolls the database back to a named savepoint, discarding any work performed after that point. If more than one savepoint with that name exists, rolls back to the most recently created one.
Releases (or removes) a named savepoint. If more than one savepoint with that name exists, it will only destroy the most recently created one. Note that all savepoints created after the one being released are also destroyed.
It is possible to send a query to the backend and have your script do other work while the query is running on the backend. Both queries sent by the do() method, and by the execute() method can be sent asynchronously. (NOTE: This will only work if DBD::Pg has been compiled against Postgres libraries of version 8.0 or greater) The basic usage is as follows:
use DBD::Pg ':async';
print "Async do() example:\n";
$dbh->do("SELECT long_running_query()", {pg_async => PG_ASYNC});
if ($dbh->pg_ready()) {
$res = $pg_result();
print "Result of do(): $res\n";
print "Query is still running...\n";
if (cancel_request_received) {
sleep 1;
print "Async prepare/execute example:\n";
$sth = $dbh->prepare("SELECT long_running_query(1)", {pg_async => PG_ASYNC});
## Changed our mind, cancel and run again:
$sth = $dbh->prepare("SELECT 678", {pg_async => PG_ASYNC + PG_OLDQUERY_CANCEL});
if (!$sth->pg_ready) {
## We wait until it is done, and get the result:
$res = $dbh->pg_result();
There are currently three asynchronous constants exported by DBD::Pg. You can import all of them by putting either of these at the top of your script:
use DBD::Pg;
use DBD::Pg ':async';
You may also use the numbers instead of the constants, but using the constants is recommended as it makes your script more readable.
This is a constant for the number 1. It is passed to either the do() or the prepare() method as a value to the pg_async key and indicates that the query should be sent asynchronously.
This is a constant for the number 2. When passed to either the do() or the prepare method(), it causes any currently running asynchronous query to be cancelled and rolled back. It has no effect if no asynchronous query is currently running.
This is a constant for the number 4. When passed to either the do() or the prepare method(), it waits for any currently running asynchronous query to complete. It has no effect if there is no asynchronous query currently running.
This database-level method attempts to cancel any currently running asynchronous query. It returns true if the cancel succeeded, and false otherwise. Note that a query that has finished before this method is executed will also return false. WARNING: a successful cancellation will leave the database in an unusable state, so DBD::Pg will automatically clear out the error message and issue a ROLLBACK.
$result = $dbh->pg_cancel();
This method can be called as a database handle method or (for convenience) as a statement handle method. Both simply see if a previously issued asynchronous query has completed yet. It returns true if the statement has finished, in which case you should then call the pg_result() method. Calls to pg_ready() should only be used when you have other things to do while the query is running. If you simply want to wait until the query is done, do not call pg_ready() over and over, but simply call the pg_result() method.
my $time = 0;
while (!$dbh->pg_ready) {
print "Query is still running. Seconds: $time\n";
sleep 1;
$result = $dbh->pg_result;
This database handle method returns the results of a previously issued asynchronous query. If the query is still running, this method will wait until it has finished. The result returned is the number of rows: the same thing that would have been returned by the asynchronous do() or execute() if it had been called without an asynchronous flag.
$result = $dbh->pg_result;
Here are some working examples of asynchronous queries. Note that we'll use the pg_sleep function to emulate a long-running query.
use strict;
use warnings;
use Time::HiRes 'sleep';
use DBD::Pg ':async';
my $dbh = DBI->connect('dbi:Pg:dbname=postgres', 'postgres', '', {AutoCommit=>0,RaiseError=>1});
## Kick off a long running query on the first database:
my $sth = $dbh->prepare("SELECT pg_sleep(?)", {pg_async => PG_ASYNC});
## While that is running, do some other things
print "Your query is processing. Thanks for waiting\n";
check_on_the_kids(); ## Expensive sub, takes at least three seconds.
while (!$dbh->pg_ready) {
## If the above function returns quickly for some reason, we add a small sleep
sleep 0.1;
print "The query has finished. Gathering results\n";
my $result = $sth->pg_result;
print "Result: $result\n";
my $info = $sth->fetchall_arrayref();
Without asynchronous queries, the above script would take about 8 seconds to run: five seconds waiting for the execute to finish, then three for the check_on_the_kids() function to return. With asynchronous queries, the script takes about 6 seconds to run, and gets in two iterations of check_on_the_kids in the process.
Here's an example showing the ability to cancel a long-running query. Imagine two slave databases in different geographic locations over a slow network. You need information as quickly as possible, so you query both at once. When you get an answer, you tell the other one to stop working on your query, as you don't need it anymore.
use strict;
use warnings;
use Time::HiRes 'sleep';
use DBD::Pg ':async';
my $dbhslave1 = DBI->connect('dbi:Pg:dbname=postgres;host=slave1', 'postgres', '', {AutoCommit=>0,RaiseError=>1});
my $dbhslave2 = DBI->connect('dbi:Pg:dbname=postgres;host=slave2', 'postgres', '', {AutoCommit=>0,RaiseError=>1});
$SQL = "SELECT count(*) FROM largetable WHERE flavor='blueberry'";
my $sth1 = $dbhslave1->prepare($SQL, {pg_async => PG_ASYNC});
my $sth2 = $dbhslave2->prepare($SQL, {pg_async => PG_ASYNC});
my $winner;
while (!defined $winner) {
if ($sth1->pg_ready) {
$winner = 1;
elsif ($sth2->pg_ready) {
$winner = 2;
Time::HiRes::sleep 0.05;
my $count;
if ($winner == 1) {
$count = $sth1->fetchall_arrayref()->[0][0];
else {
$count = $sth2->fetchall_arrayref()->[0][0];
DBD::Pg allows arrays (as arrayrefs) to be passed in to both the quote() and the execute() functions. In both cases, the array is flattened into a string representing a Postgres array.
When fetching rows from a table that contains a column with an array type, the result will be passed back to your script as an arrayref.
To turn off the automatic parsing of returned arrays into arrayrefs, you can set the variable "pg_expand_array", which is true by default.
$dbh->{pg_expand_array} = 0;
DBD::Pg allows for the quick (bulk) reading and storing of data by using the COPY command. The basic process is to use $dbh->do to issue a COPY command, and then to either add rows using pg_putcopydata, or to read them by using pg_getcopydata.
The first step is to put the server into "COPY" mode. This is done by sending a complete COPY command to the server, by using the do() method. For example:
$dbh->do("COPY foobar FROM STDIN");
This would tell the server to enter a COPY OUT state. It is now ready to receive information via the pg_putcopydata method. The complete syntax of the COPY command is more complex and not documented here: the canonical PostgreSQL documentation for COPY can be found at:
Once the COPY command has been issued, no other SQL commands are allowed until pg_putcopyend() has been issued, or the final pg_getcopydata has been called.
Note: All other COPY methods (pg_putline, pg_getline, etc.) are now deprecated in favor of the pg_getcopydata, pg_putcopydata, and pg_putcopyend methods.
Used to retrieve data from a table after the server has been put into COPY OUT mode by calling "COPY tablename TO STDOUT". The first argument to pg_getcopydata is the variable into which the data will be stored (this variable should not be undefined, or it may throw a warning, although it may be a reference). This argument returns a number greater than 1 indicating the new size of the variable, or a -1 when the COPY has finished. Once a -1 has been returned, no other action is necessary, as COPY mode will have already terminated. Example:
$dbh->do("COPY mytable TO STDOUT");
my @data;
my $x=0;
1 while $dbh->pg_getcopydata($data[$x++]) > 0;
There is also a variation of this function called pg_getcopydata_async, which, as the name suggests, returns immediately. The only difference from the original function is that this version may return a 0, indicating that the row is not ready to be delivered yet. When this happens, the variable has not been changed, and you will need to call the function again until you get a non-zero result.
Used to put data into a table after the server has been put into COPY IN mode by calling "COPY tablename FROM STDIN". The only argument is the data you want inserted. Issue a pg_putcopyend() when you have added all your rows.
The default delimiter is a tab character, but this can be changed in the COPY statement. Returns a 1 on successful input. Examples:
## Simple example:
$dbh->do("COPY mytable FROM STDIN");
## This example uses explicit columns and a custom delimiter
$dbh->do("COPY mytable(flavor, slices) FROM STDIN WITH DELIMITER '~'");
When you are finished with pg_putcopydata, call pg_putcopyend to let the server know that you are done, and it will return to a normal, non-COPY state. Returns a 1 on success. This method will fail if called when not in a COPY IN or COPY OUT state.
This driver supports all largeobject functions provided by libpq via the func method. Please note that, starting with PostgreSQL 6.5, any access to a large object -- even read-only large objects -- must be put into a transaction!
Although PostgreSQL supports cursors, they have not been used in the current implementation. When DBD::Pg was defined, cursors in PostgreSQL could only be used inside a transaction block. Because only one transaction block at a time is allowed, this would have implied the restriction not to use any nested SELECT statements. Therefore the execute method fetches all data at once into data structures located in the front-end application. This fact must to be considered when selecting large amounts of data!
You can use cursors in your application, but you'll need to do a little work. First you must declare your cursor. Now you can issue queries against the cursor, then select against your queries. This typically results in a double loop, like this:
# WITH HOLD is not needed if AutoCommit is off
$dbh->do("DECLARE csr CURSOR WITH HOLD FOR $sql");
while (1) {
my $sth = $dbh->prepare("fetch 1000 from csr");
last if 0 == $sth->rows;
while (my $row = $sth->fetchrow_hashref) {
# Do something with the data.
$dbh->do("CLOSE csr");
The current implementation of PostgreSQL returns 't' for true and 'f' for false. From the Perl point of view, this is a rather unfortunate choice. DBD::Pg therefore translates the result for the BOOL data type in a Perlish manner: 'f' -> '0' and 't' -> '1'. This way the application does not have to check the database-specific returned values for the data-type BOOL because Perl treats '0' as false and '1' as true. You may set the pg_bool_tf attribute to a true value to change the values back to 't' and 'f' if you wish.
Boolean values can be passed to PostgreSQL as TRUE, 't', 'true', 'y', 'yes' or '1' for true and FALSE, 'f', 'false', 'n', 'no' or '0' for false.
PostgreSQL version 7.3 introduced schema support. Note that the PostgreSQL schema concept may differ from those of other databases. In a nutshell, a schema is a named collection of objects within a single database. Please refer to the PostgreSQL documentation for more details.
Currently, DBD::Pg does not provide explicit support for PostgreSQL schemas. However, schema functionality may be used without any restrictions by explicitly addressing schema objects, e.g.
my $res = $dbh->selectall_arrayref("SELECT * FROM my_schema.my_table");
or by manipulating the schema search path with SET search_path, e.g.
SET search_path
$dbh->do("SET search_path TO my_schema, public");
Quoting will not work properly if standard_conforming_strings is set to 'on', so it is recommended that this be set to 'off' until full support for it can be built into DBD::Pg.
DBI and DBD-Oracle by Tim Bunce (firstname.lastname@example.com)
DBD-Pg by Edmund Mergl (email@example.com) and Jeffrey W. Baker (email@example.com). By David Wheeler <firstname.lastname@example.com>, Jason Stewart <firstname.lastname@example.com>, Bruce Momjian <firstname.lastname@example.com>, Greg Sabino Mullane <email@example.com>, and others after v1.13.
Parts of this package have been copied from DBI and DBD-Oracle.
Mailing List
The current maintainers may be reached through the 'dbd-pg' mailing list: <firstname.lastname@example.com>
Bug Reports
If you feel certain you have found a bug, you can report it by sending an email to <firstname.lastname@example.com>.
The DBD::Pg module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
See also DBI/ACKNOWLEDGMENTS.
To install DBD::Pg, copy and paste the appropriate command in to your terminal.
cpanm DBD::Pg
CPAN shell
perl -MCPAN -e shell
install DBD::Pg
For more information on module installation, please visit the detailed CPAN module installation guide.


text:
UNESCO is right on that train of thought and has recently published an extensive report entitled: Teaching and learning: achieving quality for all. I must admit I like the addition of 'quality' to the 'education for all' concept. The report is available in two formats: a 50 page summary (available in English | French | Spanish | Arabic | Russian |Chinese | Hindi | Portuguese) highlighting findings and strategies, and the full report (just under 500 pages as an English Full Report | French | Spanish (pdf.s)) for all that really want to dig in the details.
The report is divided into three parts. Part 1 provides an update of progress towards the six EFA goals. The second part presents clear evidence that progress in education is vital for achieving development goals after 2015. Part 3 puts the spotlight on the importance of implementing strong policies to unlock the potential of teachers so as to support them in overcoming the global learning crisis.
The report summary highlights some urgent goals that need to be obtained and reading the shortlist certainly got me thinking:
- Goal 1: Despite improvements, far too many children lack early childhood care and education. In 2012, 25% of children under 5 suffered from stunting. In 2011, around half of young children had access to pre-primary education, and in sub-Saharan Africa the share was only 18%.
- Goal 2: Universal primary education is likely to be missed by a wide margin. The number of children out of school was 57 million in 2011, half of whom lived in conflict-affected countries. In sub-Saharan Africa, only 23% of poor girls in rural areas were completing primary education by the end of the decade. If recent trends in the region continue, the richest boys will achieve universal primary completion in 2021, but the poorest girls will not catch up until 2086.
- Goal 3: Many adolescents lack foundation skills gained through lower secondary education. In 2011, 69 million adolescents were out of school, with little improvement in this number since 2004. In low income countries, only 37% of adolescents complete lower secondary education, and the rate is as low as 14% for the poorest. On recent trends, girls from the poorest families in sub-Saharan Africa are only expected to achieve lower secondary completion in 2111.
- Goal 4: Adult literacy has hardly improved. In 2011, there were 774 million illiterate adults, a decline of just 1% since 2000. The number is projected to fall only slightly, to 743 million, by 2015. Almost two-thirds of illiterate adults are women. The poorest young women in developing countries may not achieve universal literacy until 2072.
- Goal 5: Gender disparities remain in many countries. Even though gender parity was supposed to be achieved by 2005, in 2011 only 60% of countries had achieved this goal at the primary level and 38% at the secondary level.
- Goal 6: Poor quality of education means millions of children are not learning the basics. Around 250 million children are not learning basic skills, even though half of them have spent at least four years in school. The annual cost of this failure, around US$129 billion. Investing in teachers is key: in around a third of countries, less than 75% of primary school teachers are trained according to national standards. And in a third of countries, the challenge of training existing teachers is worse than that of recruiting and training new teachers.
The one fact that strikes me the most is the lack of progress in adult literacy. It is all good and well to advocate free online courses, but if literacy is not reached, no matter what type of content we put out there it will not engage all learners (unless we make it non-textual and available in local languages, which would be a real bonus for all). And literacy efforts demand intense teacher and learner efforts as well (time, money restraints).


text:
Tuesday, June 5, 2012
1983 - Anatomy of a cover - Avengers #233
2 comments:
First of all, first time commenter. I just discovered your blog like two weeks ago, and I went back and read the entire archive. Awesome site.ReplyDelete
Second of all, there's always a lot of talk here about how awesome the inks are, and how bad color sometimes makes stuff. Well, this is a great one for color - the inks are too heavy without the color, creating a looks-like-Thing's-torso sort of vibe, not to mention the huge blank spot in the lower left. The colors really make a world of difference here, from a mostly unintelligible picture, to a sensible picture.
Hey David. Welcome and thanks for the kind words about my blog!ReplyDelete
Good point about the inks. Sinnott's inking is quiet heavy on this cover and the rocks in the background almost seem to seep out and overpower. The yellow of the rocks in the coloured version seems to dull this effect.


text:
Path: Home Page
Login is not possible.
Your browser probably does not support cookies enabled. They turn out according to the instruction manual of your Internet browser. Then try to login again..
Mode No graphics is currently switched on. Therefore you see the web page with no decorative graphics as well as any advanced formatting. If your browser supports CSS2, you can switch a graphic mode on.


text:
The beloved American classic about a young girl's coming-of-age at the turn of the century, Betty Smith's A Tree Grows in Brooklyn is a poignant and moving tale filled with compassion and cruelty, laughter and heartache, crowded with life and people and incident. The story of young, sensitive, and idealistic Francie Nolan and her bittersweet formative years in the slums of Williamsburg has enchanted and inspired millions of readers for more than sixty years. By turns overwhelming, sublime, heartbreaking, and uplifting, the daily experiences of the unforgettable Nolans are raw with honesty and tenderly threaded with family connectedness -- in a work of literary art that brilliantly captures a unique time and place as well as incredibly rich moments of universal experience.
Purchase A Tree Grows in Brooklyn
Buy from Amazon
Buy from IndieBound
Buy from Ebay
Author: Betty Smith
Price: $12.41 *Individual store prices may vary.
Publisher: HarperCollins Publishers
Year of Publication: 1943
Genre: Fiction, Literature,
Subgenre: Classics, Historical Fiction, Young Adult,
Date Read: Apr 10, 2005
My Rating:
Purchase A Tree Grows in Brooklyn
Buy from Amazon
Buy from IndieBound
Buy from Ebay