Sign in to follow this  
Followers 0
incubi

white spaces in table field.

4 posts in this topic

The data tables I have to work with have white spaces in some fields and if I do a query with a WHERE ='1234" if fails because the queried value looks like this " 1234". So I need to trim out the spaces before the WHERE test. The only option I see is to use StringStripWS but I don't understand how to use that in the query with AutoIT.

Access for example is easy

SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE (((Ltrim(co.[co-num])) ="1234"));

But that seems to fail using AutoIT and StringStripWS in place of Ltrim

Any help would be great!

Thanks,

Incubi

Share this post


Link to post
Share on other sites



The data tables I have to work with have white spaces in some fields and if I do a query with a WHERE ='1234" if fails because the queried value looks like this " 1234". So I need to trim out the spaces before the WHERE test. The only option I see is to use StringStripWS but I don't understand how to use that in the query with AutoIT.

Access for example is easy

SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE (((Ltrim(co.[co-num])) ="1234"));

But that seems to fail using AutoIT and StringStripWS in place of Ltrim

Any help would be great!

Thanks,

Incubi

This is just a guess since I know nothing about sql. Maybe you could have

SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE co.[co-num] IN " 1234";

where there ar more leading spaces in " 1234" than you ever expect.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I was thinking more like if the value can be captured in a variable, which it appears it can be.

$Data = SELECT co.[co-num], co.[cust-num], co.contact FROM co WHERE (((Ltrim(co.[co-num]))

If StringStripWS($Data) = "1234" Then

; do something

EndIf

.... BUT, I have no clue about sql either

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I think both ideas will work but in each case the query would have to search through a lot more records until it finds the right one and with a table with 20k + records in it that could take a while. For example in Access if I add the spaces to the number it takes 5x as long to get the hit, whereas if I trim the field before the WHERE test its fast.

Thanks,

incubi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0