Tag Info

New answers tagged

2

Not a direct answer to your question but you should try the first_value window function. It works like this: CREATE TABLE test ( id SERIAL NOT NULL PRIMARY KEY, cat TEXT, value VARCHAR(2) date TIMESTAMP WITH TIME ZONE ); Then, if you want the first item in each cat (category) you will query like that: SELECT cat, ...


1

The way statement_timeout works, the time starts counting when the server receives a new command from the client. Queries launches inside server-side functions are not commands from a client, they don't reset that timer or push a new one onto a stack of timers. This is why SET LOCAL statement_timeout = 100; has no effect. And if a function does SET ...


5

UPSERT 1 row at a time with function A "table-function" is a function returning a set of rows (acting like a table when called with SELECT * FROM myfunc()). What you have is not a table-function. Since nothing is returned you can use a simple call: SELECT merge_vehicles(vid, cid, vname, reg_no, name, name_1st) FROM ( VALUES (2335, 55, '246BDH', ...


2

You can call the function multiple times like the following select merge_vehicles (2335, 55, '246BDH', '246BDH', '811', 1); select merge_vehicles (2336, 55, '038THX', '038THX', '831', 1);


4

First of all, there is no "trigger body" (unlike Oracle). In Postgres you have a trigger function (also called procedure) with a function body and 0-n triggers (without body) calling this function. The special variable NEW in plpgsql trigger functions is neither a map nor an array; it's a row: NEW Data type RECORD; variable holding the new database ...


2

I must admit that this is no easy way of solving it, but at least it's a way. I created the below example as a standalone one, to avoid all clutter with trigger creation and such. If you use it in a trigger, you can remove the declaration and initialization of p and replace the remaining use with NEW. DO $$ DECLARE p members_test; BEGIN p := (1,2,3); ...


0

yes, this is possible. however, you have to be a little careful. DDLs in a stored procedure USUALLY work. in some nasty corner cases you might end up with "cache lookup" errors. The reason is that a procedure is basically a part of a statement and modifying those system objects on the fly can in rare corner cases cause mistakes (has to be). This cannot ...


2

Unfortunately, mysql_config contains quite a bit of black magic and quite a bit of blatant sketchiness. It's notoriously untrustworthy if you have more than one copy of it or the version doesn't match your server build. Unfortunately, too, if you're using one from a distro (not official binaries) then that utility may not even be in the same package as the ...



Top 50 recent answers are included