You got the suggestion using currval already so here's one alternative.
SELECT NEXTVAL('"orderid_sequence_name"');
Assume this value is $val then do
INSERT INTO orderstemp(orderid,...) VALUES ($val, ...);
I'm not sure if this is generally used, but this works and sometimes this
way is convenient for batch processing.
>SELECT @@identity as orderid
My 0.02$.
Regards,
Ben Kim
Developer
College of Education
Texas A&M University