Print message while using sqlplus


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Print message while using sqlplus
# 1  
Old 05-23-2013
Print message while using sqlplus

I want to connect to oracle database from solaris...
After that i will drop and create a no.of tables.One of the table example is as below.

Code:
 
sqlplus -s usrname/password@dbname << SQL >> $logfile 2>&1
echo " dropping the table1" | tee logfile
DROP TABLE Table1
echo "creating the table1" | tee logfile
CREATE TABLE table1
(
  VERSION       VARCHAR2(25 BYTE),              
  CATEGORY           VARCHAR2(255 BYTE),
  SHORT_NAME  VARCHAR2(25 BYTE),
)
commit;
quit
SQL

My question is will this code print message lfor creation and deletion in the screen as well as in the log...

Please let me know if i have to modify anything in the code.

Thank you in advance.
# 2  
Old 05-23-2013
Quote:
Originally Posted by millan
My question is will this code print message lfor creation and deletion in the screen as well as in the log...
No, the code will not print messages on your screen because you are redirecting stdout and stderr to logfile:
Code:
sqlplus -s usrname/password@dbname << SQL >> $logfile 2>&1

Also below statements are wrong, because you cannot use shell built-ins, commands or utilities inside SQL block:
Code:
echo " dropping the table1" | tee logfile
DROP TABLE Table1
echo "creating the table1" | tee logfile

You should perform below modification:
Code:
sqlplus -s usrname/password@dbname << SQL | tee $logfile
prompt dropping the table1;
DROP TABLE Table1;
prompt creating the table1;
CREATE TABLE table1
(
  VERSION       VARCHAR2(25 BYTE),              
  CATEGORY           VARCHAR2(255 BYTE),
  SHORT_NAME  VARCHAR2(25 BYTE),
);
commit;
quit
SQL

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check the string in a file and print an attribute in the message

Hi, I am new to shell scripting and got a task to complete. Task is : we have a log file where in i need to traverse through the whole file to check the string "Person Type missing in message" and after that i need to get EMPLID=xxxxxx from the file and print details in a different file. ... (1 Reply)
Discussion started by: suren424
1 Replies

2. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

3. Shell Programming and Scripting

Sqlplus error - sqlplus -s <login/password@dbname> : No such file or directory

i am using bash shell Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127. IFS="," declare -a Arr=($Variable1); SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE} echo "set head off ; " > ${SQLCMD} echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Discussion started by: arghadeep adity
6 Replies

4. Shell Programming and Scripting

How to print huge values in sqlplus variable in UNIX?

Hi, I ahve a unix code as below. sqlTxt=$* sqlReturn=`echo "set feedback off; set heading off; set term off; set verify off; set serveroutput on size unlimited set lin 1000; VARIABLE GV_return_val NUMBER; VARIABLE GV_script_error varchar2(4000); EXEC :GV_return_code := 0; EXEC... (6 Replies)
Discussion started by: bhaski2012
6 Replies

5. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

6. Shell Programming and Scripting

Print a message at specific line on prompt

Hi Friends, I am using HP-UNIX(ksh). I want to print a message at specific line on the prompt screen. For Example: for num in 1 10 3 145 do echo $num // need to print this on the same line for each number sleep 2 done Actual Output: ========== 1 10 3 145 Expected Output:... (5 Replies)
Discussion started by: Niroj
5 Replies

7. Shell Programming and Scripting

Error while trying to print message

Hi all Geting this error while trying to print message as : ./logfunc: print: bad file unit number heres what i m trying to do : log_date="$(date '+%d/%m/%Y %H:%M:%S')" log_type="Message" print "${log_date}: ${log_type}" print -u3 "${log_date}: ${log_type}" this error is due to... (3 Replies)
Discussion started by: Navatha
3 Replies

8. Programming

How to limit max no of message in a posix message queue

Hii can anyone pls tell how to limit the max no of message in a posix message queue. I have made changes in proc/sys/fs/mqueue/msg_max But still whenever i try to read the value of max. message in the queue using attr.mq_curmsgs (where struct mq_attr attr) its giving the default value as 10.... (0 Replies)
Discussion started by: mohit3884
0 Replies

9. Solaris

To print Coloured Prelogin Message on SOLARIS--9................

Hiiii..... Every one...... I am using /etc/issue file to display Pre-login Message on my system, installed with SOLARIS-9. I am getting this Message in White fonts having Black background ( Colour of the Screen)..... So, is there ... (2 Replies)
Discussion started by: prashantshukla
2 Replies

10. Programming

How to implement SIGKILL and SIGTERM and print a message?

Hello, I am running a webserver that uses sockets, forks, and children. The parent process listens for connections and the child processes the information. I am trying to figure out why the code I have below SIGTERM, and SIGKILL never fire. I was messing around with the printfs and doesnt... (11 Replies)
Discussion started by: norelco55
11 Replies
Login or Register to Ask a Question