[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: Problem with recreation of session_info table
It works in my code, I did it as you suggested:
----------
User::User () : db("DSN=PostgreSQL;UID=sergey;PWD=;DATABASE=uu")
{
db.open();
}
User::~User ( )
{
db.close();
}
bool User::setSessionInfo(string login, string password, int server,
string sessionid)
{
try {
CQuery qryInsert(&db,"select login('"+login+"', '"+password+"',
"+lexical_cast<string>(server)+")");
qryInsert.exec();
}
catch (exception& e) {
cout<<"\nError: " <<e.what();
return false;
}
return true;
}
------------------
and it worked.
The problem started when I tested logout() proc manually, maybe that was
the wrong thing to do.
Now one thing is unclear. Looks like my code does the job, but when I run
"select * from session_info" manually it says:
ERROR: relation "session_info" does not exist
Is it suppose to be like that since it's 2 different sessions, one in my
code and another is "manual one"?
> Can you send me the code that has that problem, as a tar archive?
>
> 2007/3/19, sergey@total-knowledge.com <sergey@total-knowledge.com>:
>>
>> After I used logout() stored procedure I'm unable to recreate
>> session_info
>> table.
>> Here is the error message which I get after
>> select login ('sergey', 'password12', 1);
>> -----
>> ERROR: relation with OID 37226 does not exist
>> CONTEXT: SQL statement "INSERT INTO session_info SELECT pl_id,
>> pl_first_name || ' ' || pl_last_name, $1 FROM person_list WHERE
>> pl_login
>> = $2 "
>> PL/pgSQL function "login" line 27 at SQL statement
>> -----
>>
>> I did some research and I found out that it could be related to PL/PgSQL
>> caching of function scripts. The solution is to use EXECUTE for
>> temporary
>> table access. This should cause the query to be reparsed every time.
>> Here is what I did:
>>
>> prepare testplan (varchar, varchar, int) as select login($1, $2, $3);
>> execute testplan('sergey', 'password12', 1);
>>
>> but got exactly the same error message as above.
>>
>> I guess it could be a mismatch between tables in DB b/c of 'drop' that
>> logout() proc performs.
>> Do we need to use prepared statements in stored procs to avoid this
>> problem?
>>
>> Another thing, I need session_info table with si_session column. I'll
>> pass
>> session id as a parameter, as we agreed.
>>
>>
>>
>>
>
>
> --
> Alexey Parshin,
> http://www.sptk.net
>