diff options
Diffstat (limited to 'lib/sisu/v0/db_remove.rb')
-rw-r--r-- | lib/sisu/v0/db_remove.rb | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/lib/sisu/v0/db_remove.rb b/lib/sisu/v0/db_remove.rb index 63d69b64..bb88af58 100644 --- a/lib/sisu/v0/db_remove.rb +++ b/lib/sisu/v0/db_remove.rb @@ -61,8 +61,8 @@ =end module SiSU_DB_remove class Remove - def initialize(opt,conn='' ) - @opt,@conn=opt,conn + def initialize(opt,conn,file) + @opt,@conn,@file=opt,conn,file @md=SiSU_Param::Parameters.new(@opt).get @fnb=@md.fnb @db=SiSU_Env::Info_db.new @@ -72,23 +72,18 @@ module SiSU_DB_remove if del del_id=del.join #@conn.execute("BEGIN") - @conn.execute(%{ - DELETE FROM endnotes WHERE metadata_tid = '#{del_id}'; - DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}'; - DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}'; - DELETE FROM documents WHERE metadata_tid = '#{del_id}'; - DELETE FROM urls WHERE metadata_tid = '#{del_id}'; - DELETE FROM metadata WHERE tid = '#{del_id}'; - /* - DELETE FROM documents WHERE documents.metadata_tid = '#{del_id}'; - DELETE FROM endnotes WHERE endnotes.metadata_tid = '#{del_id}'; - DELETE FROM endnotes_asterisk WHERE endnotes_asterisk.metadata_tid = '#{del_id}'; - DELETE FROM endnotes_plus WHERE endnotes_plus.metadata_tid = '#{del_id}'; - DELETE FROM urls WHERE urls.metadata_tid = '#{del_id}'; - DELETE FROM metadata WHERE metadata.tid = '#{del_id}'; - */ - }) - #@conn.execute("COMMIT") + sql_entry=<<SQL +DELETE FROM endnotes WHERE metadata_tid = '#{del_id}'; +DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}'; +DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}'; +DELETE FROM documents WHERE metadata_tid = '#{del_id}'; +DELETE FROM urls WHERE metadata_tid = '#{del_id}'; +DELETE FROM metadata WHERE tid = '#{del_id}'; +SQL + if @opt.cmd =~/M/ + @file.puts sql_entry if @opt.cmd =~/M/ + else @conn.execute(%{#{sql_entry}}) + end else tell=SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}") tell.puts_grey #if @opt.cmd.include? ?v @@ -97,3 +92,17 @@ module SiSU_DB_remove end end __END__ +DELETE FROM endnotes WHERE metadata_tid = '#{del_id}'; +DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}'; +DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}'; +DELETE FROM documents WHERE metadata_tid = '#{del_id}'; +DELETE FROM urls WHERE metadata_tid = '#{del_id}'; +DELETE FROM metadata WHERE tid = '#{del_id}'; +/* +DELETE FROM documents WHERE documents.metadata_tid = '#{del_id}'; +DELETE FROM endnotes WHERE endnotes.metadata_tid = '#{del_id}'; +DELETE FROM endnotes_asterisk WHERE endnotes_asterisk.metadata_tid = '#{del_id}'; +DELETE FROM endnotes_plus WHERE endnotes_plus.metadata_tid = '#{del_id}'; +DELETE FROM urls WHERE urls.metadata_tid = '#{del_id}'; +DELETE FROM metadata WHERE metadata.tid = '#{del_id}'; +*/ |