Cannot set custom type object in plpgsql to null. Instead fields of that object becomes nullChange type of varchar field to integer: “cannot be cast automatically to type integer”Change column type and set not nullStrange behaviour of Grails' application connected to PostgreSQLUse of custom return types in a FOR loop in plpgsqlNull detection in a complex type with field of another complex typePostgreSQL returns only one row when using custom typesPostgresql - testing RECORD types (for fields or null)How to use variable as field type in plpgsql?Data Type for select in plpgsql function and access its fieldsHow do I overwrite 'not null' fields of a new record on insert using plpgsql?

Count the number of triangles

Half filled water bottle

What makes these white stars appear black?

Can a network vulnerability be exploited locally?

Employing a contractor proving difficult

If the UK Gov. has authority to cancel article 50 notification, why do they have to agree an extension with the EU

Cutting numbers into a specific decimals

Heat output from a 200W electric radiator?

Number of Fingers for a Math Oriented Race

Why might one *not* want to use a capo?

Group riding etiquette

Why is the Grievance Studies affair considered to be research requiring IRB approval?

The meaning of asynchronous vs synchronous

Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?

Do multi-engine jets need all engines with equal age to reduce asymmetry in thrust and fuel consumption arising out of deterioration?

Fantasy Macro Economics: What would Merfolk trade for?

In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?

Defending Castle from Zombies

Why does AM radio react to IR remote?

Drawing probabilities on a simplex in TikZ

Can I lend a small amount of my own money to a bank at the federal funds rate?

Is the Amazon rainforest the "world's lungs"?

How do Barton (Hawkeye/Ronin) and Romanov (Black Widow) end up on the Benatar on Morag in 2014?

Did anybody find out it was Anakin who blew up the command center?



Cannot set custom type object in plpgsql to null. Instead fields of that object becomes null


Change type of varchar field to integer: “cannot be cast automatically to type integer”Change column type and set not nullStrange behaviour of Grails' application connected to PostgreSQLUse of custom return types in a FOR loop in plpgsqlNull detection in a complex type with field of another complex typePostgreSQL returns only one row when using custom typesPostgresql - testing RECORD types (for fields or null)How to use variable as field type in plpgsql?Data Type for select in plpgsql function and access its fieldsHow do I overwrite 'not null' fields of a new record on insert using plpgsql?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to attach null to a custom type object to null. But only the fields inside that object becomes null instead of the object itself.



I have tried using the FOUND flag to determine whether any row was assigned to my object. If found was false, then the custom type object is set to null. But when I print the object, in pgadmin console it looks like (,,,,,,).



Select id,provider_id,beneficiary_name,beneficiary_branch,beneficiary_account_number,swift_code,
payment_terms,currency,bank_name,payment_entity,payment_type,invoice_due_date_type,last_updated_time
INTO provider_payment_method_result
from provider_info.provider_payment_method where provider_id = provider_id_param;
IF NOT FOUND
THEN provider_payment_method_result := NULL::provider_info_api.payment_method;
END IF;
raise notice 'found : %', found;
raise notice 'payment_method % ', provider_payment_method_result;
return provider_payment_method_result;


I expect



NOTICE: found : f NOTICE: payment_method null


Actual result



NOTICE: found : f NOTICE: payment_method (,,,,,,,,,,,,) 









