Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
91 views

PostgreSQL: How to pass multiple parameters from command line?

I am following the other topic, but unfortunately i couldn't comment on that as i don't meet requirement to comment (less reputation). If someone can help me, i really appreciate it. topic is here ...
jojo's user avatar
  • 21
0 votes
0 answers
272 views

Using PSQL COPY in postgres

I need to include \copy for my postgres code . do language plpgsql $$ declare begin \copy from tab1'C:\\Documents\test.csv' DELIMITER E'\t' CSV HEADER ; insert into tab2 select * from tab1 ; when ...
Udayasoorian CN's user avatar
0 votes
1 answer
24 views

Creating parameter inside a plpgsql function to use in bash script

I have a plpgsql function: CREATE OR REPLACE FUNCTION public.test_function() RETURNS void LANGUAGE plpgsql AS $function$DECLARE export_time timestamp; export_path text; begin export_time ...
zed's user avatar
  • 13
0 votes
1 answer
3k views

how to call and send parameter to postgres procedure

i have postgres procedure like this DROP PROCEDURE IF EXISTS updateTransactionsFromBackups(date text); CREATE PROCEDURE updateTransactionsFromBackups(date text) LANGUAGE plpgsql ...
matin's user avatar
  • 63
-1 votes
1 answer
262 views

Sum all ascii values for every character of varchar in PostgreSQL

I have a table I want to partition based on HASH. This table has a column with varchar, which is the key I want to use to partition. Ofc. I can't partition based on HASH with varchar, therefore I will ...
Logstor's user avatar
0 votes
1 answer
578 views

How to check current database inside PL/pgSQL script?

It is possible to allow PL/pgSQL script run for only specific database? Example, I have the script, that deleting unnecessary columns in all database tables and I want to be sure that this script can ...
Anton P's user avatar
  • 37
0 votes
1 answer
2k views

Not able to print raise notice output in log file tried with all log conditions - SET client_min_messages TO debug1;

BEGIN RAISE INFO 'raise info - time: %', now() ; RAISE WARNING 'raise warning - time: %', now(); RAISE NOTICE 'raise notice - time: %', now(); RAISE LOG 'raise log - ...
SamirMjs's user avatar
0 votes
0 answers
657 views

Writing a for-loop using psql

I am trying to run a for loop via psql command in Linux to do some spatial operations in PostGIS database My SQL command which I successfully ran in dbeaver looks something like this DO $$ declare ...
rm167's user avatar
  • 1,247
2 votes
1 answer
2k views

PSQL passing external variables

I'm trying to pass a value/variable from a batch script to a SQL script and I am having trouble. The code flows as such: Starting in my batch script, I make a psql command call referencing ...
nick S. tryinamakaliving's user avatar
0 votes
1 answer
204 views

I am getting the error subquery must return only one column when I try to run the following query:

CREATE or REPLACE PROCEDURE checkUpdateAdd(imei1 inout text, assetName1 inout text) language 'plpgsql' AS $BODY$ declare begin PERFORM * from msdata; if (select * from msdata where imei = imei1) ...
codeLibrary's user avatar
1 vote
0 answers
701 views

What is the alternative for DECLARE and SET in MS SQL for PostgreSQL?

I can write the below in MS SQL, however, need to write this in PostgreSQL DECLARE @countryname nvarchar(max) = 'China'; So that I can use this in; Select * from country_table where country=@...
Raj Gupta's user avatar
0 votes
1 answer
594 views

Not able to call multiple functions from one function in PostgreSQL

Here are my two functions, CREATE OR REPLACE FUNCTION public.insert_stagging() RETURNS void LANGUAGE plpgsql AS $function$ BEGIN INSERT into stagging(data) select data from ...
The Joker's user avatar
  • 214
0 votes
2 answers
954 views

Postgresql ignoring if condition

I'm trying to understand transactions in plpgsql and i would like some explanations. I have this code: CREATE OR REPLACE PROCEDURE MaJ(mode IN INT) AS $$ DECLARE r RECORD; DECLARE r RECORD; BEGIN ...
Majd's user avatar
  • 348
1 vote
1 answer
420 views

How to refer to a value in a PostgreSQL script?

I'd like to use the max value to feed the creation of a sequence. For instance, I am getting the max id value and I'd like to use this value: DO $$ DECLARE min_value Integer; BEGIN SELECT ...
JarochoEngineer's user avatar
0 votes
2 answers
234 views

How to add column inside postgres function without saving it to the db?

I have a postgres DB and I want to create a function that returns a copy of my table with a new column that has a value of 1 if its id is inside the array(idds[]) that the function gets as an input. ...
Yoad's user avatar
  • 45

15 30 50 per page