NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: debraballenger on December 22, 2012, 03:40:39 PM

Title: Why does this code not work in a NetTalk webserver?
Post by: debraballenger on December 22, 2012, 03:40:39 PM
Hi All,

I have this code that runs fine in my windows app, but for some reason when it is called from a NetTalk webserver app it does some crazy stuff.  I am running this on an MSSQL backend, NetTalk 7, C8 9661.

This is the code

TCT:Guid=''
Set(TCT:TCTGUIDKey,TCT:TCTGUIDKey)
Loop
    IF Access:Ticket_Charge_Types.Next()
        BREAK
    END
    !Do Some stuff
END

The statement sent to SQL for the Ticket Charge types is this... notice the where clause.

SELECT GUID,R_TYPE,AUTOPOPULATE,AMOUNT,CANTDELETE,CANTEDIT,CHARGETYPE,PAYCOMMISSIONS,PROFITABILITY FROM TICKET_CHARGE_TYPES WHERE 0 = 1

I have this code on a dictionary trigger after Insert, and it gets the correct records from a normal clarion app, but when called from my nettalk web server app it gets no records.

Does anyone have ideas on how to resolve it?

Thanks!
Title: Re: Why does this code not work in a NetTalk webserver?
Post by: Rene Simons on December 23, 2012, 03:16:10 AM
Hi,

I have the same sort of problem when doing this operation on a TPS file.
Only difference is that I do an additional key-check.

recordkeyField = searchField
set(recordKey, recordKey)

loop until access:file.next() or recordKeyField <> searchField
   !Do some stuff
end

The key fits exactly, but no records are read at all.

Anyone??

Regards and merry Xmas
Rene Simons
Title: Re: Why does this code not work in a NetTalk webserver?
Post by: JPMacDonald on December 23, 2012, 12:17:46 PM
Rene,

I have come across this and it is odd that in come cases your code will work and in others it does not, I cannot explain it.

It may work for you if you change the syntax to use the legacy style of coding:

OPEN(yourFile)
keyField = searchField
SET(recKey,RecKey)
LOOP
   NEXT(yourFile)
   IF Errorcode() THEN BREAK.
   IF reckeyField <> searchField THEN BREAK.
   !DO your stuff
END
CLOSE(yourFile)

CAUTION: If this works for you, test your app throughly, I tried and it worked but after a bit of use my app just hangs, not sure if its related to this code or not ;-(

Regards

Parker
Title: Re: Why does this code not work in a NetTalk webserver?
Post by: terryd on December 23, 2012, 09:19:41 PM
Rene
If this is code called from inside a nettalk form then you need to explicitly open and close the tables you are using e.g
Access:Ticket_Charge_Types.Open()
Access:Ticket_Charge_Types.Usefile()
TCT:Guid=''
Set(TCT:TCTGUIDKey,TCT:TCTGUIDKey)
Loop UNTIL Access:Ticket_Charge_Types.Next()
        BREAK
    END
    !Do Some stuff
END
Access:Ticket_Charge_Types.Close()
Title: Re: Why does this code not work in a NetTalk webserver?
Post by: estadok on December 25, 2012, 03:34:41 AM
Hi!

Also, shall use you (c) Yoda

{PROP:SQL} like:

p_web._OpenFile(Ticket_Charge_Types)
Ticket_Charge_Types{PROP:SQL} = 'select * from Ticket_Charge_Types where something = '&something or p_web.GSV('something')
NEXT(Ticket_Charge_Types)
Loop
      IF ERRORCODE() THEN  BREAK .
    !Do Some stuff
.
p_web._CloseFile(Ticket_Charge_Types)