dbTalk Databases Forums  

reg expression syntax error

comp.databases.mysql comp.databases.mysql


Discuss reg expression syntax error in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 01:21 PM






On 2010-09-17 18:32, jr wrote:
[...]
Quote:
it has to be padded with zeros.
IMO, this is an issue that should be dealt with in the in the
presentation layer and not in the data layer. I.e. store it as int (or
whatever type that is most appropiate), and transform it when it is
presented to the user.

/Lennart

Reply With Quote
  #12  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 01:35 PM






On 9/17/2010 2:21 PM, Lennart Jonsson wrote:
Quote:
On 2010-09-17 18:32, jr wrote:
[...]

it has to be padded with zeros.

IMO, this is an issue that should be dealt with in the in the
presentation layer and not in the data layer. I.e. store it as int (or
whatever type that is most appropiate), and transform it when it is
presented to the user.

/Lennart


Indeed, Lennart. How to display data is not a database issue.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #13  
Old   
jr
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 03:42 PM



On Sep 16, 5:26*pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
Quote:
On 9/16/2010 7:33 PM, jr wrote:

In the ndc column there were some imported rows from Excel with
scientific notation.
* I am trying to find those rows using preg_match so I can located
the . and then pad with zeros the number of the exponent but I get a
syntax error.The correct field has 11 digits and has leading zeros.
It is a char field.

select preg_match(^[0-9]{11}$,ndc) from inventory
select preg_match(^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
[0-9]$,ndc) from inventory
thankx,

Which is just ONE of the reasons you don't want to use a char field to
store numeric data.

I told you it would have unwelcome consequences. *But, as usual, you
just make changes willy-nilly without understanding the consequences.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================
I wrote this sql query and I found 163 records with the error with 11
digits in the exponent.
SELECT nationalDrugCode from inventory
where locate('.',ndc)=2 and substring('+11',ndc)=1

I am trying to figure out how to do the UPDATE query to format it as
a number with 11 digits and not as scientific notation when the data
type is a character. I could change the datatype for the query then
change it back or is there a way to cast it?
UPDATE inventory SET ndc=
format(ndc,11) ?????
SELECT ndc from inventory
wherE locate('.',ndc)=2 and substring('+11',ndc)=1
thanks,

Reply With Quote
  #14  
Old   
Luuk
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 04:14 PM



On 17-09-10 22:42, jr wrote:
Quote:
On Sep 16, 5:26 pm, Jerry Stuckle<jstuck... (AT) attglobal (DOT) net> wrote:
On 9/16/2010 7:33 PM, jr wrote:

In the ndc column there were some imported rows from Excel with
scientific notation.
I am trying to find those rows using preg_match so I can located
the . and then pad with zeros the number of the exponent but I get a
syntax error.The correct field has 11 digits and has leading zeros.
It is a char field.

select preg_match(^[0-9]{11}$,ndc) from inventory
select preg_match(^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
[0-9]$,ndc) from inventory
thankx,

Which is just ONE of the reasons you don't want to use a char field to
store numeric data.

I told you it would have unwelcome consequences. But, as usual, you
just make changes willy-nilly without understanding the consequences.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

I wrote this sql query and I found 163 records with the error with 11
digits in the exponent.
SELECT nationalDrugCode from inventory
where locate('.',ndc)=2 and substring('+11',ndc)=1

I am trying to figure out how to do the UPDATE query to format it as
a number with 11 digits and not as scientific notation when the data
type is a character. I could change the datatype for the query then
change it back or is there a way to cast it?
UPDATE inventory SET ndc=
format(ndc,11) ?????
SELECT ndc from inventory
wherE locate('.',ndc)=2 and substring('+11',ndc)=1
thanks,
you can also read the data back into Excel,
do the correct formatting,
and export the stuff again....

--
Luuk

Reply With Quote
  #15  
Old   
jr
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 05:35 PM



On Sep 17, 2:14*pm, Luuk <L... (AT) invalid (DOT) lan> wrote:
Quote:
On 17-09-10 22:42, jr wrote:





On Sep 16, 5:26 pm, Jerry Stuckle<jstuck... (AT) attglobal (DOT) net> *wrote:
On 9/16/2010 7:33 PM, jr wrote:

In the ndc column there were some imported rows from Excel with
scientific notation.
* *I am trying to find those rows using preg_match so I can located
the . and then pad with zeros the number of the exponent but I get a
syntax error.The correct field has 11 digits and has leading zeros.
It is a char field.

select preg_match(^[0-9]{11}$,ndc) from inventory
select preg_match(^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
[0-9]$,ndc) from inventory
thankx,

Which is just ONE of the reasons you don't want to use a char field to
store numeric data.

I told you it would have unwelcome consequences. *But, as usual, you
just make changes willy-nilly without understanding the consequences.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

