Difference between revisions of "CREATE PROCEDURE"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Creates a stored procedure in a database | Creates a stored procedure in a database | ||
Line 11: | Line 4: | ||
==Syntax== | ==Syntax== | ||
− | CREATE PROCEDURE [<database>!]<procname> AS | + | CREATE PROCEDURE [<database>!]<procname> AS <procedure source code> |
− | <procedure source code> | + | |
ENDCREATE | ENDCREATE | ||
==See Also== | ==See Also== | ||
− | [[ADATABASES()]], [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[BACKUP DATABASE]], [[CLOSE DATABASES]], [[CLOSE TABLES]], [[COMPILE DATABASE]], [[CREATE DATABASE]], [[CREATE TABLE]], [[CREATE INDEX]], [[CREATE VIEW]], [[DATABASE()]], [[DB_DATADIR]], [[DBUSED()]], [[DISPLAY DATABASE]], [[DISPLAY INDEXES]], [[DISPLAY TABLES]], [[DROP DATABASE]], [[DROP INDEX]], [[DROP PROCEDURE]], [[DROP TABLE]], [[GETENV()]], [[LIST DATABASE]], [[LIST INDEXES]], [[LIST TABLES]], [[OPEN DATABASE]], [[PACK DATABASE]], [[REBUILD DATABASE]], [[REINDEX DATABASE]], [[RESTORE DATABASE]], [[SET AUTOCATALOG]], [[SET EXCLUSIVE]], [[SET SQL]], [[SQL USE|USE]] | + | [[ADATABASES()]], [[ADD TABLE]], [[ALTER INDEX]], [[ALTER TABLE]], [[BACKUP DATABASE]], [[CLOSE DATABASES]], [[CLOSE TABLES]], [[COMPILE DATABASE]], [[CREATE DATABASE]], [[CREATE TABLE]], [[CREATE INDEX]], [[CREATE VIEW]], [[DATABASE()]], [[DB_DATADIR]], [[DBUSED()]], [[DISPLAY DATABASE]], [[DISPLAY INDEXES]], [[DISPLAY TABLES]], [[DROP DATABASE]], [[DROP INDEX]], [[DROP PROCEDURE]], [[DROP TABLE]], [[GETENV()]], [[LIST DATABASE]], [[LIST INDEXES]], [[LIST TABLES]], [[OPEN DATABASE]], [[PACK DATABASE]], [[REBUILD DATABASE]], [[REINDEX DATABASE]], [[RESTORE DATABASE]], [[SET AUTOCATALOG]], [[SET DATADIR]], [[SET EXCLUSIVE]], [[SET SQL]], [[SQL USE|USE]] |
==Description== | ==Description== | ||
− | The CREATE PROCEDURE command creates a new stored procedure in a database. If the database name, <database>!, is specified, the stored procedure will be created in that database, otherwise the stored procedure will be created in the currently open database. If no database is open and no <database>! is specified, an error occurs | + | The CREATE PROCEDURE command creates a new stored procedure in a database. If the database name, <database>!, is specified, the stored procedure will be created in that database, otherwise the stored procedure will be created in the currently open database. If no database is open and no <database>! is specified, an error occurs. No file extension should be included in <procname>: the file will be given a '.prg' file extension. |
− | Databases in Recital are implemented as directories containing files that correspond to the tables and associated files in the database. Operating System file protection can be applied individually to the files for added security. The directories are sub-directories of the Recital data directory. The environment variable | + | Databases in Recital are implemented as directories containing files that correspond to the tables and associated files in the database. Operating System file protection can be applied individually to the files for added security. The directories are sub-directories of the Recital data directory. The environment variable DB_DATADIR points to the current Recital data directory and can be queried using the GETENV() function. Files from other directories can be added to the database using the ADD TABLE command or via the database catalog and SET AUTOCATALOG functionality. The SET DATADIR command can also be used to set the default data search directory. |
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
OPEN DATABASE southwind | OPEN DATABASE southwind | ||
CREATE PROCEDURE creaxml AS | CREATE PROCEDURE creaxml AS | ||
− | SELECT orders.orderid, orders.customerid, employees.employeeid, employees.lastname, | + | SELECT orders.orderid, orders.customerid, employees.employeeid,; |
− | + | employees.lastname, employees.firstname, orders.orderdate,; | |
− | orders.shipvia, orders.shipname, orders.shipaddress, orders.shipcity, orders.shipregion, | + | orders.freight, orders.requireddate, orders.shippeddate,; |
− | + | orders.shipvia, orders.shipname, orders.shipaddress, orders.shipcity,; | |
− | + | orders.shipregion, orders.shippostalcode, orders.shipcountry,; | |
− | FROM orders INNER JOIN customers ON customers.customerid = orders.customerid, | + | customers.companyname, customers.address, customers.city,; |
− | orders INNER JOIN employees ON orders.employeeid = employees.employeeid | + | customers.region, customers.postalcode, customers.country; |
+ | FROM orders INNER JOIN customers; | ||
+ | ON customers.customerid = orders.customerid,; | ||
+ | orders INNER JOIN employees; | ||
+ | ON orders.employeeid = employees.employeeid; | ||
SAVE AS XML orderinfo | SAVE AS XML orderinfo | ||
ENDCREATE | ENDCREATE | ||
− | |||
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | Recital Server, Recital |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
[[Category:Commands]] | [[Category:Commands]] |
Latest revision as of 11:05, 23 December 2009
Purpose
Creates a stored procedure in a database
Syntax
CREATE PROCEDURE [<database>!]<procname> AS <procedure source code>
ENDCREATE
See Also
ADATABASES(), ADD TABLE, ALTER INDEX, ALTER TABLE, BACKUP DATABASE, CLOSE DATABASES, CLOSE TABLES, COMPILE DATABASE, CREATE DATABASE, CREATE TABLE, CREATE INDEX, CREATE VIEW, DATABASE(), DB_DATADIR, DBUSED(), DISPLAY DATABASE, DISPLAY INDEXES, DISPLAY TABLES, DROP DATABASE, DROP INDEX, DROP PROCEDURE, DROP TABLE, GETENV(), LIST DATABASE, LIST INDEXES, LIST TABLES, OPEN DATABASE, PACK DATABASE, REBUILD DATABASE, REINDEX DATABASE, RESTORE DATABASE, SET AUTOCATALOG, SET DATADIR, SET EXCLUSIVE, SET SQL, USE
Description
The CREATE PROCEDURE command creates a new stored procedure in a database. If the database name, <database>!, is specified, the stored procedure will be created in that database, otherwise the stored procedure will be created in the currently open database. If no database is open and no <database>! is specified, an error occurs. No file extension should be included in <procname>: the file will be given a '.prg' file extension.
Databases in Recital are implemented as directories containing files that correspond to the tables and associated files in the database. Operating System file protection can be applied individually to the files for added security. The directories are sub-directories of the Recital data directory. The environment variable DB_DATADIR points to the current Recital data directory and can be queried using the GETENV() function. Files from other directories can be added to the database using the ADD TABLE command or via the database catalog and SET AUTOCATALOG functionality. The SET DATADIR command can also be used to set the default data search directory.
Example
OPEN DATABASE southwind CREATE PROCEDURE creaxml AS SELECT orders.orderid, orders.customerid, employees.employeeid,; employees.lastname, employees.firstname, orders.orderdate,; orders.freight, orders.requireddate, orders.shippeddate,; orders.shipvia, orders.shipname, orders.shipaddress, orders.shipcity,; orders.shipregion, orders.shippostalcode, orders.shipcountry,; customers.companyname, customers.address, customers.city,; customers.region, customers.postalcode, customers.country; FROM orders INNER JOIN customers; ON customers.customerid = orders.customerid,; orders INNER JOIN employees; ON orders.employeeid = employees.employeeid; SAVE AS XML orderinfo ENDCREATE
Products
Recital Server, Recital