KB-39000: Inserting a record into a PostgreSQL Database.

Question:

How can I insert a record into a PostgreSQL Database?

Solution:

To do so, you must create the connection via scripts, since this Database is not native to E3. For example:

‘Creates the connection to the database
Set db_con = CreateObject(“ADODB.Connection”)

str_con = “Driver={PostgreSQL ODBC Driver(ANSI)};Server=localhost;Port=5432;Database=postgres;Uid=postgres;Pwd=Abcd1234”

db_con.Open str_con

‘Creates the recordset
Set rs = CreateObject(“ADODB.Recordset”)
rs.Source = “INSERT INTO tabelateste3 VALUES (‘1/1/1958’, ‘0’)”
rs.ActiveConnection = db_con
rs.CursorType = 1 ‘adOpenKeyset
rs.LockType = 3 ‘adLockOptimistic
rs.Open

NOTE: for this example, consider this table as having already been created in the Database.

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Deixe seu Comentário

Seu endereço de e-mail não será publicado. Campos marcados com asterisco são obrigatórios *