[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x

PostgreSQL

PostgreSQL is an object-relational database management system with an emphasis on extensibility and standards-compliance. As a database server, its primary function is to store data securely, supporting best practices, and to allow for retrieval at the request of other software applications. PostgreSQL implements the majority of the SQL2011 standard, is ACID-compliant and transactional using multiversion concurrency control (MVCC), and handles complex SQL queries using many indexing methods that are not available in other databases. It is cross-platform and runs on many operating systems including Linux, FreeBSD, OS X, Solaris, and Microsoft Windows.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi there,

I have this KB article from Atlassian, and they show a specific PostgreSQL query, but I need to run it against Microsoft SQL server. Anybody able to assist?

The article is: https://confluence.atlassian.com/confkb/some-attachments-or-links-are-no-longer-accessible-after-server-migration-214862724.html

The query itself that is shown is:

insert into contentmigration
select bodycontentid, substring(body from '\\|http://oldServerName/download/attachments/.*/') from bodycontent;


Thanks for any suggestions!
0
Free Tool: Path Explorer
LVL 11
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

We have a .NET application that we have developed which mostly runs calculation queries and inserts data to a few tables based on the calculation queries. We want to add a progress bar. How could this be accomplished? The longest part is the functions it runs for the calculation where the data is coming from large tables. Inserting the data is very quick after the calculation. The database is a PostgreSQL
0
Hi,
I have installed postgresql  version 9.6.
But when i give "sudo service postgresql start" command am getting the below error
* Restarting PostgreSQL 9.6 database server                                                                                                                          
* Failed to issue method call: Unit postgresql@9.6-main.service failed to load: No such file or directory. See system logs and 'systemctl status postgresql@9.6-main.service' for details.

Please give me the solution
0
I am trying to convert a SQL Server stored procedure to Post gres procedure but stuck up in the XML portion.  Need help in converting this XML piece of code to post gres code.

EXEC sp_xml_preparedocument @idoc OUTPUT, @ROLES;
                  UPDATE SSO_XREF_USER_ROLE SET ACTV_IND=1 WHERE
                  (CONVERT(VARCHAR,SSO_USER_ID)+CONVERT(VARCHAR,SSO_ROLE_ID)) IN
                  (SELECT CONVERT(VARCHAR,X.SSO_USER_ID)+CONVERT(VARCHAR,X.SSO_ROLE_ID) FROM
                        (SELECT XUR.SSO_USER_ID,SR.SSO_ROLE_ID FROM SSO_XREF_USER_ROLE XUR
                              JOIN SSO_ROLE SR ON XUR.SSO_ROLE_ID=SR.SSO_ROLE_ID WHERE
                              SR.SSO_ROLE_NM IN
                              (SELECT RoleName FROM
                                    OPENXML(@idoc, '/DocumentElement/UpdateRoles', 2)
                                          WITH (RoleName  varchar(100),
                                                      RoleStatus  numeric(1,0))
                                                      WHERE RoleStatus=1))AS X)

Not sure what is the equivalent of sp_xml_preparedocument in Postgres procedure
0
For a database hosted elsewhere we have asked for a dump to use locally with GIS.
The file we have from the dump has the following in it and fails on the import via SQL query.

COPY catch_methods (name) FROM stdin;
Set Line
Set net
Other
\.

Open in new window



The error that comes up is:
Invalid command \.. Try \? for help

What am I missing in regards to this, there are multiple large entries with the above just being a short one.
0
Hi,

We are migrating from oracle to postgresql. And we faced problems while rewriting oracle procedures to postgresql functions.

We get all the data required for the endpoint from single procedure to reduce round trips to database.

for example if we want show user posts

create or replace procedure user_posts(userId IN NUMBER, noOfPosts OUT NUMBER, posts OUT sys_refcursor, postComments OUT sys_refcursor)

here we are getting noOfPosts, posts and postComments resultset from single procedure.

Searched for the equivalent procedure in postgresql but not found.

While searching for the answer I found returns table. But using returns table I am not able to achieve this. I am able to get only one of these three out parameters.

Because of this constraint now we are using three queries for noOfPosts, posts and postComments.

How can we achieve same with postgresql.

Thanks.
0
Hi,
   we have postgresql function which accepts tags_type composite type as a input parameter.  
How can we pass the values to the function using jpa.

create type tags_type as(tag text, tag_url text)


CREATE OR REPLACE FUNCTION public.create_article(title text, tags tags_type[])
 RETURNS integer
AS $function$
DECLARE
	id int2;
	t tags_type;
begin
	
	insert into articles(a_title)
	values(title);

	id := currval('article_id_seq');

	FOREACH t in array tags
	loop
		insert into atricle_tags(at_id, at_tag, at_url_name)
		values(id, t.tag, t.tag_url);
	end loop;

	return id;
end;
$function$
LANGUAGE plpgsql

Open in new window

0
Hi,

 I am trying to get refcursor from postgresql procedure using spring data jpa. I am getting below error.

org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: 1111; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111

Here data got inserted in database but not able to get the data from.

CREATE OR REPLACE FUNCTION public.register(email text, password text, name text)
 RETURNS refcursor

AS $function$
DECLARE
	userInfo REFCURSOR;
	userId int4;
begin
	insert into "users"(u_email, u_password, u_name)
	values(email, password, name);
	
	userId := currval('user_u_user_id_seq');

	open userInfo FOR SELECT * FROM users WHERE u_user_id = userId;

	return userInfo;
end;
$function$
 LANGUAGE plpgsql

Open in new window



@Override
public User register(User user) {


StoredProcedureQuery storedProcedureQuery = entityManager.createStoredProcedureQuery(REGISTER_PROCEDURE)
        .registerStoredProcedureParameter(1, String.class, ParameterMode.IN).setParameter(1, user.getEmail())
        .registerStoredProcedureParameter(2, String.class, ParameterMode.IN).setParameter(2, user.getPassword())
        .registerStoredProcedureParameter(3, String.class, ParameterMode.IN).setParameter(3, user.getName());

storedProcedureQuery.execute();
List<User> list = storedProcedureQuery.getResultList();


return list.get(0);
}

Open in new window


@Entity
@Table(name = "users")
public class User implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "u_user_id")
    private long userId;

    @Column(name = "u_email")
    private String email;

    @Column(name = "u_password")
    private String password;

    @Column(name = "u_name")
    private String name;


}

