Sponsored Content
Top Forums Programming SQLPlus Case statement on a substring Post 302716589 by Yoda on Tuesday 16th of October 2012 04:01:13 PM
Old 10-16-2012
Try:-

Code:
select 
case 
when dbms_lob.substr(msg_body,1,1) in ('A', 'B', 'C', 'E') then 'BILL'
when dbms_lob.substr(msg_body,1,1) =  'F' then 'BOB'
when dbms_lob.substr(msg_body,1,1) =  'G' then 'JOHN'
when dbms_lob.substr(msg_body,1,1) =  'H' then 'TOM'
when dbms_lob.substr(msg_body,1,1) =  'I' then 'NIGEL'
end as networkId, count(1)


Last edited by Yoda; 10-16-2012 at 05:32 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

case statement

Hi all, is it possible to create a 'dynamic' case statement. ie select option in `ls` do case satement depending on results of the above `ls` done I hope I have explained this ok! Thanks Helen (1 Reply)
Discussion started by: Bab00shka
1 Replies

2. Shell Programming and Scripting

Case Statement

Can anyone please tell me why this wont work! Thanks so much! #!/bin/sh for file do case $file in *.*.*) echo Cannot have more than 1 dot exit ;; *'**'*) echo Cannot have more than 1 asterisk exit ;; *'*'*|?.) echo this is a target (19 Replies)
Discussion started by: Zeta_Acosta
19 Replies

3. UNIX for Dummies Questions & Answers

If or Case Statement

I want to write a program with the following variables: a=7000 b=24000 c=613.8 The user can enter two words: Vivid or Blue for example. The challenge is that the user might not want to write the words the way they appear. The user can write V or v or vivid or Vivid or write Blue or blue, or B,... (1 Reply)
Discussion started by: Ernst
1 Replies

4. Shell Programming and Scripting

case-insensitive if on substring

I'd like to print a line if a substring is matched in a case insensitive manner something like do a case insensitive search for ABCD as a substring: awk '{ if (substr($1,1,4) == "") print $1 }' infile > outfile I'm not certain how to make the syntax work??? Thanks (4 Replies)
Discussion started by: dcfargo
4 Replies

5. Shell Programming and Scripting

case statement

Hi, I am writing case statement to execute some finction, my requirement is once one of the case statement is executed again it has to prompt for the option. for script in `echo "$Script_Selected"` do case $script in 1) getNoOFActUsers ;; 2) moveServerrOORotation ;; ... (2 Replies)
Discussion started by: Satyak
2 Replies

6. UNIX for Dummies Questions & Answers

If statement for substring within string (korn)

Hi all, Just looking for a simple if statement that searches for a substring within a varaible, and then performs some function. Problem is that I need it to work in Korn shell $var = *string* does not work in Korn i="xxxxxx00.00yyyyy.zzzzz" want to find 00.00 (2 Replies)
Discussion started by: jgrosecl
2 Replies

7. Shell Programming and Scripting

Case Statement

Hey, guys I really need some help with a project. "Write a shell program that examines the command line arguments, counts and collects the number of options. Basically it has to collect and count the arguments that start with a "-" and the one's that don't start with a - I know I have to use... (2 Replies)
Discussion started by: sk192010`
2 Replies

8. Shell Programming and Scripting

Connecting sqlplus from UNIX with multiple select statement

hi, i have a requirement where i need to connect sqlplus from unix and i am able to do so by following command: cust_count=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID << EOF set pagesize 0 set feedback off set verify off ... (1 Reply)
Discussion started by: lovelysethii
1 Replies

9. Shell Programming and Scripting

Use sqlplus statement inside case sentence

Hello, I have a problem. I want to launch a different sql queries for different shell parameter values, something like this. #/bin/bash case $1 in "A") sqlplus -s user/pass << SQL query A; SQL "B") sqlplus -s user/pass << SQL2 ... (3 Replies)
Discussion started by: Vares
3 Replies

10. Shell Programming and Scripting

SQLPLUS command with more than 1 select statement

Hi all, I'm using below code processId=`sqlplus -s ${sysuser}/${syspwd} <<CHK_PROCESS whenever sqlerror exit sql.sqlcode; set head off feedback off echo off pages 0 SELECT PROCESS_ID FROM LSHADMIN.DATA_DOMAIN WHERE DOMAIN_NAME = '${tabname}' ... (8 Replies)
Discussion started by: Pratiksha Mehra
8 Replies
STRRCHR(3)								 1								STRRCHR(3)

strrchr - Find the last occurrence of a character in a string

SYNOPSIS
string strrchr (string $haystack, mixed $needle) DESCRIPTION
This function returns the portion of $haystack which starts at the last occurrence of $needle and goes until the end of $haystack. PARAMETERS
o $haystack - The string to search in o $needle - If $needle contains more than one character, only the first is used. This behavior is different from that of strstr(3). If $needle is not a string, it is converted to an integer and applied as the ordinal value of a character. RETURN VALUES
This function returns the portion of string, or FALSE if $needle is not found. CHANGELOG
+--------+------------------------------------+ |Version | | | | | | | Description | | | | +--------+------------------------------------+ | 4.3.0 | | | | | | | This function is now binary safe. | | | | +--------+------------------------------------+ EXAMPLES
Example #1 strrchr(3) example <?php // get last directory in $PATH $dir = substr(strrchr($PATH, ":"), 1); // get everything after last newline $text = "Line 1 Line 2 Line 3"; $last = substr(strrchr($text, 10), 1 ); ?> NOTES
Note This function is binary-safe. SEE ALSO
strstr(3), strrpos(3). PHP Documentation Group STRRCHR(3)
All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy