Listing of db/insert.pl


#!/usr/bin/perl -w
#
# Make a SQL INSERT to MySQL database
#
# Tested with WinXP and perl, v5.8.0 built for MSWin32-x86-multi-thread
# Binary build 806 provided by ActiveState Corp. http://www.ActiveState.com
# Built 00:45:44 Mar 31 2003
#
# ------------------------------
# Installing MySQL API into perl:
# (The interface requires Perl Version 5.6.0 or later)
# ppm> install DBI
# ppm> install DBD-MySQL
# ------------------------------
# Change History:
# 2004-11-22 jje - SQL script created for MySQL 4.0
# 2005-03-30 jje - Adapted for MySQL 4.1.1 and above (renamed columns UTC_TIME and UTC_DATE into UTCTIME and UTCDATE)

require 5.008;
use strict;
use DBI;

  my $data_source = "dbi:mysql:gsmtrack";
  my $user = "root";
  my $password = shift || ""; # you may give password at the command line
  my $dbh = DBI->connect($data_source, $user, $password)
      or die "Can't connect to $data_source: $DBI::errstr";

# If you get the following error with MySQL 4.1.1 or newer
# 
#   DBI connect('gsmtrack','root',...) failed: Client does not support authenticatio
#   n protocol requested by server; consider upgrading MySQL client ...
#
# Reset the root password to pre-4.1 style as follows: 
#   mysql>  SET PASSWORD = OLD_PASSWORD('newpwd');
#
# (See http://dev.mysql.com/doc/mysql/en/old-client.html)

  my $sql_stmt;
  $sql_stmt = q{
            INSERT INTO GPS (PHONE,STATUS,LATITUDE,LONGITUDE,SPEED_KNOTS,COURSE_DEG,UTCTIME,UTCDATE,LABEL)
            VALUES (?,?,?,?,?,?,?,?,?)
  };
  my $sth = $dbh->prepare( $sql_stmt ) or die "Can't prepare statement: $DBI::errstr";

  my $rc = $sth->execute( "123456789012345", "A", 60.1505966666667, 24.888705, 0.0, 0.0, 
        "144858.159", "191104", "Aspicore Ltd"  )
      or die "Can't execute statement: $DBI::errstr";

  # $dbh->commit;        # To commit your changes to the database (when AutoCommit is off)
  $dbh->disconnect;

exit;

This file was generated by Gabriel Knoy's perl2html script.