How to use the extended stored procedures of the Sybase ASE database

Source: Internet
Author: User
Tags command line sybase

We've been using ASE for a long time, in the use of the process, in-depth understanding of its various functions, but for the extended stored procedures are basically not mentioned in the book, the Forum does not appear to have such problems, but it does solve some of the special problems, and the function is very powerful, I have studied this specifically and now share the results with you.

Sometimes you might have the need to do something with the server, such as copying files, starting or stopping certain services and programs, and so on. In general this case, PB can do nothing, only auxiliary to a large number of API functions, and often through the server operating system complex permissions control, Then you have to perform some operations, which are not generally available to PB developers. Extended stored procedures provide a convenient way for us.

1. Common Extended stored procedures:
xp_cmdshell: Performs certain operations on the server side as a command line. The command line function is very powerful and can almost do anything.

Extended stored procedures for the 2.mail series.

3. Custom stored procedures, in order to achieve some special features.

Here's how to use extended stored procedures, mainly with xp_cmdshell:

First, the extension of the stored procedure is the same as that of the ordinary procedure;

Similarly, you must have permission to invoke the extension process;

There is a special place for xp_cmdshell: It enforces more restrictive permissions and, even with SA privileges, cannot be executed by default, and you must restart the server using sp_configure to modify the server Configuration "xp_cmdshell context" to 0. Has the ability to own a permission.

Here we start by xp_cmdshell, get the server time, very simple:

Open the PB database artboard, connect to the database with the SA user, and enter:

exec xp_cmdshell ' date ';

The system will return the server time.

Then we perform a copy of the C: Disk file Test.txt Copy to D: Disk:

exec xp_cmdshell "copy c:\test.txt d:\test.txt";

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.