proc db_name {} { return "oracle" } proc db_postgres {} { return "" } proc db_oracle {} { return "oracle" } proc db_sysdate {} { return "sysdate" } proc db_resultrows {db} { return [ns_ora resultrows $db] } proc db_sequence_nextval_sql {sequence_name} { return "${sequence_name}.nextval" } proc db_sequence_nextval {db sequence_name} { return [database_to_tcl_string $db "select [db_sequence_nextval_sql $sequence_name] from dual"] } # This performs some simple operations on the SQL # statement to convert it to the proper SQL syntax. # Useful mostly for automatic DB porting of simple things. proc db_sql_prep {sql} { # Take care of sequences # regsub -all "(\[^ \]*)\\.nextval" $sql "nextval('\\1')" sql # Take care of sysdate calls # regsub -all "sysdate(\[^\(_\])" $sql "sysdate\(\)\\1" sql return $sql } ## Recreate the ns_table command for now # proc ns_table3 {command db data} { # if {$command == "exists"} { # # MAJOR HACK CHANGE THIS SOON # # TODO: ben@adida.net # return 1 # } # } # Nulls proc db_null_sql {str} { return [db_postgres_null_sql $str] } proc db_postgres_null_sql {str} { if {$str == ""} { return "NULL" } else { return "'$str'" } } # Nulls proc db_postgres_doubleapos_null_sql {str} { if {$str == ""} { return "NULL" } else { return "'[DoubleApos $str]'" } }