Monday, 15 August 2011

Replacing/Converting 1 to A with Oracle/PLSQL -



Replacing/Converting 1 to A with Oracle/PLSQL -

firstly, appreciate feedback can offer. using oracle sql developer, version 4.0.2.15, build 15.21.

i know , understand many, many similar questions have been asked, i've searched around on stackoverflow rest of internet. however, corresponding answers either vague or extravagant, , effort things way on head , not trying accomplish. extremely new sql , haven't done coding since did java 12 years ago. please understand simple you, not simple , obvious me.

my bare-bones endstate shooting taking pre-existing oracle table column, called 'service_level', has parameters of 1-3, , making them a-c (where a=1, b=2, c=3). reason have arcgis gdb featureclass has corresponding column, called 'maintservi', parameters of a-c. going bring together them using arctoolbox 1 time have converted/replaced 1-3 a-c, , have exported them oracle arc gdb table. reason beingness featureclass (obviously) has geometry, particular oracle table not.

from have gathered know (or think) need utilize like:

chr(ord('a') + 3)

^ need use/call upon chr/ord functions. however, due inexperience, cannot think of how phone call without getting error. below have query far (but without chr/ord). need figure out how correctly insert query accomplish desired results.

select v_wv_wp_crew.*, substr(v_wv_wp_crew.winter_supp_id, 1, 6) costcenter, substr(v_wv_wp_crew.winter_supp_id, 8, 11) crew_supp_id v_wv_wp_crew crew_on_road >= '13-feb-12' , ( operation = 2 or operation = 3 );

thanks 1 time again , have complied posting rules of stackoverflow.

@ mark j. bobak - when implementing ideas either (like said, i'm not sure how insert without receiving error)

select v_wv_wp_crew.*, substr(v_wv_wp_crew.winter_supp_id, 1, 6) costcenter, substr(v_wv_wp_crew.winter_supp_id, 8, 11) crew_supp_id v_wv_wp_crew crew_on_road >= '13-feb-12' , ( operation = 2 or operation = 3 ) union service_level (select 1 service_level dual union select 2 service_level dual union select 3 service_level dual) select decode(service_level,1,'a',2,'b',3,'c') service_level;

i receive next error:

*ora-32034: unsupported utilize of clause 32034. 00000 - "unsupported utilize of clause" *cause: inproper utilize of clause because 1 of next 2 reasons 1. nesting of clause within clause not supported yet 2. set query, clause can't specified branch. 3. clause can't sepecified within parentheses. action: right query , retry error @ line: 14 column: 25

or receive output of 3 rows (a, b, c) if run query separately - sorry don't have plenty reputation post image yet.

you can utilize decode() function. should work:

with list_of_digits (select 1 col_a dual union select 2 col_a dual union select 3 col_a dual union select 4 col_a dual) select decode(col_a,1,'a',2,'b',3,'c','other') list_of_digits;

using query, seek this:

with service_level (select 1 service_level dual union select 2 service_level dual union select 3 service_level dual) select decode(service_level,1,'a',2,'b',3,'c') service_level union select v_wv_wp_crew.*, substr(v_wv_wp_crew.winter_supp_id, 1, 6) costcenter, substr(v_wv_wp_crew.winter_supp_id, 8, 11) crew_supp_id v_wv_wp_crew crew_on_road >= '13-feb-12' , ( operation = 2 or operation = 3 );

oracle plsql

No comments:

Post a Comment