pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pepe TD Vo <pepevo@yahoo.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
To: Pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: %rowtype
Date: Fri, 9 Nov 2018 13:12:45 +0000 (UTC)
Message-ID: <1072312432.1472810.1541769165531@mail.yahoo.com> (raw)
In-Reply-To: <cca2ac7b8f6f19c5334d6aa803be33e1065bd7be.camel@cybertec.at>
References: <1769600488.1326361.1541732091653.ref@mail.yahoo.com>
	<1769600488.1326361.1541732091653@mail.yahoo.com>
	<cca2ac7b8f6f19c5334d6aa803be33e1065bd7be.camel@cybertec.at>

thank you Ms. Albe,
I have tried that and still not working.  It passed that error and then complained about the shema, cidr_staging does not exist and/or c1 (cursor) is not exist.  when I take it out, it complained invalid type name for those below:   v_Rec_Num      cidr_staging.stg_i864.receipt_number%type;   v_Dat_Ent      cidr_staging.stg_i864.date_entered%type;   v_Seq_Num      cidr_staging.stg_i864.sequence_number%type;
according to this url, https://www.postgresql.org/docs/10/plpgsql-declarations.html

PL/pgSQL variables can have any SQL data type, such as integer, varchar, and char.Here are some examples of variable declarations:user_id integer;
quantity numeric(5);
url varchar;
myrow tablename%ROWTYPE;
myfield tablename.columnname%TYPE;
arow RECORD; again, none of variable declaration as same as example work.  Sorry, I'm not a developer and I'm new on Postgres, sorry for ask a wrong question here when I'm not know how.
thank you,
Bach-Nga

No one in this world is pure and perfect.  If you avoid people for their mistakes you will be alone. So judge less, love and forgive more.To call him a dog hardly seems to do him justice though in as much as he had four legs, a tail, and barked, I admit he was, to all outward appearances. But to those who knew him well, he was a perfect gentleman (Hermione Gingold)
**Live simply **Love generously **Care deeply **Speak kindly.*** Genuinely rich *** Faithful talent *** Sharing success 

    On Friday, November 9, 2018 2:26 AM, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
 

 Pepe TD Vo wrote:
> Would you please tell me what I did wrong here?
> I couldn't find the rowtype eliminate with a cursor in multi-tables selected.
> 
> 
> CREATE OR REPLACE FUNCTION "CIDR_STAGING"."PR_MIG_STG_I864" ( v_Ret OUT int ) RETURNS integer as $$
>  declare 
>    c1 cursor is
>      SELECT ...;
>    rec1            c1%rowtype;

There is a type associated with each view and table, but not with a cursor.

You need to use the generic type "record" for "rec1".

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com



   

view thread (4+ messages)  latest in thread

Message-ID: <1072312432.1472810.1541769165531@mail.yahoo.com>
Permalink:  ../1072312432.1472810.1541769165531@mail.yahoo.com/
Also on:    postgresql.org/message-id/1072312432.1472810.1541769165531@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: pepevo@yahoo.com, laurenz.albe@cybertec.at
  Subject: Re: %rowtype
  In-Reply-To: <1072312432.1472810.1541769165531@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox