Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




pg_select

pg_select

Name

pg_select — loop over the result of a SELECT statement
pg_select dbHandle queryString
  arrayVar queryProcedure

Inputs

dbHandle

Specifies a valid database handle.

queryString

Specifies a valid SQL select query.

arrayVar

Array variable for tuples returned.

queryProcedure

Procedure run on each tuple found.

Outputs

resultHandle

the return result is either an error message or a handle for a query result.

Description

pg_select submits a SELECT query to the Postgres backend, and executes a given chunk of code for each tuple in the result. The queryString must be a SELECT statement. Anything else returns an error. The arrayVar variable is an array name used in the loop. For each tuple, arrayVar is filled in with the tuple field values, using the field names as the array indexes. Then the queryProcedure is executed.

Usage

This would work if table "table" has fields "control" and "name" (and, perhaps, other fields):

	pg_select $pgconn "SELECT * from table" array {
		puts [format "%5d %s" array(control) array(name)]
	}



With any suggestions or questions please feel free to contact us