Unix Technical Forum

Re: [compgeneral] I cant get the description or default value of a field

This is a discussion on Re: [compgeneral] I cant get the description or default value of a field within the pgsql Interfaces odbc forums, part of the PostgreSQL category; --> Forwarding to official PostgreSQL's ODBC mailing list... -----Original Message----- From: compgeneral@googlegroups.com [mailto:compgeneral@googlegroups.com] On Behalf Of serkane Sent: Monday, June ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces odbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 03:01 AM
Gurjeet Singh
 
Posts: n/a
Default Re: [compgeneral] I cant get the description or default value of a field

Forwarding to official PostgreSQL's ODBC mailing list...



-----Original Message-----
From: compgeneral@googlegroups.com [mailto:compgeneral@googlegroups.com]
On Behalf Of serkane
Sent: Monday, June 12, 2006 5:56 PM
To: compgeneral
Subject: [compgeneral] I cant get the description or default value of a
field


Hi everyone

excuse me for my english is not very well

I use the asp, vb 6 (with sp6) and .net vb to development. And I use
the postgres_odbc driver to connect the postgres server.

I need to know a field description of a table. But I can not get the
neither field description or field default value.

to learn is the code wrong or right, I've tried it another db
connection (ex. SQL2K, ORA, Foxpro). And there wasnt error. the code
has run corectly.

I wonder if the postgres doesnt provide these properties by the ADO.

thanks in advance


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "compgeneral" group.
To post to this group, send email to compgeneral@googlegroups.com
To unsubscribe from this group, send email to
compgeneral-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/compgeneral
-~----------~----~----~----~------~----~------~--~---


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 03:01 AM
Ludek Finstrle
 
Posts: n/a
Default Re: [compgeneral] I cant get the description or default value of a field

> excuse me for my english is not very well

That's no such problem in english. But I see few information from you :-(
What's PgSQL version, psqlodbc version, how you try get the informations?

> I use the asp, vb 6 (with sp6) and .net vb to development. And I use
> the postgres_odbc driver to connect the postgres server.
>
> I need to know a field description of a table. But I can not get the
> neither field description or field default value.


Could you send us code snipset (how you try to get the information)?
BTW mylog output could be interesting too.

Regards,

Luf

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 03:01 AM
serkane
 
Posts: n/a
Default Re: I cant get the description or default value of a field

I Use the version 8.1.4 of PostgreSQL on Windows 2003 Server as OS.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-16-2008, 03:01 AM
serkane
 
Posts: n/a
Default Re: I cant get the description or default value of a field

Set Rs = Cn.OpenSchema(adSchemaColumns, Array(Empty, Empty, TableName,
Empty))
Do While Not Rs.EOF
Debug.Print Rs("ORDINAL_POSITION")
Debug.Print Rs("COLUMN_NAME")
Debug.Print Rs("DATA_TYPE")
Debug.Print Rs("COLUMN_DEFAULT")
Debug.Print Rs("IS_NULLABLE")
If IsNull(Rs("CHARACTER_MAXIMUM_LENGTH")) = False Then
Debug.Print Rs("CHARACTER_MAXIMUM_LENGTH")
Debug.Print "0" '** Num_scale=0
Else
Debug.Print Rs("NUMERIC_PRECISION")
Debug.Print Rs("NUMERIC_SCALE")
End If
Debug.Print Rs("DESCRIPTION")
Debug.Print Rs("DISPLAY_SIZE")
Debug.Print Rs("COLUMN_HASDEFAULT"), Rs("COLUMN_DEFAULT")
Rs.MoveNext
Loop
Call RsClose

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-16-2008, 03:01 AM
Campbell, Greg
 
Posts: n/a
Default Re: [compgeneral] I cant get the description or default valueof a field

There is a technique at the ADO (VB) level. I do not know if the lower level ADO calls and the driver
support what your are trying to do.

Code Level:
================================================== ==================================================
Dim strConn as String
Dim conn As ADODB.Connection
Dim rs As Recordset
Dim fld As Field


strConn = _
"DRIVER={PostgreSQL};SERVER=my_sever_address;port= 5432;DATABASE=my_database_name;UID=my_user_id;PWD= my_password;"

Set conn = New Connection
conn.Open strConn

Debug.Print "The connection is open"

'this will query for the schema for a table named employees
'see MSDN for specification on parameters and the array
'return a recordset contain information about the schema
'there is a record for each schema item , in this case 1 per field
Set rs = conn.OpenSchema(adSchemaColumns, Array("", "", "employees"))

If Not rs.EOF Then
Debug.Print "There are records"
Do While Not rs.EOF
'each field is a different schema descriptor for the current employee field
For Each fld In rs.Fields
'just comment out the If and End If so see all available schema descriptor field
If (fld.Name = "COLUMN_NAME") Or _
(fld.Name = "COLUMN_DEFAULT") Or _
(fld.Name = "FIELD_TYPE") Or _
(fld.Name = "DESCRIPTION") Then

Debug.Print fld.Name & ":" & vbTab & fld.Value

End If
Next
rs.MoveNext 'each record is a field in employee
Debug.Print "-----------------------------"
Loop
Else
Debug.Print "No records found"
End If

rs.Close

Set rs = Nothing

conn.Close

Set conn = Nothing
============= end of code snippet ================================================== =======
This code should provide the schema information, particularly the column name, default, field_type ( a
number which must be interpreted using the ADO DataType Enum see MSDN or use Object Browser),
and the Description.

In practice the driver I am using did not return the COLUMN_DEFAULT value, and I do not have many tables
with a description attached to the field. I am rather ruthless about using obvious column names. If you
want to dig into what gets returned into the schema, you can of course turn on ODBC tracing, and the
Postgresql Driver setting for MyLog. You may uncover an ODBC driver feature that has a bug or is not
supported in the existing drivers.



Gurjeet Singh wrote:

> Forwarding to official PostgreSQL's ODBC mailing list...
>
>
>
> -----Original Message-----
> From: compgeneral@googlegroups.com [mailto:compgeneral@googlegroups.com]
> On Behalf Of serkane
> Sent: Monday, June 12, 2006 5:56 PM
> To: compgeneral
> Subject: [compgeneral] I cant get the description or default value of a
> field
>
>
> Hi everyone
>
> excuse me for my english is not very well
>
> I use the asp, vb 6 (with sp6) and .net vb to development. And I use
> the postgres_odbc driver to connect the postgres server.
>
> I need to know a field description of a table. But I can not get the
> neither field description or field default value.
>
> to learn is the code wrong or right, I've tried it another db
> connection (ex. SQL2K, ORA, Foxpro). And there wasnt error. the code
> has run corectly.
>
> I wonder if the postgres doesnt provide these properties by the ADO.
>
> thanks in advance
>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "compgeneral" group.
> To post to this group, send email to compgeneral@googlegroups.com
> To unsubscribe from this group, send email to
> compgeneral-unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/compgeneral
> -~----------~----~----~----~------~----~------~--~---
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com