PDA

View Full Version : Why do I get no results?


dwilliams
09-11-02, 11:55
This is a literal cut and past from the docs

-- Set up and use a cursor:

BEGIN WORK;
DECLARE liahona CURSOR FOR SELECT * FROM films;

-- Fetch first 5 rows in the cursor liahona:
FETCH FORWARD 5 IN liahona;

-- Fetch previous row:
FETCH BACKWARD 1 IN liahona;

-- close the cursor and commit work:

CLOSE liahona;
COMMIT WORK;

It says that it runs ok but how do I view the results?

Thanks

Dave

eperich
09-11-02, 16:39
This cannot be.
I have tested this.
Do you have a table named films?

Are there rows in it?

I was testing this on 7.2.1 in RH7.2

dwilliams
09-11-02, 16:39
Originally posted by eperich
This cannot be.
I have tested this.
Do you have a table named films?

Are there rows in it?

I was testing this on 7.2.1 in RH7.2

The table is users ( I forgot to edit this post ) and yes there are 9 records.

eperich
09-11-02, 17:00
Is there a script that executes this statemtns or do you type it manuallly in psql?

dwilliams
09-11-02, 17:04
I am running it through pgadmin II SQL query screen. I will try it from the command prompt.

Thanks

Dave

EDIT: Ok it works fine at the psql level.

So now my question is how do I return that recordsetup to the calling application level?

eperich
09-11-02, 17:14
What do you want exactly?

begin work;
declare cursor ...

FETCH FORWARD 5 cursor;

commit;

get the rows of the fetch?

dwilliams
09-11-02, 17:17
Originally posted by eperich
What do you want exactly?

begin work;
declare cursor ...

FETCH FORWARD 5 cursor;

commit;

get the rows of the fetch?

Yes. Ideally I would like to contain the entire thing in a function and return a pointer to a cursor that contains the recordset but failing that yes that is exactly what I want to do.

eperich
09-11-02, 17:22
I don't know how you can achieve this but I think only way is that this fetch is the same as a select and you can get the data in the same way as you can get it from select.

I'm no ASP and ODBC guru so I can't test this theory
:D

dwilliams
09-11-02, 17:26
ok so at the psql level how do I make this a function and return only the cursor object.

The crux of the problem is a limited amount of data that ODBC will pass ( 2K I think ) and my queries would exceed that.

Thanks again.

Dave

eperich
09-11-02, 17:33
now I understand you want to return the referenc of the cursor from the function

Sorry. I don't know if this is possible.

The only chance you have is to post an entry in the pgsql-sql list.
Josh Berkus may know this. I think he is the pl/pgsql expert

dwilliams
09-11-02, 17:37
Originally posted by eperich
now I understand you want to return the referenc of the cursor from the function

Sorry. I don't know if this is possible.

The only chance you have is to post an entry in the pgsql-sql list.
Josh Berkus may know this. I think he is the pl/pgsql expert

Ok. great thank you for all your help.

One last question :)

Where do I find the pgsql-sql list? I have been all over the web and postgresql documentation is all over the place but mostly redundant. So just to avoid me finding 3000 identical locations calling themselves a pgsql-sql list could you give me a primary url to register and post at.

Thanks again.

Dave

eperich
09-11-02, 17:44
usenet below :D
comp.databases.postgresql.sql

or the mailing list

Lists near the bottom of the page (http://www.de.postgresql.org/users-lounge/index.html)