Exporting Oracle Database stored procedures

Source: Internet
Author: User
Oracle| stored Procedure | data | database

Project is over, want to write their own stored procedures exported to save a copy of this write a simple script, take out to share with you. In fact, it is very simple, mainly used to User_procedures, user_source Two views, we can see that.

It seems that some of the online search is not comprehensive enough, and fragmented, if you feel good to support it, '

#! /usr/bin/ksh
. ~/.profile

Begintime= ' date +%y year%m month%d%h%m minutes%s seconds '


Bindir=~/work/common
Prodir=~/work/common/procedure

#连接数据库 (with parameter-s)
ora_s ()
{
~/cfg/dbetl_s
}

#连接数据库 (with no parameters)
ORA ()
{
~/cfg/dbetl
}

#获得存储过程名称
Getprocedurename ()
{
ora_s <<! >${bindir}/procedure.lst

Set heading off;
SET FEEDBACK off;
Set pagesize 0;
Set Wrap off;
Set echo off;
Set term off;
Set Linesize 1000;
Set Trimspool on;

Select object_name from User_procedures;

Exit
!

}

#导出存储过程代码
Exportproceduresource ()
{
ora_s <<! >${prodir}/${procedure_name}.sql

Set serveroutput on;
Set heading off;
SET FEEDBACK off;
Set pagesize 0;
Set Wrap off;
Set echo off;
Set term off;
Set Linesize 1000;
Set Trimspool on;

Select text from User_source a where a.name = ' ${procedure_name} ' order by A.line;

Exit
!

}


##################### Mian ##########################

Getprocedurename

mkdir Prodir

While Read procedure_name
Todo

Exportproceduresource

Done<${bindir}/procedure.lst


echo "Begin at ${begintime}"
echo "End at ' date +%y year%m month%d%h%m minutes%s seconds '"




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.