---
title: "Linux bash中存储过程的调用"
author: "jilin"
date: "2017-09-02T17:09:44Z"
tags: []
categories: ["数据库"]
slug: "linux-bash"
draft: false
lastmod: "2017-09-02T17:09:44Z"
id: 2391949
url: "https://jilin.iteye.com/blog/2391949"
---

在bash中调用存储过程，需要模拟sqlplus输入，通过&lt;&lt;管道与EOF结尾标识处理。

```
#!/bin/bash
user=aps2
passwd=aps2
sid=192.168.11.129/orcl

#there is no space before last EOF
function call_procedure()
{
value=`sqlplus -s /nolog << EOF
conn ${user}/${passwd}@${sid};
call $1;
quit;
EOF`;#此处的EOF不能有空格，之前我的就一直报需要EOF结束就是次原因
}

call_procedure 'P_S01_CORP_CUST_BASIC_INFO()'  #存储过程的名字作为参数数
call_procedure 'P_S05_LOAN_ACCT_FIN_EVT()'
```