Most voted "plpgsql" questions
Questions about the procedural language of Postgresql.
Learn more…19 questions
Sort by count of
-
6
votes2
answers402
viewsPass ROWTYPE parameter with the EXECUTE command
I am developing a function in Postgres that aims to recover for each record of a query the result value of a check contained in a set of functions. Of these functions only one will return the…
-
2
votes1
answer1193
viewsUpdate from comparison between two postgres tables
I have a sales chart that contains the seller’s code. However the seller’s table was all redone, with the change of id. How can I update the seller code in the sales table from the comparison…
-
2
votes2
answers117
viewsReturn records that total desired value
I have a table in this format, with more N values and N suppliers, approximately 100 thousand records, and I need to do through a query or a plpgsql function a way to get all the release numbers num…
-
1
votes2
answers275
viewsForeign key FK, is each identification number on a table?
Example: - CLIENTE(Num_cliente, Nome_cliente, Cidade) - PEDIDO(Num_pedido, Data_pedido, Num_cliente, Preco_total) - ITEM_PEDIDO(Num_pedido, Num_item, Quantidade) - ITEM(Num_item, Preco_unitario) -…
-
1
votes1
answer330
viewsScript to change table names in the Postgresql database
I have this script: SELECT n.nspname AS schema_name, c.relname AS table_name, c.reltuples::int AS num_reg FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace LEFT JOIN pg_tablespace t…
-
1
votes1
answer186
viewsUpdate an attribute according to two other tables
Table Company CREATE TABLE empresa ( cnpj char(18) PRIMARY KEY, nome varchar(60) NOT NULL UNIQUE, receita float NOT NULL, pais_sede varchar(26) NOT NULL ); Target table CREATE TABLE destino( cidade…
-
1
votes1
answer202
viewsHow to update column for each SELECT in a given table?
I tried to create a trigger for a table using for it to be activated after each select, but researching a little I discovered that it is not possible to create triggers for selections, only for…
-
1
votes2
answers246
viewsPostgres: How to compare json to create audit Trigger and display only differences
According to the structure below, I would like that when it was updated I could memorize only the differences. Example in the table produto I have the fields: prodcodigo = 1 proddescricao = 'FILTRO…
-
0
votes1
answer78
viewsAutomatic SCHEMA creation in postgresql
I’m having a problem with the following, I need to create a Rigger that when a given row is inserted it creates a SCHEMA with a specific structure! For example, in the public scheme, I have the…
-
0
votes1
answer577
viewspostgres compare time extracted from a timestamp
I need to extract the hours and minutes of a timestamp in mysql, I tried to use maketime(); CREATE OR REPLACE FUNCTION agendar(dia timestamp) returns bool as $$ declare hora time := extract(hour…
-
0
votes0
answers66
viewsmysql error while trying to insert a timestamp
I’m trying to pass a timestamp per parameter for a Function, but I end up getting an error ERROR: invalid input syntax for type time: "10" the stretch where I pass is: select agendar('2010-01-01…
-
0
votes1
answer112
viewsReturn result from a select inside a loop
I’ve been trying for a few hours to get the result of a select that is within a pgsql function. I don’t have much experience with sql. I researched a little but I was not very successful. Follow my…
-
0
votes1
answer999
viewsIf exists update Else Insert in table with foreign key postgres
I need to do an Insert in a table with a foreign key, so if this record does not exist in the other table I need to do an Insert, can I do this operation using if exists? Some solution?
-
0
votes2
answers710
viewsOperator in postgres function returns SQL Error [42883]: ERROR: operator does not exist: integer = integer[]
I have the following error in a function postgres SQL Error [42883]: ERROR: operator does not exist: integer = integer[] I tried to convert the data to varchar and text but still I could not return…
-
0
votes1
answer29
viewsCounting supervisors in pgAdmin
How can I list the name of each supervisor with the amount of supervised. select f.NomeFunc, s.ID_Superv from Funcionario f inner join Funcionario s on s.ID_Superv = f.ID_Func having…
-
0
votes1
answer538
viewsHow can I make a trial to update the balance in postgres?
Mine has been giving an error that I can not understand talking q is wrong in $, but when I used another example internet trial almost in the same way as mine worked, then the mistake is being on…
-
0
votes0
answers233
viewsPostgres Pl syntax (syntax error at or near "integer")
I’m having trouble making a Pl in Postgres, I don’t know where I’m going wrong, can help me... THE TENACIOUS: do $$ declare id_cir integer; begin -- ERROR: syntax error at or near "integer" (SELECT…
-
-1
votes1
answer84
viewsTrigger cursor in book allocation
Well, I have a table called LOCACAO_LIVRO in it I have BOOK and CLIENT information when an allocation update occurs then the id_client will be informed, id_book, the data_de_output and from this…
-
-1
votes1
answer18
viewsProblem with update Trigger PLPGSQL
I have a Trigger for a stock audit, the Insert of it works, but the update no, or it changes nothing or changes all records with the same item code. How can I adjust this part of the Where of update…
postgresql function sql-update trigger plpgsqlasked 3 years, 6 months ago Camila Gabrielly Gonçalves 1