Open in new window

0
this query work in postgresql and console SQL of sc, but no work in SQL of grid...why?

      SELECT
          cpccod,
          lpad(cpcdes,cast(60+(4*cpcnvl) as int), ' '),
          cpccla,
          cpcslm
      FROM
          "public".sccmpc
           where trim(ccodemp)='1' and cempre='E02'
           order by cpccla
0
I want to convert my postgress 7.4 Sql_ascii database to postgress 9.4 utf8 database..... how can I do it?..... please help
0
NFR key for Veeam Backup for Microsoft Office 365
LVL 1
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Greetings,

I have a 700gb postgres database which has a standby readonly replica and I wish to migrate and upgrade to a new server with the latest postgres version so what would be the ideal migration path for this situation? it's in a Linux environment.
0
Simply put.. I connected to a free micro instance of a postgres DB I created on AWS RDS.

It worked fine. I set up a database and a couple tables on it.

Now that I'm trying to connect to it from my app.. it's just timing out.

AND.. I can no longer connect to it from PSequel or.. anything. It just keeps timing out.

I'm not even sure what more detailed questions to ask or what to direction to poke in on this one.
0
Hi, I write after sending my code to the attention. So ... I have to convert an Oracle Pl-Sql application into a similar PostgreSQL application. In addition to the ect table view tables, I need to convert Procedures and Functions.
I find myself having to convert an Oracle Pl-Sql procedure with 6 input parameters (the search filter) and 2 output parameters (one numeric for cpunt of extracted recs, the other Type Cursor for the processed cursor result ).
Well in Postgres does not exist the Type Cursor, so I wondered how to overcome the problem having a minimum target: the structure of the procedure / function should remain unaltered in the input and output parameters.
This is because the java application must be able to call the procedure / function both in oracle and postgres without modifying the call itself.
It's possible?
So far I have worked with the refcursor solution and with the table solution (as data type of output).
With the first one they could not get the result of the cursor but only the error "unnamed_portal_1" while with the TABLE solution I finally found the solution but it obliges me to have to modify the similar running procedure in Oracle.
Attach the test environment and code tested in the various versions.
0
The same slightly changed function returns only the count. I have difficulty with the cursor result sets.
If I use the function3 using refcursor, I return to "unnamed_portal_1", who finds the solution to extract the second cursor? The 2 OUT variables must remain since the java application must invoke the Oracle function and the one converted to Postgres without changing the call
function2.sql
function3.sql
0
I find this function, but I can not return any data.
Testing the individual queries, there are 5 recs that should be extracted.
Where am I wrong?
The function MUST be with the INPUT parameters that are highlighted and with the two OUT parameters.
This is because of the conversion of a similar Oracle function, a function that must be invoked by the same application by either pointing to Oracle or pointing to Postgres
function1.sql
0
CREATE OR REPLACE FUNCTION pck_gestione_tracce_sistema.p_get_rotta_traccia_sistema6(
    IN in_id_traccia_sistema numeric,
    IN in_id_versione numeric,
    IN in_limite_inferiore numeric,
    IN in_limite_superiore numeric,
    IN id_limite_inferiore_data date,
    IN id_limite_superiore_data date,
    IN in_id_viaggio numeric,
    OUT on_out_total_count numeric,
    OUT oc_out_recordset character varying)
  RETURNS record AS
