Creates a stored procedure in a database
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
https://www.lianja.com/doc/index.php/CREATE_PROCEDURE
OPEN DATABASE southwind // Removes a stored procedure from a database DROP PROCEDURE creaxml
https://www.lianja.com/doc/index.php/DROP_PROCEDURE
Compile stored procedure files in the specified database or databases
compile database southwind
https://www.lianja.com/doc/index.php/COMPILE_DATABASE
Mark an SQL cursor as a resultset
function GetExampleCursor lparameters lcAccountNo select * from example where account_no = lcAccountNo into cursor curExample return setresultset("curExample") open database southwind GetExampleCursor("00050") select * from curexample ? "Cleared resultset marker in work area #" + ltrim(str(clearresultset())) ? iif(getresultset() > 0,"Resultset available in work area #" + ltrim(str(getresultset())),; "No resultsets available") ? close databases
https://www.lianja.com/doc/index.php/SETRESULTSET()
Clear the marker from an SQL cursor previously marked as a resultset
function GetExampleCursor lparameters lcAccountNo select * from example where account_no = lcAccountNo into cursor curExample return setresultset("curExample") open database southwind GetExampleCursor("00050") select * from curexample ? "Cleared resultset marker in work area #" + ltrim(str(clearresultset())) ? iif(getresultset() > 0,"Resultset available in work area #" + ltrim(str(getresultset())),; "No resultsets available") ? close databases
https://www.lianja.com/doc/index.php/CLEARRESULTSET()
Return the workarea number of an SQL cursor previously marked as a resultset
function GetExampleCursor lparameters lcAccountNo select * from example where account_no = lcAccountNo into cursor curExample return setresultset("curExample") open database southwind GetExampleCursor("00050") select * from curexample ? "Cleared resultset marker in work area #" + ltrim(str(clearresultset())) ? iif(getresultset() > 0,"Resultset available in work area #" + ltrim(str(getresultset())),; "No resultsets available") ? close databases
https://www.lianja.com/doc/index.php/GETRESULTSET()
Description of the input, output and results associated with stored procedures
SELECT * FROM sysprocedurecolumns
https://www.lianja.com/doc/index.php/SYSPROCEDURECOLUMNS
Description of the stored procedures available in the catalog
SELECT * FROM sysprocedures
https://www.lianja.com/doc/index.php/SYSPROCEDURES
Executing Procedures and Prepared Statements using Lianja SQL
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 drop procedure creaxml
The prepare statement is used to set up an SQL statement for subsequent execution.
stmtbuf = "select * from example where account_no = ?" prepare mystmt from :stmtbuf m_acc = "00002" execute mystmt using :m_acc m_acc = "00003" execute mystmt using :m_acc stmtbuf = "insert into example (account_no, last_name, forename) values (?,?,?)" prepare mystmt from :stmtbuf buf1 = "99999" buf2 = "Smith" buf3 = "John" execute mystmt using :buf1, :buf2, :buf3 stmtbuf = "delete from example where account_no = ?" prepare mystmt from :stmtbuf buf1 = "99999" execute mystmt using :buf1
The execute immediate statement is used to prepare and execute immediately a delete, insert, or update SQL statement.
execute immediate select * from example where account_no = m_acc
The sysresultset system table returns the singleton result from any Lianja expression.
select set("exclusive") as excl, time() as time from sysresultset
https://www.lianja.com/doc/index.php/Using_Recital_SQL
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
drop procedure creaxml
stmtbuf = "select * from example where account_no = ?" prepare mystmt from :stmtbuf m_acc = "00002" execute mystmt using :m_acc m_acc = "00003" execute mystmt using :m_acc stmtbuf = "insert into example (account_no, last_name, forename) values (?,?,?)" prepare mystmt from :stmtbuf buf1 = "99999" buf2 = "Smith" buf3 = "John" execute mystmt using :buf1, :buf2, :buf3 stmtbuf = "delete from example where account_no = ?" prepare mystmt from :stmtbuf buf1 = "99999" execute mystmt using :buf1
execute immediate select * from example where account_no = m_acc
select set("exclusive") as excl, time() as time from sysresultset
https://www.lianja.com/doc/index.php/Using_Lianja_SQL