forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using "returning" in a Rdb Insert statement ?

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Sat Jul 05, 2008 11:03 pm    Post subject: Using "returning" in a Rdb Insert statement ? Reply with quote

Hi.
When trying an INSERT statement using the Rdb interface in Python,
using the RETURNING <col> option, I always get :

rdb._rdb_exceptions.Error: (-1, '%SQL-F-SYNTAX_ERR, Syntax error', 'RR000')

If I take the RETURNING <col> out, it works just OK.

This statement work OK :

"insert into sched_template (template_id) values (template_id_seq.nextval)"

This gives the error :

"insert into sched_template (template_id) values (template_id_seq.nextval) returning template_id"

Using SQL interactive this works fine.

Maybe this just isn't supported through the interface that Python uses ?
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 632

PostPosted: Mon Jul 07, 2008 2:31 pm    Post subject: Reply with quote

This is a Rdb SQL Dynamic problem.

A workaround:

Code:

Statement.execute('declare :id integer')
sti = Statement.execute("insert into sched_template (template_id) values (template_id_seq.nextval) returning template_id into :id")
sti.execute()
sts = Statement("select :id from rdb$database")
sts.execute()
print sts.fetchall()[0][0]


I do something like this into Rdb interface for Django.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Tue Jul 08, 2008 7:44 pm    Post subject: Reply with quote

Ah yes, that's a nice workaround without to much overhead.

I also tried simply with a "select max(template_id) from sched_template"
in the second statement, but that is of course a bit more overhead.

Anyway, it was not *my* fault then... Smile Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group