share|improve this question
































    0















    I am trying to attach null to a custom type object to null. But only the fields inside that object becomes null instead of the object itself.



    I have tried using the FOUND flag to determine whether any row was assigned to my object. If found was false, then the custom type object is set to null. But when I print the object, in pgadmin console it looks like (,,,,,,).



    Select id,provider_id,beneficiary_name,beneficiary_branch,beneficiary_account_number,swift_code,
    payment_terms,currency,bank_name,payment_entity,payment_type,invoice_due_date_type,last_updated_time
    INTO provider_payment_method_result
    from provider_info.provider_payment_method where provider_id = provider_id_param;
    IF NOT FOUND
    THEN provider_payment_method_result := NULL::provider_info_api.payment_method;
    END IF;
    raise notice 'found : %', found;
    raise notice 'payment_method % ', provider_payment_method_result;
    return provider_payment_method_result;


    I expect



    NOTICE: found : f NOTICE: payment_method null


    Actual result



    NOTICE: found : f NOTICE: payment_method (,,,,,,,,,,,,) 









    share|improve this question




























      0












      0








      0








      I am trying to attach null to a custom type object to null. But only the fields inside that object becomes null instead of the object itself.



      I have tried using the FOUND flag to determine whether any row was assigned to my object. If found was false, then the custom type object is set to null. But when I print the object, in pgadmin console it looks like (,,,,,,).



      Select id,provider_id,beneficiary_name,beneficiary_branch,beneficiary_account_number,swift_code,
      payment_terms,currency,bank_name,payment_entity,payment_type,invoice_due_date_type,last_updated_time
      INTO provider_payment_method_result
      from provider_info.provider_payment_method where provider_id = provider_id_param;
      IF NOT FOUND
      THEN provider_payment_method_result := NULL::provider_info_api.payment_method;
      END IF;
      raise notice 'found : %', found;
      raise notice 'payment_method % ', provider_payment_method_result;
      return provider_payment_method_result;


      I expect



      NOTICE: found : f NOTICE: payment_method null


      Actual result



      NOTICE: found : f NOTICE: payment_method (,,,,,,,,,,,,) 









      share|improve this question
















      I am trying to attach null to a custom type object to null. But only the fields inside that object becomes null instead of the object itself.



      I have tried using the FOUND flag to determine whether any row was assigned to my object. If found was false, then the custom type object is set to null. But when I print the object, in pgadmin console it looks like (,,,,,,).



      Select id,provider_id,beneficiary_name,beneficiary_branch,beneficiary_account_number,swift_code,
      payment_terms,currency,bank_name,payment_entity,payment_type,invoice_due_date_type,last_updated_time
      INTO provider_payment_method_result
      from provider_info.provider_payment_method where provider_id = provider_id_param;
      IF NOT FOUND
      THEN provider_payment_method_result := NULL::provider_info_api.payment_method;
      END IF;
      raise notice 'found : %', found;
      raise notice 'payment_method % ', provider_payment_method_result;
      return provider_payment_method_result;


      I expect



      NOTICE: found : f NOTICE: payment_method null


      Actual result



      NOTICE: found : f NOTICE: payment_method (,,,,,,,,,,,,) 






      sql postgresql plpgsql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 8:07









      a_horse_with_no_name

      330k52 gold badges514 silver badges608 bronze badges




      330k52 gold badges514 silver badges608 bronze badges










      asked Mar 27 at 21:26









      Sourav MukherjeeSourav Mukherjee

      941 silver badge12 bronze badges




      941 silver badge12 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          2















          This depends on version of PostgreSQL. Where PostgreSQL is older than 10, then behave described by you is expected. Row (or composite value) with NULL in all fields is effectively NULL. On these version, the composite value is passed by value every time (from SQL perspective) and cannot be expressed as one value (although this value is NULL).



          On PostgreSQL 10 and higher this behave is changed.



          CREATE TYPE xy AS (x int, y int);

          DO $$
          DECLARE _xy xy;
          BEGIN
          _xy := (NULL, NULL);
          RAISE NOTICE '% %', _xy, _xy IS NULL;
          END;
          $$;


          If you have older Postgres, and you would to see just NULL, use RECORD type instead.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386692%2fcannot-set-custom-type-object-in-plpgsql-to-null-instead-fields-of-that-object%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2















            This depends on version of PostgreSQL. Where PostgreSQL is older than 10, then behave described by you is expected. Row (or composite value) with NULL in all fields is effectively NULL. On these version, the composite value is passed by value every time (from SQL perspective) and cannot be expressed as one value (although this value is NULL).



            On PostgreSQL 10 and higher this behave is changed.



            CREATE TYPE xy AS (x int, y int);

            DO $$
            DECLARE _xy xy;
            BEGIN
            _xy := (NULL, NULL);
            RAISE NOTICE '% %', _xy, _xy IS NULL;
            END;
            $$;


            If you have older Postgres, and you would to see just NULL, use RECORD type instead.






            share|improve this answer





























              2















              This depends on version of PostgreSQL. Where PostgreSQL is older than 10, then behave described by you is expected. Row (or composite value) with NULL in all fields is effectively NULL. On these version, the composite value is passed by value every time (from SQL perspective) and cannot be expressed as one value (although this value is NULL).



              On PostgreSQL 10 and higher this behave is changed.



              CREATE TYPE xy AS (x int, y int);

              DO $$
              DECLARE _xy xy;
              BEGIN
              _xy := (NULL, NULL);
              RAISE NOTICE '% %', _xy, _xy IS NULL;
              END;
              $$;


              If you have older Postgres, and you would to see just NULL, use RECORD type instead.






              share|improve this answer



























                2














                2










                2









                This depends on version of PostgreSQL. Where PostgreSQL is older than 10, then behave described by you is expected. Row (or composite value) with NULL in all fields is effectively NULL. On these version, the composite value is passed by value every time (from SQL perspective) and cannot be expressed as one value (although this value is NULL).



                On PostgreSQL 10 and higher this behave is changed.



                CREATE TYPE xy AS (x int, y int);

                DO $$
                DECLARE _xy xy;
                BEGIN
                _xy := (NULL, NULL);
                RAISE NOTICE '% %', _xy, _xy IS NULL;
                END;
                $$;


                If you have older Postgres, and you would to see just NULL, use RECORD type instead.






                share|improve this answer













                This depends on version of PostgreSQL. Where PostgreSQL is older than 10, then behave described by you is expected. Row (or composite value) with NULL in all fields is effectively NULL. On these version, the composite value is passed by value every time (from SQL perspective) and cannot be expressed as one value (although this value is NULL).



                On PostgreSQL 10 and higher this behave is changed.



                CREATE TYPE xy AS (x int, y int);

                DO $$
                DECLARE _xy xy;
                BEGIN
                _xy := (NULL, NULL);
                RAISE NOTICE '% %', _xy, _xy IS NULL;
                END;
                $$;


                If you have older Postgres, and you would to see just NULL, use RECORD type instead.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 8:03









                Pavel StehulePavel Stehule

                25.3k3 gold badges52 silver badges62 bronze badges




                25.3k3 gold badges52 silver badges62 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386692%2fcannot-set-custom-type-object-in-plpgsql-to-null-instead-fields-of-that-object%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현