Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 网络资源 > Connecting SQL*PLUS with a shell script
【标  题】:Connecting SQL*PLUS with a shell script
【关键字】:Connecting,SQL,PLUS,with,shell,script
【来  源】:http://www.cublog.cn/u/14784/showart.php?id=276443

Connecting SQL*PLUS with a shell script

Your Ad Here
Here's a piece that allows to execute select statements on an Oracle database from a shell script. It consists of two parts: a shell function (read_sql_stmt) and the part that actually uses the function.
#!/bin/bash

read_sql_stmt() {
  typeset stmt=$1
  typeset login=$2

  echo "
    set feedback off verify off heading off pagesize 0
    $stmt;
    exit 
  " |  sqlplus -s  $login
}
The second part: read_sql_stmt is executed with an SQL statement and a login, its output is piped into an ordinary shell while loop:
read_sql_stmt "select username, user_id from dba_users" "system/system_pw" | while read u i 
do
  echo "user $u has userid $i"
done  
Oracle's V$ Views:【上一篇】
Integrity Constraints [Oracle]:【下一篇】
【相关文章】
  • MYSQL where 筛选数据问题
  • [mysql cook book mysql 菜谱] 第一章: 使用mysql客户端 -1
  • One scripts to restore all metadevice over cluster
  • 用PowerShell下载网页
  • Linux下Shell基础知识简介
  • Effective Code Reviews Without the Pain
  • shape文件存入PostgreSQL数据库初探
  • SQL Server 2000中的数据转换服务 (DTS)
  • SQLPLUS输出结果
  • 新PL/SQL程序包问题探讨
  • 【随机文章】
  • Struts+Spring+Hibernate上传下载--之三
  • 显示TCP连接数脚本
  • COM组件设计与应用14 - 事件和通知(vc.net)
  • 以原始套接字的方式 截获流经本机网卡的IP数据包
  • 如果你真要学TORQUE,花$100值! (It's worth buying your own Torque Engine)
  • 光接入网
  • 访问简单变量总是快于数组元素值
  • 浅析LMDS多点分配接入技术(8)
  • HOW TO:操作定长字符串
  • AJAX设计策略(八)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.