Unix/Linux Go Back    


Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

Need help in select statetment

Windows & DOS: Issues & Discussions


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-18-2012   -   Original Discussion by Alone
Alone's Unix or Linux Image
Alone Alone is offline
Registered User
 
Join Date: Jun 2012
Last Activity: 5 May 2014, 9:44 AM EDT
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Need help in select statetment

Dear Expert,

I have an table name (SMS) in which two column are there one "Flag" other is "Message", If my flag column consist of status "1" then output should be "welcome", else" try again" ,. please correct my code.


Code:
DECLARE 
c PLS_INTEGER := dbms_sql.open_cursor; 
flag VARCHAR2(50); 
STATEMENT VARCHAR2(255); 
BEGIN 
SELECT SUBSTR(flag, 1,2) 
INTO flag 
FROM xxx.sms; 
IF flag = 1 THEN 
dbms_output.put_line('welcome');
ELSE
dbms_output.put_line('ty again');
END IF;
END ;

Thank you,
Sponsored Links
    #2  
Old Unix and Linux 07-20-2012   -   Original Discussion by Alone
jim mcnamara's Unix or Linux Image
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 14 December 2017, 3:00 PM EST
Location: NM
Posts: 11,253
Thanks: 577
Thanked 1,122 Times in 1,034 Posts

Code:
set serveroutput on size 100000
DECLARE 

flag VARCHAR2(50); 
STATEMENT VARCHAR2(255); 

BEGIN 
  dbms_output.enable(100000);
 SELECT SUBSTR(flag, 1,2) 
   INTO flag 
 FROM xxx.sms; 
 IF flag = 1 THEN 
   dbms_output.put_line('welcome');
 ELSE
   dbms_output.put_line('try again');
 END IF;
END ;

Try that.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Socket and select naresh046 Programming 3 07-01-2011 03:54 PM
Reboot and Select Proper Boot device or insert Boot media in select Boot device and press a key rpf Boot Loaders 0 03-22-2011 04:20 PM
How to: IFNULL(SELECT ...,0) STOIE Web Programming 0 10-22-2010 03:41 AM
select always the first row iga3725 Shell Programming and Scripting 4 10-14-2010 12:09 PM
SQL Select and awk habuzahra Shell Programming and Scripting 6 11-26-2008 01:44 AM



All times are GMT -4. The time now is 06:54 PM.