# Print message while using sqlplus

**URL:** <https://community.unix.com/t/print-message-while-using-sqlplus/329088>\
**Category:** UNIX for Advanced & Expert Users\
**Created:** [May 23, 2013, 10:01am UTC](https://community.unix.com/t/print-message-while-using-sqlplus/329088 "2013-05-23T10:01:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![millan](https://community.unix.com/letter_avatar/millan/32/6_22734026db12803ebb3e059622ac3534.png) [@millan](https://community.unix.com/u/millan)\
**Post date:** [May 23, 2013, 10:01am UTC](https://community.unix.com/t/print-message-while-using-sqlplus/329088/1 "2013-05-23T10:01:27Z")

</div>

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.

```nohighlight
 
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.

---

<div class="post-metadata">

**Author:** ![Yoda](https://community.unix.com/user_avatar/community.unix.com/yoda/32/2498_2.png) [@Yoda](https://community.unix.com/u/Yoda)\
**Post date:** [May 23, 2013, 10:56am UTC](https://community.unix.com/t/print-message-while-using-sqlplus/329088/2 "2013-05-23T10:56:55Z")

</div>

> [@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:

```plaintext
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:

```plaintext
echo " dropping the table1" | tee logfile
DROP TABLE Table1
echo "creating the table1" | tee logfile

```

You should perform below modification:

```plaintext
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

```
