Voir ci-dessous les données ci-dessous d'abord, j'ai besoin de calculer les colonnes HUB_NM, PRODUCT_NM et STRIP_NM à partir des 2 premières colonnes comme décrit.En utilisant INSTR et SUBSTR ensemble
DEAL_ORIGINATION EXCH_SYMBOL HUB_NM PRODUCT_NM STRIP_NM
---------------- ---------------------------------------------- ---------- --------------------- ------------
TT_ICE IPE e-Gas Oil DEC 2010 IPE e-Gas Oil DEC 2010
GLOBEX HO DEC 2010 HO DEC 2010
ICE NG Firm Phys, ID, GDD - Transco-45 - Next Day Gas Transco-45 NG Firm Phys, ID, GDD Next Day Gas
STUSCO_ICE Brent Crude Futures - North Sea - Dec12 Brent Crude Futures DEC12
Je n'arrive pas à comprendre comment procéder. Je sais que je devrais utiliser SUBSTR et INSTR mais je ne peux pas le comprendre.
A) Comment obtenir la valeur de colonne HUB_NM de EXCH_SYMBOL?
If T.DEAL_ORIGINATION = 'ICE'
then
Find 1st space dash space
Find 2nd space dash space
Display the word in between, no space at the end
elsif T.DEAL_ORIGINATION in ('GLOBEX', 'TT_ICE', 'STUSCO_ICE')
then
null;
end if;
B) Comment obtenir la valeur de colonne PRODUCT_NM de EXCH_SYMBOL?
If T.DEAL_ORIGINATION in ('ICE', 'STUSCO_ICE')
then
Display from 1st character to the 1st dash, no space at the end
elsif T.DEAL_ORIGINATION in ('GLOBEX', 'TT_ICE',)
then
Remove -9 caharacters from the end of the word and display the fornt word, no space at the end
end if;
C) Comment obtenir la valeur de colonne STRIP_NM de EXCH_SYMBOL?
If T.DEAL_ORIGINATION in ('ICE', 'STUSCO_ICE')
then
Find the 2nd space dash space
Display from then on to the end of the word, no space at the end
elsif T.DEAL_ORIGINATION in ('GLOBEX', 'TT_ICE',)
then
Display the last -8 caharacters from the end of the word, no space at the end
end if;
pourriez-vous fournir un exemple de table avec des inserts pour la table ou un CTE? Je ne peux pas faire la tête ou la queue hors des données d'échantillon. – Harrison
une demande de plus, pourriez-vous mettre dans les exemples dans A, B, C de votre sortie prévue? et quelle version d'Oracle utilisez-vous (êtes-vous opposé à une réponse d'expression régulière? REGEXP_SUBSTR & regexp_replace peut être la réponse que vous cherchez – Harrison