Home » U++ Library support » U++ SQL » PostgreSQL example does not save data to database
PostgreSQL example does not save data to database [message #20572] |
Tue, 24 March 2009 05:04  |
rtmex
Messages: 9 Registered: March 2009 Location: Puebla, MEXICO
|
Promising Member |
|
|
Hi, I recreate the PostgreSQL example, just with another table
It works ok, but the data is not saved to the PostgreSQL table when I check it with pgAdmin III.
The table in the database has more fields but I'm just using 3 fields in my code, just to test.
This is my InsertTestData function
bool prueba_Postgres::InsertTestData()
{
Sql sql(m_session);
sql.ClearError();
sql.Begin();
sql * Delete(estacion);
sql * Insert(estacion)
(cve_estacion, 1)
(nombre_estacion, "ESTACION 1")
(siglas, "SIGLAS 1")
;
sql * Insert(estacion)
(cve_estacion, 2)
(nombre_estacion, "RADIO ORO")
(siglas, "XH-ORO")
;
sql * Insert(estacion)
(cve_estacion, 3)
(nombre_estacion, "ESTACION 3")
(siglas, "SIGLAS 3")
;
if(!OkCommit(m_session, "Unable to insert test data."))
return false;
return true;
}
This is my .sch file
TABLE_ (estacion)
INT_ (cve_estacion) PRIMARY_KEY
STRING_ (nombre_estacion, 30) INDEX
STRING_ (siglas, 10)
END_TABLE
Tha SqlArray show the data but the data is not saved to the table in the database
What could by the problem?
Thanks in advance
|
|
|
|
Re: PostgreSQL example does not save data to database [message #20593 is a reply to message #20579] |
Tue, 24 March 2009 17:39   |
rtmex
Messages: 9 Registered: March 2009 Location: Puebla, MEXICO
|
Promising Member |
|
|
Thanks,
m_session.SetTrace() is in this function
bool prueba_Postgres::OpenDB()
{
if(!m_session.Open("host=localhost dbname=radioactivo user=postgres password=test"))
{
Exclamation(Format("Error in open: %s", DeQtf(m_session.GetLastError())));
return false;
}
m_array.SetSession(m_session);
#ifdef _DEBUG
m_session.SetTrace();
#endif
//schema
Progress p;
p.SetText(t_("Creating _DEBUG database"));
SqlSchema sch(PGSQL);
StdStatementExecutor se(m_session);
All_Tables(sch);
if(sch.ScriptChanged(SqlSchema::UPGRADE))
PostgreSQLPerformScript(sch.Upgrade(),se, p);
if(sch.ScriptChanged(SqlSchema::ATTRIBUTES))
{
PostgreSQLPerformScript(sch.Attributes(),se, p);
}
if(sch.ScriptChanged(SqlSchema::CONFIG))
{
PostgreSQLPerformScript(sch.ConfigDrop(),se, p);
PostgreSQLPerformScript(sch.Config(),se, p);
}
sch.SaveNormal();
return true;
}
I tryed with the #ifdef _DEBUG and #endif lines commented and I also tryed compiling it in Release mode, but still the info is not saved
|
|
|
Re: PostgreSQL example does not save data to database [message #20601 is a reply to message #20572] |
Wed, 25 March 2009 18:16   |
rtmex
Messages: 9 Registered: March 2009 Location: Puebla, MEXICO
|
Promising Member |
|
|
This is the log file
* /home/salomon/upp/out/GCC.Debug.Debug_full.Gui.Shared/prueba _Postgres 25.03.2009 11:11:23, user: salomon
begin
delete from estacion
insert into estacion(cve_estacion, nombre_estacion, siglas) values (1, 'ESTACION 1', 'SIGLAS 1')
insert into estacion(cve_estacion, nombre_estacion, siglas) values (2, 'RADIO ORO', 'XH-ORO')
insert into estacion(cve_estacion, nombre_estacion, siglas) values (3, 'ESTACION 3', 'SIGLAS 3')
commit
select cve_estacion, cve_estacion, nombre_estacion, siglas from estacion order by nombre_estacion
I don't see any problem, it seems that the insert statements are ok, and there is the commit sentence at the end. I don't know why the information is not saved in the table
Any clue?
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 12:48:21 CEST 2025
Total time taken to generate the page: 0.02727 seconds
|