I wrote this sql query and I found 163 records with the error with 11
digits in the exponent.
SELECT nationalDrugCode from inventory
where locate('.',ndc)=2 and substring('+11',ndc)=1

* I am trying to figure out how to do the UPDATE query to format it as
a number with 11 digits and not as scientific notation when the data
type is a character. *I could change the datatype for the query then
change it back or is there a way to cast it?
UPDATE inventory SET ndc=
format(ndc,11) * * * * * *?????
SELECT ndc from inventory
wherE locate('.',ndc)=2 and substring('+11',ndc)=1
thanks,

you can also read the data back into Excel,
do the correct formatting,
and export the stuff again....

--
Luuk
That might be difficult. It is exported from different files into one
extract and then I extract it from that.

Reply With Quote
  #16  
Old   
jr
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 05:39 PM



On Sep 17, 11:21*am, Lennart Jonsson <erik.lennart.jons... (AT) gmail (DOT) com>
wrote:
Quote:
On 2010-09-17 18:32, jr wrote:
[...]



*it has to be padded with zeros.

IMO, this is an issue that should be dealt with in the in the
presentation layer and not in the data layer. I.e. store it as int (or
whatever type that is most appropiate), and transform it when it is
presented to the user.

/Lennart
It is mainly a transformation issue. It needs to relate to another
files to pull in the item_id, so it gets off the error list.
There is no user looking at the display.
It really should be fixed in mysql, and there are users that use the
mysql db directly, but I see your point if it is not a mysql issue
directly.

Reply With Quote
  #17  
Old   
jr
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 05:41 PM



On Sep 17, 11:35*am, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
Quote:
On 9/17/2010 2:21 PM, Lennart Jonsson wrote:

On 2010-09-17 18:32, jr wrote:
[...]

* it has to be padded with zeros.

IMO, this is an issue that should be dealt with in the in the
presentation layer and not in the data layer. I.e. store it as int (or
whatever type that is most appropiate), and transform it when it is
presented to the user.

/Lennart

Indeed, Lennart. *How to display data is not a database issue.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================
if there is a way to transform it with a php script I would use
preg_match if I had some idea of how to proceed with it.

Reply With Quote
  #18  
Old   
jr
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 05:44 PM



On Sep 17, 2:14*pm, Luuk <L... (AT) invalid (DOT) lan> wrote:
Quote:
On 17-09-10 22:42, jr wrote:





On Sep 16, 5:26 pm, Jerry Stuckle<jstuck... (AT) attglobal (DOT) net> *wrote:
On 9/16/2010 7:33 PM, jr wrote:

In the ndc column there were some imported rows from Excel with
scientific notation.
* *I am trying to find those rows using preg_match so I can located
the . and then pad with zeros the number of the exponent but I get a
syntax error.The correct field has 11 digits and has leading zeros.
It is a char field.

select preg_match(^[0-9]{11}$,ndc) from inventory
select preg_match(^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
[0-9]$,ndc) from inventory
thankx,

Which is just ONE of the reasons you don't want to use a char field to
store numeric data.

I told you it would have unwelcome consequences. *But, as usual, you
just make changes willy-nilly without understanding the consequences.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

I wrote this sql query and I found 163 records with the error with 11
digits in the exponent.
SELECT nationalDrugCode from inventory
where locate('.',ndc)=2 and substring('+11',ndc)=1

* I am trying to figure out how to do the UPDATE query to format it as
a number with 11 digits and not as scientific notation when the data
type is a character. *I could change the datatype for the query then
change it back or is there a way to cast it?
UPDATE inventory SET ndc=
format(ndc,11) * * * * * *?????
SELECT ndc from inventory
wherE locate('.',ndc)=2 and substring('+11',ndc)=1
thanks,

you can also read the data back into Excel,
do the correct formatting,
and export the stuff again....

--
Luuk
I could possibly download from inventory tbl to excel just these
errors, fix them, then upload them again, the trouble with that is not
being able to automate the process.

Reply With Quote
  #19  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: reg expression syntax error - 09-17-2010 , 06:51 PM



On 9/17/2010 6:41 PM, jr wrote:
Quote:
On Sep 17, 11:35 am, Jerry Stuckle<jstuck... (AT) attglobal (DOT) net> wrote:
On 9/17/2010 2:21 PM, Lennart Jonsson wrote:

On 2010-09-17 18:32, jr wrote:
[...]

it has to be padded with zeros.

IMO, this is an issue that should be dealt with in the in the
presentation layer and not in the data layer. I.e. store it as int (or
whatever type that is most appropiate), and transform it when it is
presented to the user.

/Lennart

Indeed, Lennart. How to display data is not a database issue.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck... (AT) attglobal (DOT) net
==================

if there is a way to transform it with a php script I would use
preg_match if I had some idea of how to proceed with it.
If you handled things CORRECTLY, you wouldn't need preg_match.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.