Blocking single and double quotes in GET

This forum is for eXpress++ general support.
Message
Author
Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Blocking single and double quotes in GET

#1 Post by Andy Edward »

Hi Roger,

Background:
- We are using PostgresSQL with xBase++ 2.00.685 and Express++ 263
- DbCreateIndex() on fields containing single quote or double quotes fails in ISAM mode.
- It fails because it is using SQL's UPDATE command to populate the index column. Here is the error output from pg_log

Code: Select all

2016-05-18 14:10:31 MYT ERROR:  syntax error at or near "EQUITY" at character 56
2016-05-18 14:10:31 MYT STATEMENT:  UPDATE ac SET __order_acnme_acnme='TOTAL SHAREHOLDERS' EQUITY              100000                    1@0000000001' WHERE __RECORD=1;
Take note the single quote after "SHAREHOLDERS".

- We have contacted Alaska and they verified that this is a bug and opened a PDR here http://www.alaska-software.com/scripts/ ... PDRID=6724

While waiting for this issue to be resolved (if it's even being looked at), is there any way to block the DCGETs from accepting single quote and double quotes?

If I may give a suggestion, an option for DCGET like

Code: Select all

DCGET ... NOQUOTE
to indicate the GET to not accept single and double quotes, that would be ideal.

Note: If anyone is thinking about moving forward with Postgres and Xbase, kindly click the PDR link to boost the priority

Regards,

Andy

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Blocking single and double quotes in GET

#2 Post by skiman »

Hi,

Maybe just change your indexkey? If you use a user defined function in your index, you can strip/replace these characters. I suppose this will be the fastest way to solve this.
Best regards,

Chris.
www.aboservice.be

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: Blocking single and double quotes in GET

#3 Post by Andy Edward »

Hi Chris,

Thanks for your suggestion.

I've also tested using User Defined Index, it does strip all the single quote and the INDEX ON command ran just fine.
But another problem appears when doing a SEEK. It will not find the record that I want. Because the content I'm searching still has a single quote but the index have no single quote.

So using a user defined index will only solve the INDEX ON part. But when it comes to SEEK time, it will not find the record

Regards,

Andy

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Blocking single and double quotes in GET

#4 Post by skiman »

Hi,

I always use the same function before my seek.
customer->(dbseek(strip( cSeek)))
Best regards,

Chris.
www.aboservice.be

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: Blocking single and double quotes in GET

#5 Post by Andy Edward »

Hi Chris,

Just like avoiding any code rewrites, which entails hundreds of hours of testing, we would not prefer to change the operational code.

We appreciate your solution, but as this is a deployed software in dozens of companies, we would prefer a less "invasive" solution, rather than going back and do code rewrites.

The current code is tested and working, so to circle back to the original question, if there is a way to block the GET from accepting single and double quotes, it would be ideal for our case.

Regards,

Andy

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Blocking single and double quotes in GET

#6 Post by Tom »

Hi, Andy.

Build your own "NOQUOTE"-option. This works for single quotes:

Code: Select all

#xtranslate  NOQUOTE => ;
             KEYBLOCK {|x,y,o|CheckQuotes(x,y,o)}

#include "dcdialog.ch"
#include "appevent.ch"
#include "inkey.ch"

#pragma library ("dclipx.lib")

FUNCTION Main()
LOCAL GetList := {}, c := Space(30)

@ 1,1 DCSAY 'Test:' GET c SAYSIZE 10 NOQUOTE

DCREAD GUI FIT ADDBUTTONS

RETURN NIL

FUNCTION CheckQuotes(x,y,o)
IF Chr(x) == "'"
  PostAppEvent(xbeP_Keyboard,xbeK_BS,y,o)
ENDIF
RETURN NIL

PROC AppSys() ; RETURN
Edit: It works for typed single quotes. It does not work for pasted textes. You may change "CheckQuotes" and work with EditBuffer(), SetData() a.s.o. there.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Blocking single and double quotes in GET

#7 Post by Cliff Wiernik »

You could also add a custom keyhandler that would strip the quote for get fields.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Blocking single and double quotes in GET

#8 Post by rdonnay »

is there any way to block the DCGETs from accepting single quote and double quotes?
Try this:

Code: Select all

@ .. DCGET .. KEYBLOCK {|a,b,o|IIF(a==Asc('"') .OR. a == Asc("'"),o:undo(),nil)}
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Blocking single and double quotes in GET

#9 Post by Tom »

Undo() will erase the get contens completely. Try my suggestion; it works fine. Just add the characters you want to delete to the function.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Blocking single and double quotes in GET

#10 Post by rdonnay »

Undo() will erase the get contens completely. Try my suggestion; it works fine. Just add the characters you want to delete to the function.
Oops, I forgot about that, I was thinking o:get:delleft(), but that doesn't work right either. Your solution is best.
The eXpress train is coming - and it has more cars.

Post Reply