PGSQL insert data to a oid column using SOCI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PGSQL insert data to a oid column using SOCI

Chamath Sajeewa
Hi All,
I am using c++ with soci to insert oid values to a table.

Table structure is as follows,

CREATE TABLE test_table (

       key varchar(200NULL,

       value oid NULL

);


Value is a large xml file given as std::string.
What is the correct way to insert oid data using binding variables.
Used code snippet is given below which is not working.

std::string key = "test key";
std::string value = "test xml";
std::string sql = "insert into test_table(key,value) values (:KEY, :VALUE)
soci:use(key);
soci:use(value);

soci::statement st(session);
st.prepare(sql)
st.execute()

Thanks!



--
G.K.M.C Sajeewa

Reply | Threaded
Open this post in threaded view
|

RE: PGSQL insert data to a oid column using SOCI

David Raymond

https://www.postgresql.org/docs/current/datatype-oid.html

 

Are you sure OID is what you really want? An OID is basically an integer. Not something you can store text or xml data into.

 

 

From: Chamath Sajeewa <[hidden email]>
Sent: Wednesday, July 29, 2020 2:17 PM
To: [hidden email]
Subject: PGSQL insert data to a oid column using SOCI

 

Hi All,

I am using c++ with soci to insert oid values to a table.

 

Table structure is as follows,

 

CREATE TABLE test_table (

       key varchar(200NULL,

       value oid NULL

);

 

Value is a large xml file given as std::string.

What is the correct way to insert oid data using binding variables.

Used code snippet is given below which is not working.

 

std::string key = "test key";

std::string value = "test xml";

std::string sql = "insert into test_table(key,value) values (:KEY, :VALUE)

soci:use(key);

soci:use(value);

 

soci::statement st(session);

st.prepare(sql)

st.execute()

 

Thanks!

 


 

--

G.K.M.C Sajeewa

 

Reply | Threaded
Open this post in threaded view
|

Re: PGSQL insert data to a oid column using SOCI

Chamath Sajeewa
What is the correct data type to be used for large objects then?

On Thu, 30 Jul 2020, 00:31 David Raymond, <[hidden email]> wrote:

https://www.postgresql.org/docs/current/datatype-oid.html

 

Are you sure OID is what you really want? An OID is basically an integer. Not something you can store text or xml data into.

 

 

From: Chamath Sajeewa <[hidden email]>
Sent: Wednesday, July 29, 2020 2:17 PM
To: [hidden email]
Subject: PGSQL insert data to a oid column using SOCI

 

Hi All,

I am using c++ with soci to insert oid values to a table.

 

Table structure is as follows,

 

CREATE TABLE test_table (

       key varchar(200NULL,

       value oid NULL

);

 

Value is a large xml file given as std::string.

What is the correct way to insert oid data using binding variables.

Used code snippet is given below which is not working.

 

std::string key = "test key";

std::string value = "test xml";

std::string sql = "insert into test_table(key,value) values (:KEY, :VALUE)

soci:use(key);

soci:use(value);

 

soci::statement st(session);

st.prepare(sql)

st.execute()

 

Thanks!

 


 

--

G.K.M.C Sajeewa

 

Reply | Threaded
Open this post in threaded view
|

Re: PGSQL insert data to a oid column using SOCI

David G Johnston
On Wednesday, July 29, 2020, Chamath Sajeewa <[hidden email]> wrote:
What is the correct data type to be used for large objects then?

Please don’t top-post.

If you want to use large objects you should follow the examples in the documentation.  Specifically:


Though as you are using a client library it should be telling you how it implements the large object api which is usually quite different than its SQL api.

David J.

Reply | Threaded
Open this post in threaded view
|

Re: PGSQL insert data to a oid column using SOCI

Stephen Frost
In reply to this post by Chamath Sajeewa
Greetings,

* Chamath Sajeewa ([hidden email]) wrote:
> What is the correct data type to be used for large objects then?

I'd suggest you seriously consider if you can just use a 'bytea' for the
object rather than the actual large object system.  'bytea' is limited
to 1GB, though you could chunk up larger objects if needed.

Thanks,

Stephen

signature.asc (836 bytes) Download Attachment