Results 1 to 4 of 4

Thread: Insert into array column

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Insert into array column

    I have a column with type integer array (postgresql). But I don't know how to insert data with bindValue. I tried QVariantList, but failed.


    Qt Code:
    1. QVariantList nomor;
    2. nomor << 1 << 2 << 3 << 4;
    3.  
    4. sql.bindValue(":intarraycolumn", nomor);
    To copy to clipboard, switch view to plain text mode 

    Need your help

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Insert into array column

    You need to construct a string that will look like this one:
    { youInt1, yourInt2, ..., your intN } and bound it.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    1

    Default Re: Insert into array column

    you can try something like:


    Qt Code:
    1. QString nomor;
    2. nomor.append("(");
    3. for (int i=0; i < n; i++)
    4. {
    5. nomor.append(QString::number(i));
    6. if (i != n-1)
    7. {
    8. nomor.append(", ");
    9. }
    10. }
    11. nomor.append(")");
    12.  
    13. sql.bindValue(":intarraycolumn", nomor);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Insert into array column

    PostgreSQL's doc says it should be "{...}", not "(...)".
    I'm a rebel in the S.D.G.

Similar Threads

  1. Replies: 1
    Last Post: 3rd October 2009, 05:20
  2. Replies: 0
    Last Post: 4th December 2008, 06:48
  3. Replies: 0
    Last Post: 25th June 2008, 19:36
  4. Replies: 0
    Last Post: 10th November 2006, 14:46
  5. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 09:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.