#!/usr/bin/perl use strict; use warnings; $|=1; #turn STDIO buffering off use Data::Dump qw(pp); use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=:memory:","","",{RaiseError => 1}) or die "Couldn't connect to database: " . DBI->errstr; $dbh->do ("CREATE TABLE ScoreCard ( id INTEGER PRIMARY KEY AUTOINCREMENT, Score INTEGER DEFAULT 11, My_Info VARCHAR DEFAULT '' ); "); my $insert_row = $dbh->prepare("INSERT INTO ScoreCard(Score) VALUES(?)"); # desired goal: get Score in the DB to be 11 if its not specified. $insert_row->execute(); #row 1 Score=undef $insert_row->execute(undef); #row 2 Score=undef $insert_row->execute(''); #row 3 Score=null string $insert_row->execute(333); #row 4 Score=333 my $get_all_rows = $dbh->prepare("SELECT * FROM ScoreCard"); $get_all_rows->execute(); my $aref = $get_all_rows->fetchall_arrayref; print "all rows="; pp $aref; __END__ all rows=[ [1, undef, ""], [2, undef, ""], [3, "", ""], [4, 333, ""], ]