Questions tagged as 'postgresql'

1
answer

Create a table copy

Greetings. I have a table (basic_data), when generating a "new project", each project inherits basic_data. But when the user wants to edit these, the ideal is that these modifications are in a table "data_basicos_editables", that is to say where...
asked by 15.12.2017 / 15:54
1
answer

Multiple primary key problem

I have the table in which 2 fields are found as primary keys CREATE TABLE public.productounidad ( prod_cod character varying(30) NOT NULL, uni_nombre character varying(100) NOT NULL, pu_cantidad numeric(8,2) DEFAULT 0, pu_minimo numeric(8,2) D...
asked by 01.11.2017 / 16:35
2
answers

How do I solve error due to foreign key restriction?

I have an error in my database in some tables, they have information inside, the problem is that when I try to delete some data I miss this error ERROR: update o delete en «cronograma» viola la llave foránea «fk_participantes_id_cronograma» e...
asked by 08.09.2017 / 18:14
2
answers

ERROR: syntax error on or near «'postgresql

Hi, I have the following problem, I'm trying to create a view in postgresql this is my instruction: CREATE OR REPLACE VIEW cat_ejemplo_view AS SELECT CCC.c_campo1 as id_campo1, CCC.c_campo2 as descripcion FROM dblink('host=pruebas dbna...
asked by 14.06.2017 / 00:33
2
answers

How to search by date in a timestamp

I have dates stored in timestamp of the form: 1999-01-08 04:05:06 1999-01-24 13:22:29 What I want is to make a query between ranges of dates that is: Inicio: 1999-01-09 Fin: 1999-01-12 It returns the records with a date between 1999-0...
asked by 09.04.2018 / 22:33
2
answers

Error creating Trigger in Postgresql - syntax error at or near "BEGIN"

I am currently trying to create a trigger in postgresql to perform an insert in a table. But when executing the sentence the result throws:    ERROR: syntax error at or near "BEGIN"   LINE 4: BEGIN CREATE TRIGGER TRG_INS_DOCUMETTYPE...
asked by 21.11.2016 / 19:46
4
answers

What is the best way to make a current contract selection and an employee's previous contract in the same row?

Hi, I'm scheduling queries in Oracle 11g and PostgreSQL 9.4, and I have been asked to perform a query whose output is shown in the following image. Employee_ID belongs to the employee table; Current_Contract_ID and Previous_Contract_Id...
asked by 08.11.2016 / 18:21
2
answers

How can I get a value between [] of a String?

When postgres sends an error, it sends a message with a code, example:    SQLSTATE [23505]: Unique violation: 7 ERROR: duplicate key violates uniqueness restriction «cargos_index_lower_unique»   DETAIL: The key already exists (lower (name ::...
asked by 08.11.2016 / 15:44
3
answers

Sort alphabetically two columns, PostgreSQL

I have the following query: SELECT carreras.nombre,grupos_acta.grado,count(grupos_acta.grado) AS grupos ,sum(hombres),sum(mujeres),descripcion FROM control.asignacion_grupos INNER JOIN control.grupos_acta ON grupos_acta.id = id_grupos_acta...
asked by 29.12.2016 / 15:46
2
answers

How can I modify a field to integrate and return it null or empty? from laravel in DB postgresql

The table is as follows: CREATE TABLE public.productos_procesos ( id integer NOT NULL DEFAULT nextval('productos_procesos_id_seq'::regclass), id_productos integer NOT NULL, id_procesos integer NOT NULL, unidad_teorica integer, id_uni...
asked by 15.03.2017 / 18:56