Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
In the below code, the FOR doc IN SELECT ... loop was returning a NULL in doc_typeid - impossible because it has a foreign key constraint on it. By luck I found that modifying it to FOR doc in SELECT doc_id, doc_typeid magically forced the correct value into doc_typeid (luck because I didn't need to select doc_id). When I changed the declaration of doc to record instead of a rowtype and removed the kludgey doc_id from the SELECT, it also worked correctly. These different tests led me to conclude that something other than the list of selected columns in the SELECT was determining the result set - perhaps the columns as ordered in the doc table at the last creation or alter table event are driving the population of the rowtype variable instead. So perhaps because record does not depend on any tables, my workaround to replace the rowtype declaration with record worked first time.
CREATE OR REPLACE FUNCTION public."doct_GetActMask"( parm_holid bigint, parm_holtype character varying) RETURNS integer AS $BODY$DECLARE doc document%ROWTYPE;; actmask integer := 0; doctpid integer := NULL; approved integer := NULL; verified integer := NULL; logok integer := NULL; BEGIN SELECT docs_id FROM public."DocumentStatus" WHERE docs_shortname = 'Approved' INTO approved; SELECT docs_id FROM public."DocumentStatus" WHERE docs_shortname = 'Verified' INTO verified; FOR doc IN SELECT doc_type_id FROM document WHERE doc_hol_id = parm_holid AND (doc_docsid = approved OR doc_docsid = verified) LOOP SELECT public."doct_GetRoot"(doc.doc_type_id) INTO doctpid; IF doctpid < 0 THEN RETURN doctpid; END IF; actmask := actmask | (1<<(doctpid-1)); END LOOP; RETURN actmask; END$BODY$ LANGUAGE plpgsql VOLATILE COST 100; ALTER FUNCTION public."doct_GetActMask"(bigint, character varying) OWNER TO mydbo;

One world, one people

In reply to Re^2: Returning multiple rows from pgplsql to DBI by (anonymized user)
in thread Returning multiple rows from pgplsql to DBI by (anonymized user)

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (6)
    As of 2020-08-14 23:57 GMT
    Find Nodes?
      Voting Booth?
      Which rocket would you take to Mars?

      Results (77 votes). Check out past polls.