## Table of Contents

clock_to_precise_sql_time
clock_to_sql_time
gen_sql_insert_from_array
perform_sql_insert_from_array
quote_sql
sql_time_to_clock

[next] [TOC]

## Command

clock_to_precise_sql_time

### Synopsis

clock_to_precise_sql_time clock

### Description

        return [fmtclock $clock "%b %d %H:%M:%S %Y GMT"]

[next] [prev] [TOC]

## Command

clock_to_sql_time

### Synopsis

clock_to_sql_time clock

### Description

    #
    # convert a clock value (integer seconds since 1970) to a sql standard
    # abstime value.
    #
    #        Month  Day [ Hour : Minute : Second ]  Year [ Timezone ]
    #

        return [fmtclock $clock "%b %d %Y"]

[next] [prev] [TOC]

## Command

gen_sql_insert_from_array

### Synopsis

gen_sql_insert_from_array tableName arrayName

### Description

    #
    # generate a sql insert command based on contents of an array
    #

        upvar $arrayName array

        set nameList [array names array]

        set result "insert into $tableName ([join $nameList ","]) values ("

        foreach name $nameList {
    	append result "[quote_sql $array($name)],"
        }
        return "[crange $result 0 end-1]);"

[next] [prev] [TOC]

## Command

perform_sql_insert_from_array

### Synopsis

perform_sql_insert_from_array session tableName arrayName

### Description

    #
    # generate a sql insert command based on contents of an array and
    # send it to the database
    #

        upvar $arrayName array
        set result [pg_exec $session [gen_sql_insert_from_array $tableName array]]
        set status [pg_result $result -status]
        pg_result $result -clear
        return $status

[next] [prev] [TOC]

## Command

quote_sql

### Synopsis

quote_sql string

### Description

    #@package: postgres-basic quote_sql gen_sql_insert_from_array perform_sql_insert_from_array clock_to_sql_time clock_to_precise_sql_time sql_time_to_clock
    #
    # Copyright (C) 1996 NeoSoft.
    #
    # Permission to use, copy, modify, and distribute this software and its
    # documentation for any purpose and without fee is hereby granted, provided
    # that the above copyright notice appear in all copies.  NeoSoft makes no
    # representations about the suitability of this software for any purpose.
    # It is provided "as is" without express or implied warranty.
    #
    # postgres95 interface stuff
    #
    # $Id: postgres95.html,v 1.1.1.1 1999/03/31 20:34:36 damon Exp $
    #
    #
    # make string mostly legally quoted for postgres95
    #

        set string [join [split $string "\n"] "\\n"]
        regsub -all "(')" $string "\\'" string
        regsub -all {(\\)} $string "\\\\" string
        return '$string'

[prev] [TOC]

## Command

sql_time_to_clock

### Synopsis

sql_time_to_clock date

### Description

    #
    # convert a sql standard abstime value to a clock value (integer
    # seconds since 1970)
    #

        if {$date == ""} {
    	return 0
        }
        return [convertclock $date]