日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

INFORMIX IDS11.5 動態(tài)存儲過程(DYNAMIC SPL) - INFORM...

 snowlewolf 2009-11-19
INFORMIX IDS11支持 動態(tài)存儲過程。本文通過舉例的方法演示如何在INFORMIX中創(chuàng)建動態(tài)存儲過程。
EXAMPLE 1 
說明 EXECUTE IMMEDIATE 語句
可以通過參數(shù)名來動態(tài)執(zhí)行不同的表
DATABASE stores_demo;
   
CREATE PROCEDURE create_tab (table_name CHAR(128), column_list CHAR(512))
   DEFINE l_crtstmt   CHAR(1024);
   LET l_crtstmt = "CREATE TABLE " || table_name ||"("|| column_list || " )";  --動態(tài)語句,存放到一個變量中
   EXECUTE IMMEDIATE l_crtstmt;          --動態(tài)執(zhí)行SQL
END PROCEDURE;
執(zhí)行存儲過程
EXECUTE PROCEDURE create_tab ("tmp_cust","cust_num INTEGER,cust_fname CHAR(30)");

--------------------------------------------------------------------------------
EXAMPLE 2
說明在SPL中如何利用游標和動態(tài)語句
DATABASE stores_demo;
-- Procedure to dynamically constructs query `cust_qry' using supplied
-- table_name and returns all rows whose first name is the supplied
-- first_name
CREATE PROCEDURE customer_details(table_name CHAR(30),first_name CHAR(30))
RETURNING INTEGER, CHAR(30), CHAR(30), CHAR(30);
   DEFINE cust_qry VARCHAR(250);
   DEFINE l_cust_num INTEGER;
   DEFINE l_fname CHAR(30);
   DEFINE l_lname CHAR(30);
   DEFINE l_state CHAR(30);
   -- Construct a Dynamic query using SPL argument table_name
   LET cust_qry = "select customer_num, fname, lname, state from "
||table_name || " where fname = ?";
   -- Prepare the above constructed query
   -- Get the statement handle "statement_id"
   PREPARE stmt_id FROM cust_qry;
-- Declare the cursor for the prepared "statement_id"
-- get the cursor handle "cust_cur"
DECLARE cust_cur cursor FOR stmt_id;
           -- Open the declared cursor using handle "cust_cur"
           -- Supply the first_name as an input. This will be
           -- substituted in the place of "?" in the query
 
本文來自CSDN博客,轉(zhuǎn)載請標明出處:http://blog.csdn.net/ibminformix/archive/2009/11/19/4833481.aspx

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多