# - - # # - INSERT - # https://www.postgresql.org/docs/9.6/static/sql-insert.html # - TRANSACTIONS - # https://www.postgresql.org/docs/9.6/static/tutorial-transactions.html # - - # DROP TABLE IF EXISTS New_ChartOfAccounts; CREATE TEMPORARY TABLE New_ChartOfAccounts AS SELECT * FROM "Accounting"."ChartOfAccounts" WHERE "Accounting"."ChartOfAccounts".Cia = 'IS'; UPDATE New_ChartOfAccounts SET Cia = '00001'; SELECT * FROM New_ChartOfAccounts; # - - # DELETE FROM "Accounting"."ChartOfAccounts" WHERE "Accounting"."ChartOfAccounts".Cia = '00001'; # - - # DROP TABLE IF EXISTS New_ChartOfAccounts; CREATE TEMPORARY TABLE New_ChartOfAccounts AS SELECT * FROM "Accounting"."ChartOfAccounts" WHERE "Accounting"."ChartOfAccounts".Cia = 'IS'; UPDATE New_ChartOfAccounts SET Cia = '00001'; INSERT INTO "Accounting"."ChartOfAccounts" SELECT * FROM New_ChartOfAccounts; # - - # SELECT '00001' AS Cia, Account, Description, Level, Able, BalanceProfitLoss FROM "Accounting"."ChartOfAccounts" WHERE "Accounting"."ChartOfAccounts".Cia = 'IS'; # - - # INSERT INTO "Accounting"."ChartOfAccounts" SELECT '00001' AS Cia, Account, Description, Level, Able, BalanceProfitLoss FROM "Accounting"."ChartOfAccounts" WHERE "Accounting"."ChartOfAccounts".Cia = 'IS'; # - TRANSACTIONS - # BEGIN; UPDATE accounts SET balance = balance - 100.00 WHERE name = 'Alice'; SAVEPOINT my_savepoint; UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob'; -- oops ... forget that and use Wally's account ROLLBACK TO my_savepoint; UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Wally'; COMMIT; psql -U $user -d $dbIS -h $host -qf /home/Data-1/Images/Programs/Linux\(x32x64\).Img/Linux_Ubuntu\(x32x64\).Img/Linux_Ubuntu_Server.Img/1-Linux_Configuration_Files/General-Documentation/PostgreSQL/PostgreSQL-SQLCommands/SQL_Commands/InsertIntoChartOfAccounts.sql Running the file from psql prompt: \i /home/Data-1/Images/Programs/Linux(x32x64).Img/Linux_Ubuntu(x32x64).Img/Linux_Ubuntu_Server.Img/1-Linux_Configuration_Files/General-Documentation/PostgreSQL/PostgreSQL-SQLCommands/SQL_Commands/InsertIntoChartOfAccounts.sql;