+ "Usage: \n $0\n\t-H hostname\n\t[ -D database ]\n\t-U user\n\t-P password\n\t[ -c cdrtypenum ]\n\t[ -L num_cdrs_limit ]\n\t[ -T table ]\n\t[ -S status table ]\n\tfreesideuser\n";
+}
+
+sub get_queries {
+ #my ($dbd, $host, $table, $column, $column_create_info, $status_table, $primary_key, $primary_key_info) = @_;
+ my $info = shift;
+
+ #get host and port information.
+ my ($host, $port) = split /:/, $info->{host};
+ $host ||= 'localhost';
+ $port ||= '5000'; # check for pg default 5000 is sybase.
+
+ my %dbi_connect_types = (
+ 'Sybase' => ':server='.$host.';port='.$port,
+ 'Pg' => ':host='.$info->{host},
+ );
+
+ #Check for freeside status table
+ my %dbi_check_statustable = (
+ 'Sybase' => "SELECT * FROM sysobjects WHERE name = '$info->{status_table}'",
+ 'Pg' => "SELECT * FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '$info->{status_table}' AND column_name = '$info->{status_column}'",
+ );
+
+ #Create freeside status table
+ my %dbi_create_statustable = (
+ 'Sybase' => "CREATE TABLE $info->{status_table} ( $info->{primary_key} $info->{primary_key_info}, $info->{status_column} $info->{status_column_info} )",
+ 'Pg' => "CREATE TABLE $info->{status_table} ( $info->{primary_key} $info->{primary_key_info}, $info->{status_column} $info->{status_column_info} )",
+ );
+
+ #Check for freeside status column
+ my %dbi_check_statuscolumn = (
+ 'Sybase' => "SELECT syscolumns.name FROM sysobjects
+ JOIN syscolumns ON sysobjects.id = syscolumns.id
+ WHERE sysobjects.name LIKE '$info->{table}' AND syscolumns.name = '$info->{status_column}'",
+ 'Pg' => "SELECT * FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '$info->{table}' AND column_name = '$info->{status_column}' ",
+ );
+
+ #Create freeside status column
+ my %dbi_create_statuscolumn = (
+ 'Sybase' => "ALTER TABLE $info->{table} ADD $info->{status_column} $info->{status_column_info} NULL",
+ 'Pg' => "ALTER TABLE $info->{table} ADD COLUMN $info->{status_column} $info->{status_column_info}",
+ );
+
+ my $queries = {
+ 'connect_type' => $dbi_connect_types{$info->{dbd}},
+ 'check_statustable' => $dbi_check_statustable{$info->{dbd}},
+ 'create_statustable' => $dbi_create_statustable{$info->{dbd}},
+ 'check_statuscolumn' => $dbi_check_statuscolumn{$info->{dbd}},
+ 'create_statuscolumn' => $dbi_create_statuscolumn{$info->{dbd}},
+ };
+
+ return $queries;