Sql CASE statement with SUBSTRING? -


hi have small query below :

select  subscriberdataid,         substring(facetsdata,  5,  9) subscribercode,         substring(facetsdata, 14, 35) subscriberlastname,         substring(facetsdata, 50, 15) subscriberfirstname    facets.facetsimport   dataindicator = 'dem1' 

i trying use case statement in query dont know how. have have find invalid records 3 fields above. gonna use len(subscribercode) > 9 (9 lenght of data type) , when greater 9 insert error table. same way other 2 columns having lenght 35 , 15.

thanks

the strings have correct lengths if , if input string 64 characters or longer:

insert    main_table select  subscriberdataid,         substring(facetsdata,  5,  9) subscribercode,         substring(facetsdata, 14, 35) subscriberlastname,         substring(facetsdata, 50, 15) subscriberfirstname    facets.facetsimport   dataindicator = 'dem1'         , len(facetsdata) >= 64  insert    error_table select  subscriberdataid,         substring(facetsdata,  5,  9) subscribercode,         substring(facetsdata, 14, 35) subscriberlastname,         substring(facetsdata, 50, 15) subscriberfirstname    facets.facetsimport   dataindicator = 'dem1'         , (len(facetsdata) < 64 or facetsdata null) 

Comments

Popular posts from this blog

sql server - python to mssql encoding problem -

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -