Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 16 total
Thread Interesting problem
Tue, Apr 8 2014 3:38 PMPermanent Link

Ben Sprei

CustomEDP

The SKU field value is 4563 25' 90
select * from InvMas where sku = '4563 25' 90'

if I run the above statement I will get an error.  Is there any workaround
???

Tue, Apr 8 2014 4:00 PMPermanent Link

Raul

Team Elevate Team Elevate

On 4/8/2014 3:38 PM, Ben wrote:
> The SKU field value is 4563 25' 90
> select * from InvMas where sku = '4563 25' 90'
>
> if I run the above statement I will get an error.  Is there any workaround
> ???
>
>

select * from name where name='4563 25'' 90'

see manual for "literals" :
http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=String_Types

Raul
Tue, Apr 8 2014 7:35 PMPermanent Link

Ben Sprei

CustomEDP

That would be fine if I would enter manually.  However during runtime I have
the program get the string from a data file and incorporate into a sql
string.  Automatically a single apostrophie will appear

"Raul" <raul@removethis.raul.ca> wrote in message
news:FD496FF9-2C2F-497C-9712-6DA0C244C1CC@news.elevatesoft.com...
> On 4/8/2014 3:38 PM, Ben wrote:
>> The SKU field value is 4563 25' 90
>> select * from InvMas where sku = '4563 25' 90'
>>
>> if I run the above statement I will get an error.  Is there any
>> workaround
>> ???
>>
>>
>
> select * from name where name='4563 25'' 90'
>
> see manual for "literals" :
> http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=String_Types
>
> Raul

Tue, Apr 8 2014 9:17 PMPermanent Link

Raul

Team Elevate Team Elevate

On 4/8/2014 7:35 PM, Ben wrote:
> That would be fine if I would enter manually.  However during runtime I have
> the program get the string from a data file and incorporate into a sql
> string.  Automatically a single apostrophie will appear
>

That's not what your original question asked though solution is still
the same.

Just use the QuotedSQLStr engine function for your literal strings when
building the SQL:

http://www.elevatesoft.com/manual?action=viewmethod&id=dbisam4&product=rsdelphiwin32&version=XE5&comp=TDBISAMEngine&method=QuotedSQLStr

Raul
Wed, Apr 9 2014 10:40 AMPermanent Link

Ben Sprei

CustomEDP

Thanks for your reply.
Can you give me a usage example, please.  Whatever I try errors out

"Raul" <raul@removethis.raul.ca> wrote in message
news:D2EBE223-8618-46D3-9F98-DD3BB19105D9@news.elevatesoft.com...
> On 4/8/2014 7:35 PM, Ben wrote:
>> That would be fine if I would enter manually.  However during runtime I
>> have
>> the program get the string from a data file and incorporate into a sql
>> string.  Automatically a single apostrophie will appear
>>
>
> That's not what your original question asked though solution is still the
> same.
>
> Just use the QuotedSQLStr engine function for your literal strings when
> building the SQL:
>
> http://www.elevatesoft.com/manual?action=viewmethod&id=dbisam4&product=rsdelphiwin32&version=XE5&comp=TDBISAMEngine&method=QuotedSQLStr
>
> Raul

Wed, Apr 9 2014 11:30 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Ben,

This is not an SQL issue. Sometimes you do have to write some code.
Just scan the input string and add an extra quote character.

--
Fernando Dias
[Team Elevate]
Wed, Apr 9 2014 10:55 PMPermanent Link

Ben Sprei

CustomEDP

I did some further test utilizing this function and these were the results:

 vSKU := Engine.QuotedSQLStr(QInvMasSKU.Value);

Value Input
   A456 23' 24

Value Output
   'A456 23'' 24'

This function is not working.  Is there any other way around this.


"Ben" <arrow1432@verizon.net> wrote in message
news:21816081-371F-4A51-9CA7-70FD0CBF77F5@news.elevatesoft.com...
> Thanks for your reply.
> Can you give me a usage example, please.  Whatever I try errors out
>
> "Raul" <raul@removethis.raul.ca> wrote in message
> news:D2EBE223-8618-46D3-9F98-DD3BB19105D9@news.elevatesoft.com...
>> On 4/8/2014 7:35 PM, Ben wrote:
>>> That would be fine if I would enter manually.  However during runtime I
>>> have
>>> the program get the string from a data file and incorporate into a sql
>>> string.  Automatically a single apostrophie will appear
>>>
>>
>> That's not what your original question asked though solution is still the
>> same.
>>
>> Just use the QuotedSQLStr engine function for your literal strings when
>> building the SQL:
>>
>> http://www.elevatesoft.com/manual?action=viewmethod&id=dbisam4&product=rsdelphiwin32&version=XE5&comp=TDBISAMEngine&method=QuotedSQLStr
>>
>> Raul
>
>

Thu, Apr 10 2014 12:36 AMPermanent Link

Raul

Team Elevate Team Elevate

On 4/9/2014 10:55 PM, Ben wrote:
> I did some further test utilizing this function and these were the results:
>
>    vSKU := Engine.QuotedSQLStr(QInvMasSKU.Value);
>
> Value Input
>      A456 23' 24
>
> Value Output
>      'A456 23'' 24'
>
> This function is not working.  Is there any other way around this.

What do you mwan it's not working ? This is exactly what it's supposed
to do.

Here's an example as requested.

- for this sample i assume the SKU input is from edit field named
"Edit1" but of course it can come from any where (file, another table, etc).
- q1 is a TEDBQuery
- code sample code that queries the table for specific SKU and displays it :

  q1.SQL.Clear;
  q1.SQL.Add('SELECT * FROM Inv WHERE SKU=' +
Engine.QuotedSQLStr(Edit1.Text));
  q1.Open;
  if not q1.Eof then
    ShowMessage( Format('Sku=%s.
Count=%d',[q1.FieldByName('SKU').AsString,q1.FieldByName('Num').AsInteger]));
  q1.Close;


Raul
Thu, Apr 10 2014 3:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ben


Raul is right in what he's been advising you to do.

<<
 vSKU := Engine.QuotedSQLStr(QInvMasSKU.Value);

Value Input
   A456 23' 24

Value Output
   'A456 23'' 24'
>>

I'm with Raul on this. The results are exactly what I would expect.

Can you post the table structure and the code you're using to construct the sql statement?

Roy Lambert
Thu, Apr 10 2014 3:29 AMPermanent Link

Adam Brett

Orixa Systems

Ben

I usually use EDB's PARAMs in this situation as it cleanly copes with all issues such as single & double quotes which might confuse the compiler:

EDBQuery.SQL.Text:= 'SELECT * FROM sometable WHERE somefield = :Str';
EDBQuery.Prepare;
EDBQuery.ParamByName('Str').asString:= 'Someone''s ';

The point is that if you do it like this the compiler will spot the single quote when you set the Param, so you can correct it. If it works as a string in code, EDB will happily run it.
Page 1 of 2Next Page »
Jump to Page:  1 2
Image