Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9248255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:54:20+00:00 2026-06-18T09:54:20+00:00

Say I have a double precision column in a postgresql table and try the

  • 0

Say I have a double precision column in a postgresql table and try the following INSERTS

Case 1:

INSERT INTO schema.table (column_name) VALUES (null);

Case 2:

INSERT INTO schema.table (column_name) VALUES (unnest(array[1,null,null,4,5]));

Case 3:

INSERT INTO schema.table (column_name) VALUES (unnest(array[null,null,null,null,null]));

Case 1 and 2 execute succesfully, but case 3 returns the following error:

ERROR: column “column_name” is of type double precision but
expression is of type text LINE 1: INSERT INTO schema.table
(column_name) VALUES (unnest(array[nu…
^ HINT: You will need to rewrite or cast the expression.

How should I re-write case 3 to re-cast an unnested array of null values into something that can be inserted in a double precision (or any numeric) column?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:54:21+00:00Added an answer on June 18, 2026 at 9:54 am

    You need to cast the array of null values to double precision[] or float8[]

    INSERT INTO schema.table (column_name)
    VALUES (unnest(
        array[null,null,null,null,null]::float8[]
    ));
    

    or the cast can be expressed as

    cast(array[null,null,null,null,null] as double precision[])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have the following code. double *return_array(void) { double foo[2]; foo[0] =
Say I have the following double-quoted string in Ruby: Person's name Does the single
Say you have the following: foo(x: String)(y: Int): Int foo(x: String)(y: Double): Int Scala
Let's say I have a data structure like the following: Camera { double x,
Let's say I have the following function: Function myFunction(j As Integer) As Double myFunction
Let’s say I have double length that can be either a real length or
Let's say I have two maps: typedef int Id; std::map<Id, std::string> idToStringMap; std::map<Id, double>
I have this 2D array (say double[10][10]) which contain some 1.0 and 10.0, rest
Say i have a few fields like the following: abd738927 jaksm234234 hfk342 ndma0834 jon99322
Lets say I have the double 42.433243 and I would like to convert it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.