PostgreSQL

PgSql: Replace Add break

Posted on

UPDATE m_product SET em_mg_longdescription = regexp_replace(em_mg_longdescription,’————‘,chr(13)) WHERE em_mg_manufacturer = 1000637 AND value = ‘IMI-YW356A01′     Some additional replace scripts   UPDATE m_product SET em_mg_longdescription = regexp_replace(em_mg_longdescription,'</li>’,chr(10)) WHERE em_mg_manufacturer = 1000637   UPDATE m_product SET em_mg_longdescription = replace(em_mg_longdescription,'<li>’,”) WHERE em_mg_manufacturer = 1000637   UPDATE m_product SET em_mg_longdescription = replace(em_mg_longdescription,'<ul>’,”) WHERE em_mg_manufacturer = 1000637   UPDATE […]

MySQL

phpMyAdmin: Securing web console

Posted on

I installed PHPMyadmin to check my help manage my database, eventhough I also use the desktop program MySQL Workbench, I fell sometimes its important to use the webconsole. Recently, upon checking my MySQL Logs (/var/logs/mysql/error.log) I encountered that everyday I had thousands of failed logins to the PHPMyAdmin. I sure enough have a very strong […]

PostgreSQL

PostgreSQL: Limit 1 on Group BY

Posted on

It’s stupidly complicated to get just one record per group on a PostgreSQL query… After an hour of trial and error this worked for me: SELECT DISTINCT ON (c_order_id) c_order_id FROM c_invoice   No Group By or Limit 1 functions needed.    

PostgreSQL

PgSql: Cannot Alter Character Length because of Dependant Views

Posted on

  SQL error: ERROR: cannot alter type of a column used by a view or rule DETAIL: rule _RETURN on view rv_warehouseprice depends on column “sku” In statement: ALTER TABLE “adempiere”.”m_product” ALTER COLUMN “sku” TYPE character varying(50) I’ve read some documentation and the only apparent solution is to delete all the related views and then […]