Sybase ASE: Query to find correct format issue.


 
Thread Tools Search this Thread
Top Forums Programming Sybase ASE: Query to find correct format issue.
# 1  
Old 04-25-2017
Sybase ASE: Query to find correct format issue.

Hi Team ,

I am new to Sybase Adaptive Server Enterprise/15.7 (ASE) and need some guidance to find the different values in serial format column.
Code:
SELECT DISTINCT SERIAL_FORMAT FROM PRODUCTS

It has values with below format which contains 12 digits hexadecimal characters with numbers/alphabets.
Ex:
  • 00:71:48:D1:R6:Z7 --Valid record
  • 3E67E5E334Q8 --invalid as : is not used across 2 digits

How can query be written to identify SERIAL_FORMAT with:-
  1. Total Valid
  2. Invalid
  3. Missing
  4. Bad format
  5. Repeated values

Any help is appreciated.

Last edited by rbatte1; 04-25-2017 at 01:38 PM.. Reason: Removed gratuitous FONT formatting, corrected CODE tags range and added formatted lists and ICODE tags.
# 2  
Old 04-25-2017
I think pattern matching would be one of many ways to check.
For example, this statement would count number of valid records:
Code:
 select COUNT(*) 
 from PRODUCTS
 where SERIAL_FORMAT like "__:__:__:__:__:__"

I don't know what are the valid characters in between the colons, so I use underscore (any character), you can change that to valid range using
Code:
[]

brackets.
For example
Code:
[A-Z]

would mean any character between A and Z inclusive.
# 3  
Old 04-25-2017
Quote:
Originally Posted by Perlbaby
Hi Team ,

I am new to Sybase Adaptive Server Enterprise/15.7 (ASE) and need some guidance to find the different values in serial format column.
Code:
SELECT DISTINCT SERIAL_FORMAT FROM PRODUCTS

It has values with below format which contains 12 digits hexadecimal characters with numbers/alphabets.
Ex:
  • 00:71:48:D1:R6:Z7 --Valid record
  • 3E67E5E334Q8 --invalid as : is not used across 2 digits

How can query be written to identify SERIAL_FORMAT with:-
  1. Total Valid
  2. Invalid
  3. Missing
  4. Bad format
  5. Repeated values

Any help is appreciated.
In addition to what migurus has already said, note that saying that valid records contain 12 hexadecimal digits and then saying that a string containing 17 characters of which 7 are not hexadecimal digits (five colons, an uppercase R, and an uppercase Z) is valid AND saying that a string that doesn't contain colons is invalid brings everything else you've said into question. It is very hard to help you write code to help you test conflicting requirements.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Sybase ASE - Query Tuning - Need Suggestion

Dear Team Please provide suggestion on below query which is used in Sybase Adaptive Server Enterprise/15.7 (ASE). Query takes more time > 30 Mins to 1 Hr All required indexes are built Can we have any efficient approach to get the data retrieval faster for below query.Any help... (0 Replies)
Discussion started by: Perlbaby
0 Replies

2. Programming

Sybase ASE Soundex Function Issue -Need Suggestion

Dear Team I am using Sybase Adaptive Server Enterprise/15.7 (ASE). Trying my luck on SOUNDEX function to get unique records Though the command works for characters and provides unique code for similar outputs. But when i try with Starting numbers ( Followed with Street address ) , soundex... (1 Reply)
Discussion started by: Perlbaby
1 Replies

3. Programming

Sybase ASE - AVG Function Error

Hi Team - I am using Sybase ASE 15.7 version. Below query is throwing an error stating Error : incorrect syntax near the keyword 'OVER' SELECT EMPLOYEE_ID , EMPLOYEE , Department, CAST( Salary as DECIMAL( 10, 2 ) ) AS Salary CAST(AVG( Salary) OVER ( PARTITION... (3 Replies)
Discussion started by: Perlbaby
3 Replies

4. Programming

How to trim values in sybase ase?

HI Team I am using Sybase ASE15.7 version. Below is the sample column values . http://abc.lifeline.airs.com/support/ https://xyzbre.lifeline.airs.com/video/ Would like to know how to Trim http:// and https:// from above list of example Remove characters after first / Include only the... (3 Replies)
Discussion started by: Perlbaby
3 Replies

5. Programming

Hierarchical Query for Sybase database

Team I am using DBartisan tool for sybase database. I have a table that has below fields Employee_ID,EMP_Name,First_Nm,Last_Nm,Emp_Designation,Employee's_Manager is it possible to retrieve hierarchical data based on below fields Emp_Designation will have Soft Engg,SSE,Team Lead,... (6 Replies)
Discussion started by: Perlbaby
6 Replies

6. UNIX and Linux Applications

sybase ase installer

i'm looking for an installer of Sybase ASE 11.9.2.6 for HP-UX. tried buying from the local distributor but he can only give me the latest version. can anyone point me to where i could possibly get it? (0 Replies)
Discussion started by: sam_salazar
0 Replies

7. Programming

Need help with complex SQL query (Sybase)

Hello, I have three tables. I need an SQL query (preferably Sybase) that will return all of the stringID values of table B where the following conditions exist: (1) B.intID = A.intID (2) B.intID != C.intID or (B.intID = C.intID and (C.v1 = 0 or C.v2... (2 Replies)
Discussion started by: chatieremerrill
2 Replies

8. Shell Programming and Scripting

Print out loop index on the console after executing each sybase DB query

Hello Guys, Well, using shell script, I'm doing loop on DB query as below: isql -Usa -Ptest -I /opt/sybase/interfaces << EOF use testdb go declare @i int select @i = 1 while(@i <= 5) begin Insert into TEST values (@i,"Test","TestDesc") select @i = @i + 1 end go EOF The Issue... (2 Replies)
Discussion started by: Alaeddin
2 Replies

9. Shell Programming and Scripting

Dynamic update loop query on Sybase database

Hello Guys, I'm new to Shell scripting, and i need someone to help me with this issue: I'm trying to do a dynamic update query on Sysbase database table using shell script. Lets say, the Update query is "update Table set id=X" , where X is dynamic value for the loop index. If the loop is... (10 Replies)
Discussion started by: Alaeddin
10 Replies
Login or Register to Ask a Question