composite-types

Array of composite type as stored procedure input passed by C# Npgsql

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 14:00:11
问题 I've read several questions and topics related to the issue but none of them actually helped me to solve my problem and none of them actually were related to C#. And here is the actual problem: I have a Postgre composite type: CREATE TYPE law_relation_update_model AS ( from_celex character varying, from_article character varying, to_celex character varying, to_article character varying, link_ids integer[], to_doc_par_id integer ); And I have a stored procedure that is meant to accept an array

Array of composite type as stored procedure input passed by C# Npgsql

帅比萌擦擦* 提交于 2021-02-06 13:59:54
问题 I've read several questions and topics related to the issue but none of them actually helped me to solve my problem and none of them actually were related to C#. And here is the actual problem: I have a Postgre composite type: CREATE TYPE law_relation_update_model AS ( from_celex character varying, from_article character varying, to_celex character varying, to_article character varying, link_ids integer[], to_doc_par_id integer ); And I have a stored procedure that is meant to accept an array

How to map User Data Type (Composite Type) with Hibernate

女生的网名这么多〃 提交于 2020-01-14 02:03:30
问题 I am quite new to Hibernate world. I have modeled by means of ER CASE TOOL (TOAD) my database and I have defined several User Data Type (Composite Type). For example assume I have a type Contact declared as follow in PostgreSQL CREATE TYPE Contact AS ( "email" Varchar, "phone" Varchar, "mobile" Varchar, "other" Varchar ); Now assume i use it on Users Entity like in the following SQL code CREATE TABLE Users( idUser Serial NOT NULL, login Character varying(20) NOT NULL, password Character

Insert using a function that returns two values per row

前提是你 提交于 2020-01-04 04:19:26
问题 This function: CREATE OR REPLACE FUNCTION fn_test1() RETURNS SETOF date AS $BODY$ declare i int; begin i:=0; while i<5 loop return next '2001-01-02'::date; i:=i+1; end loop; end $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 1000; This table: CREATE TABLE teste1 ( teste1_id serial NOT NULL, num integer, fn_date date) An INSERT like this works just fine (inserting 5 rows): Insert into teste1(num,fn_date) select 1, fn_test1(); But if I want to have a function that returns two dates in a row,

Querying CompositeType columns in Cassandra using Hector

﹥>﹥吖頭↗ 提交于 2019-12-18 10:29:14
问题 Here's a sample of the scenario I'm facing. Say I have this column family: create column family CompositeTypeCF with comparator = 'CompositeType(IntegerType,UTF8Type)' and key_validation_class = 'UTF8Type' and default_validation_class = 'UTF8Type' Here's some sample Java code using Hector as to how I'd go about inserting some data into this column family: Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", "192.168.1.6:9160"); Keyspace keyspaceOperator = HFactory.createKeyspace(

SUM & GROUP BY on an array of composite type

为君一笑 提交于 2019-12-11 10:59:25
问题 I have a column with an array of composite type (text, decimal, timestamp) as data type. I want to create a query to sum the total of the double column of the composite type. Also I want to perform a group by on the date(day-month-year) of the date time. Can anyone show me an example of explain how this an be done? Definition of table and type: create type stage as ( Stage_Name text, Stage_Distance decimal, Stage_Start_Time timestamp ); CREATE TABLE "Event" ( "Id" serial NOT NULL, "Location"

How to clone a RECORD in PostgreSQL

白昼怎懂夜的黑 提交于 2019-12-11 06:45:08
问题 I want to loop through a query, but also retain the actual record for the next loop, so I can compare two adjacent rows. CREATE OR REPLACE FUNCTION public.test () RETURNS void AS $body$ DECLARE previous RECORD; actual RECORD; query TEXT; isdistinct BOOLEAN; tablename VARCHAR; columnname VARCHAR; firstrow BOOLEAN DEFAULT TRUE; BEGIN tablename = 'naplo.esemeny'; columnname = 'esemeny_id'; query = 'SELECT * FROM ' || tablename || ' LIMIT 2'; FOR actual IN EXECUTE query LOOP --do stuff --save

Easy way to have return type be SETOF table plus additional fields?

不羁的心 提交于 2019-12-10 22:32:00
问题 I'm writing a PL/pgSQL stored procedure that will return a set of records; each record contains all the fields of an existing table (call it Retailer, which has two fields: retailer_key and retailer_name). This, of course, works: CREATE FUNCTION proc_Find_retailers (IN p_Store_key INT) RETURNS SETOF Retailer AS $$ ...` Now I want to update the sp so that it returns an additional two fields to the 'end' of each returned record. I can do something such as: CREATE FUNCTION proc_Find_store (IN p

How to map User Data Type (Composite Type) with Hibernate

99封情书 提交于 2019-12-06 06:07:40
I am quite new to Hibernate world. I have modeled by means of ER CASE TOOL (TOAD) my database and I have defined several User Data Type (Composite Type). For example assume I have a type Contact declared as follow in PostgreSQL CREATE TYPE Contact AS ( "email" Varchar, "phone" Varchar, "mobile" Varchar, "other" Varchar ); Now assume i use it on Users Entity like in the following SQL code CREATE TABLE Users( idUser Serial NOT NULL, login Character varying(20) NOT NULL, password Character varying(20) NOT NULL, name Character varying(30), surname Character varying(50), contact Contact ) -- Add