Difference between revisions of "Conf/Examples/DatabseExampleOneRow"

From AOLserver Wiki
Jump to navigation Jump to search
(Created page with ' part of AOL Database Configuration with PostgreSQL <html> <head><title>Testing of Database connection</title></head> <body> A simple…')
 
Line 16: Line 16:
 
   </body>
 
   </body>
 
   </html>
 
   </html>
 +
 +
------
 +
 +
'''Note'''
 +
 +
This command(ns_db 1row) expects the SQL to be a select statement that returns exactly one row and returns that row as an ns_set. An error is returned if zero or more than one row is returned.

Revision as of 12:18, 12 January 2012

part of AOL Database Configuration with PostgreSQL

<html>
   <head><title>Testing of Database connection</title></head>
 <body>  
 A simple tcl script example of Database Configuration
 <% 
  set pool "postgres_pool"
  set sql "select * from users"    
  set db [ns_db gethandle $pool]
  
  set rec [ns_db 1row $db $sql]
  ns_puts [ns_set array $rec]
  ns_db releasehandle $db
 %>
 </body>
 </html>

Note

This command(ns_db 1row) expects the SQL to be a select statement that returns exactly one row and returns that row as an ns_set. An error is returned if zero or more than one row is returned.