$BODY$
DECLARE
   LD_LIMITE_INFERIORE_DATA Date ;
   LD_LIMITE_SUPERIORE_DATA Date ;
   LK_PACKAGE_NAME varchar(1000);
   LK_FUNCTION_NAME varchar(1000);
   LN_DEBUG_INFO Integer;
 
   ref refcursor;
   ref1 refcursor;

Begin  

   
   LN_DEBUG_INFO := 1;
   LK_PACKAGE_NAME := 'PCK_GESTIONE_DATI';
   LK_FUNCTION_NAME := 'P_GET_ROTTA_TRACCIA_SISTEMA';
   LD_LIMITE_INFERIORE_DATA  := TO_DATE(TO_CHAR(ID_LIMITE_INFERIORE_DATA,'DD/MM/YYYY HH24:MI:SS'),'DD/MM/YYYY HH24:MI:SS');
   LD_LIMITE_SUPERIORE_DATA  := TO_DATE(TO_CHAR(ID_LIMITE_SUPERIORE_DATA,'DD/MM/YYYY HH24:MI:SS'),'DD/MM/YYYY HH24:MI:SS');

    If (LN_DEBUG_INFO = 1) Then
      PERFORM nereus.p_logging(IN_TIPO        => 'I'::character varying,
                IN_CODICE      => 'INFO'::character varying,
                IN_DESCRIZIONE => 'Input call'::character varying,
                IN_MODULO      => LK_PACKAGE_NAME::character varying, --LK_PACKAGE_NAME,
                IN_FUNZIONE    => LK_FUNCTION_NAME::character varying, --LK_FUNCTION_NAME,
               …
0
CREATE OR REPLACE FUNCTION pck_gestione_tracce_sistema.p_get_rotta_traccia_sistema10(
    IN in_id_traccia_sistema numeric,
    IN in_id_versione numeric,
    IN in_limite_inferiore numeric,
    IN in_limite_superiore numeric,
    IN id_limite_inferiore_data date,
    IN id_limite_superiore_data date,
    IN in_id_viaggio numeric,
    OUT on_out_total_count numeric,
    OUT oc_out_recordset character varying)
  RETURNS SETOF record AS
$BODY$
DECLARE
   LD_LIMITE_INFERIORE_DATA Date ;
   LD_LIMITE_SUPERIORE_DATA Date ;
   LK_PACKAGE_NAME varchar(1000);
   LK_FUNCTION_NAME varchar(1000);
   LN_DEBUG_INFO Integer;
 
   ---ref refcursor;
   ---ref1 refcursor;
   counter record;
   setdati record;

Begin  

   
   LN_DEBUG_INFO := 1;
   LK_PACKAGE_NAME := 'PCK_GESTIONE_DATI';
   LK_FUNCTION_NAME := 'P_GET_ROTTA_TRACCIA_SISTEMA';
   LD_LIMITE_INFERIORE_DATA  := TO_DATE(TO_CHAR(ID_LIMITE_INFERIORE_DATA,'DD/MM/YYYY HH24:MI:SS'),'DD/MM/YYYY HH24:MI:SS');
   LD_LIMITE_SUPERIORE_DATA  := TO_DATE(TO_CHAR(ID_LIMITE_SUPERIORE_DATA,'DD/MM/YYYY HH24:MI:SS'),'DD/MM/YYYY HH24:MI:SS');

    If (LN_DEBUG_INFO = 1) Then
      PERFORM nereus.p_logging(IN_TIPO        => 'I'::character varying,
                IN_CODICE      => 'INFO'::character varying,
                IN_DESCRIZIONE => 'Input call'::character varying,
                IN_MODULO      => LK_PACKAGE_NAME::character varying, --LK_PACKAGE_NAME,
                IN_FUNZIONE    => …
0
Hello Experts,

Currently the Atlassian applications along with the Postgres databases reside on 1 VM.

I am looking for any recommendations for splitting up the applications/databases and platform options to integrate the Atlassian applications on (VM, Docker or AWS).

We have 100 users split between the US and UK.
0
Hello Experts,

I would like to use spark streaming to identify in real time if a record already exists in the database.

The data that we receive contains the customerId and I would like to be able to determine if the customerId that we are receiving is already stored in a specific table in our database. If not I would go ahead and store the record, if yes I won't store it again.

The customerId is a value generated by an external application
The data is received from Kafka 24/7.
0

PostgreSQL

PostgreSQL is an object-relational database management system with an emphasis on extensibility and standards-compliance. As a database server, its primary function is to store data securely, supporting best practices, and to allow for retrieval at the request of other software applications. PostgreSQL implements the majority of the SQL2011 standard, is ACID-compliant and transactional using multiversion concurrency control (MVCC), and handles complex SQL queries using many indexing methods that are not available in other databases. It is cross-platform and runs on many operating systems including Linux, FreeBSD, OS X, Solaris, and Microsoft Windows.

Top Experts In
PostgreSQL
<
Monthly
>