since tables & cursors don't stay open between pages...

Topics: Developer Forum, User Forum
Mar 21, 2012 at 10:50 PM

I'm working on a site where a user might need to make a single payment that would apply to one or more Locations (maybe their home, a business, a rental property, etc.). First off, I've created a page that displays each Location with its Balance, along with a Payment field for each Location. The Payment field is populated with the Balance by default, but the user can edit the Payment for each one, and a Total Payment is displayed at the bottom of the page. When they've keyed in all of the payments, the user will click a "Pay Bill" button at the bottom of the page, which will send them to a second page where they enter their Credit Card data, etc., and then Submit.

If I was doing this in VFP, I would simply create a cursor with a LocationId and Payment field, populate it with each LocationId & Payment, then keep it open between forms. However, since tables & cursors don't persist between pages, I'm having trouble getting a handle on how to do this properly with AVFP. I know I can assign variables to the Session object, so should I just create two variables (one for the LocationId's and the other for the Payments) that are comma-delimited lists, and store them to the Session object? Then I could use GetWordCount() and GetWordNum() in the second page to retrieve each LocationId and Payment pair? Or is there a better way to handle something like this? I'm just looking for a best practice way of performing such a task, since I'm new to AVFP.

Mar 21, 2012 at 11:33 PM

I've been creating a small session dbf in the AVFPinit Function (all the way at the bottom of main)

ASP assigns a SessionId cookie - so I use that as a controlling DBF

At the top of every webpage, I have something like:

SessDBF  = LEFT(UPPER(oRequest.oRequest.cookies("ASP.NET_SessionId").ITEM()),15)

SessFile = oProp.DataPath + SessDBF + [.DBF]
IF .NOT. USED(SessDBF)
   SELECT 0
   USE (SessFile)
ELSE
  SELECT (SessDBF)

ENDIF

 

*NOW* I have something I can hang my hat on..

 

 

Mar 23, 2012 at 9:58 PM

So you're creating tables on disk instead of cursors? How do you ensure those tables get deleted from the disk later?

Mar 26, 2012 at 2:57 PM

Sorry, I did not understandYou can create a cursor on a page and it will stay open and visible to other pages during a session?
Be possible, as this should be done?

 

Portuguese of Brazil:

Desculpe, eu não entendi. É possível criar um cursor em um pagina e este permanecer aberto e visível as demais páginas durante uma sessão ?
Ser for possível, como isto deve ser feito ?

Mar 26, 2012 at 4:21 PM
EdsonLG wrote:

Sorry, I did not understandYou can create a cursor on a page and it will stay open and visible to other pages during a session?
Be possible, as this should be done?

 

If I understand it correctly, the answer is no--you cannot create a cursor in one page and have it stay open and visible in another page.

Apr 5, 2012 at 4:08 AM

It's totally possible, using a temp table as a way

Just put this on the end of your sql statment

 ..  .. . . .. . INTO TABLE temp_table.dbf

Then you can use the temp table on other pages.

 

 

Apr 5, 2012 at 4:10 AM

Coloca isto no fim do seu sql

.. .. . . .. . INTO TABLE temp_table.dbf

Criara uma tabela temporaria, que podera ser vista por outras paginas e ate mesmo outros programas, mas nao é um cursor e sim uma tabela com o conteudo de seu cursor.

Abcs