Home » SQL & PL/SQL » SQL & PL/SQL » Substr weirdness (Oracle 10g, Linux)
Substr weirdness [message #423579] Fri, 25 September 2009 06:53 Go to next message
fatmcgav
Messages: 2
Registered: September 2009
Junior Member
Hi there,

I'm trying to substr a string value, however i'm experiencing some weird behaviour.

My Code looks like:
dbms_output.put_line('ESP Tracking Data is '||esp_cards.szITSOTrackingData);
		
		-- Split Tracking Data
		Typ32Track:=substr(esp_cards.szITSOTrackingData,1,20);
		Typ00Track:=substr(esp_cards.szITSOTrackingData,21,40);
		Typ02Track:=substr(esp_cards.szITSOTrackingData,41,60);
		Typ16Track:=substr(esp_cards.szITSOTrackingData,61,80);
		Typ22Track:=substr(esp_cards.szITSOTrackingData,81,length(esp_cards.szITSOTrackingData));
		
		dbms_output.put_line('Typ32 Tracking Data is '||Typ32Track);
		dbms_output.put_line('Typ00 Tracking Data is '||Typ00Track);
		dbms_output.put_line('Typ02 Tracking Data is '||Typ02Track);
		dbms_output.put_line('Typ16 Tracking Data is '||Typ16Track);
		dbms_output.put_line('Typ22 Tracking Data is '||Typ22Track);


My result looks like:
Quote:
ESP Tracking Data is 63359703A00008000C1163359703A00008000C1363359703A00008000C1463359703A00008000C1663359703A00008000C1863359703A00008000C1A
Typ32 Tracking Data is 63359703A00008000C11
Typ00 Tracking Data is 63359703A00008000C1363359703A00008000C14
Typ02 Tracking Data is 63359703A00008000C1463359703A00008000C1663359703A00008000C18
Typ16 Tracking Data is 63359703A00008000C1663359703A00008000C1863359703A00008000C1A
Typ22 Tracking Data is 63359703A00008000C1863359703A00008000C1A


As you can see above Typ00, Typ02 and Typ16 are far more than the 20 characters they should be...

Any ideas where i'm going wrong?

Cheers
Gavin
Re: Substr weirdness [message #423580 is a reply to message #423579] Fri, 25 September 2009 06:59 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
You are using substr wrong.

They are now 20,40,60 ..... long
Re: Substr weirdness [message #423581 is a reply to message #423580] Fri, 25 September 2009 07:01 Go to previous message
fatmcgav
Messages: 2
Registered: September 2009
Junior Member
Doh... Length rather than end point...

Knew it was something simple...

Cheers
Gavin
Previous Topic: Data Dictionary
Next Topic: kill user sessions for certain user
Goto Forum:
  


Current Time: Wed Dec 07 18:25:15 CST 2016

Total time taken to generate the page: 0.08616 seconds