dbTalk Databases Forums  

Libpq.dll

comp.databases.postgresql comp.databases.postgresql


Discuss Libpq.dll in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Enzo Campanella
 
Posts: n/a

Default Libpq.dll - 07-31-2008 , 03:03 PM






Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?

Thank you.
Enzo.


Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM






Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #3  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #4  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #5  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #6  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #7  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #8  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #9  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Libpq.dll - 08-01-2008 , 01:58 AM



Enzo Campanella <v.campanella (AT) tin (DOT) it> wrote:
Quote:
Hello everyone.

I'm trying to interface my program in Visual Object so native postgreSQL
through Libpq.dll.
I have a problem with the dll in question, namely:
if I have a field of table type varchar (30), how do I know the actual
length of the field?
The function PQgetlenght me back the length of the string contained in the
field and not the maximum size of the field if field = 'Campanella' me back
10 and not 30.
other problem with the numeric.
A field declared numeric (10.2), how do I know the length and number of
decimal places?
What role should I use?
I don't understand that last question about the role.

To find out specifics about the column definitions of a table, consult
the table information_schema.columns, like this:

CREATE TABlE laurenz.testtab (
id integer PRIMARY KEY,
val varchar(20),
num numeric(10,2)
);

SELECT column_name,
character_maximum_length,
numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_name = 'testtab' AND table_schema = 'laurenz';

Yours,
Laurenz Albe


Reply With Quote
  #10  
Old   
Enzo Campanella
 
Posts: n/a

Default Re: Libpq.dll - 08-02-2008 , 03:39 PM



Thank you.
I wanted to know how to do it by using the functions of the library
Libpq.dll.
However there are managed with the combined use PQfType and PQfmod.
I managed to find the primary key with the following method:

METHOD IsPrimaryKey(nField) CLASS PgSqlTable
LOCAL pRes AS PTR
LOCAL nPos AS LONGINT
LOCAL cSelect AS STRING

cSelect := "SELECT ordinal_position "+;
" FROM information_schema.key_column_usage "+;
" WHERE table_name='"+Lower(SELF:TableName)+"'"

pRes := PQexec(oSQLConnPgSQL,String2Psz(cSelect))
IF pRes != NULL_PTR
nPos := Val(Psz2String(PQgetvalue(pRes,0,0)))
IF nPos == nField
RETURN TRUE
ENDIF
ENDIF
RETURN FALSE

We have not managed to find the select field to find the serial
autoincrement.
Some straight?

Enzo.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.