存储过程103
‘壹’ 如何调用oracle中的存储过程了
你的参数变换的种类多吗,我们做报表,每天晚上把所有的参数变换都做一次分析,然后保存在一个中间表中,前台WEB页面查询的实际上是中间表的结果!
<?
$conn=mssql_connect("127.0.0.1","user","passwd");
mssql_select_db("mydb");
$stmt=mssql_init("pr_name",$conn);//
$a=50001;
mssql_bind($stmt,"RETVAL",$val,SQLVARCHAR);//用于直接返回return
-103此类的值。
mssql_bind($stmt,"@outvar",$b,SQLVARCHAR,true);//用于返回在存储过程中定义的输出参数
mssql_bind($stmt,"@invar",$a,SQLINT4);
$result=
mssql_execute($stmt,true);//不能返回结果集,只能得到输出参数
//$result=
mssql_execute($stmt,false);//返回结果集
//$records=mssql_fetch_array($result);
//print_r($records);
//mssql_next_result($result);下一个结果集,当等于FALSE的时候下一个就是输出参数
echo$b;
echo$val;
?>
‘叁’ MYSQL中使用存储过程中,变量怎么使用
①由ρ=mV得:酒的质量m酒=ρ酒V=0.9×103kg/m3×500×10-6m3=0.45kg=450g;②倒出一半后,质量和体积减小一半,但密度是不变的,仍然等于0.9×103kg/m3;③装满水时水的质量m水=ρ水V=1.0×103kg/m3×500×10-6m3=0.5kg,可见总质量比装酒时多.故答案为:450;0.9×103;多.
‘肆’ PL/SQL 存储过程出错
我试验了,你的代码写的大体没有错误,只有一点点问题。
改成下面这样后,在我的电脑上过了,你试试吧。
update index_check_log cc
set cc.diff_time = to_date(v_ft - v_bt)
where cc.id_log = r1.id_log;
***********
试试log:
***********
[TEST@ORA1] SQL>create or replace procere p_index_check is
2 v_sql varchar2(2048);
3 v_bt timestamp;
4 v_ft timestamp;
5 cursor c1 is select * from index_check_log;
6 Begin
7 for rr in c1 loop
8 v_sql := rr.sql_statement;
9 update index_check_log aa
10 set aa.v_begin_time = (to_char(systimestamp, 'yyyy-mm-dd hh24:mi:ssxff'))
11 where aa.id_log = rr.id_log;
12
13 v_bt := systimestamp;
14 execute immediate v_sql;
15 v_ft := systimestamp;
16 update index_check_log bb
17 set bb.v_finish_time = (to_char(systimestamp, 'yyyy-mm-dd hh24:mi:ssxff'))
18 where bb.id_log = rr.id_log;
19
20 update index_check_log cc
21 set cc.diff_time = to_date(v_ft - v_bt)
22 where cc.id_log = rr.id_log;
23 End loop;
24 End;
25 /
Procere created.
---
以上,希望对你有所帮助。
‘伍’ 求高手写ORACLE存储过程
--仅仅用于模拟你的测试数据。
CREATETABLEtest_ll(
IDINT,
ongitudeINT,
latitudeINT
);
INSERTINTOtest_ll
SELECT1,100,30FROMalUNIONALL
SELECT1,101,30FROMalUNIONALL
SELECT1,103,30FROMalUNIONALL
SELECT1,110,31FROMalUNIONALL
SELECT1,110,32FROMalUNIONALL
SELECT1,110,33FROMal;
--模拟你的函数.
(
lat1INT,lng1INT,lat2INT,lng2INT
)
RETURNINTIS
BEGIN
RETURNABS(lat1-lat2)+ABS(lng1-lng2);
END;
/
SELECT
ID,
latitude,
ongitude,
LAG(latitude,1)OVER(ORDERBYid)AS"上一行_La",
LAG(ongitude,1)OVER(ORDERBYid)AS"上一行_Ln",
getdistance(latitude,ongitude,LAG(latitude,1)OVER(ORDERBYid),LAG(ongitude,1)OVER(ORDERBYid))AStmpResult
FROM
test_ll;
IDLATITUDEONGITUDE上一行_La上一行_LnTMPRESULT
------------------------------------------------------------
130100
130101301001
1331103010112
131110331102
132110311101
130103321109
已选择6行。
‘陆’ ORACLE数据库存储过程,转义符问题
sql_de1varchar2(200)中200之太小了,超出delete语句的长度,将其改为sql_de1varchar2(2000)
‘柒’ 如何设置sql server的最大连接数
设置最大连接数
下面的T-SQL 语句可以配置SQL Server 允许的并发用户连接的最大数目。
exec sp_configure 'show advanced options', 1
exec sp_configure 'user connections', 100
第一句用以表示显示sp_configure 系统存储过程高级选项,使用user connections 时,要求show advanced options 值为1。
第二句配置最大连接数为100,0 表示不限制,但不表示无限,后面将谈谈。
也可以在企业管理器中配置,在企业管理器中,可以在实例上点右键->“属性”->“连接”里面更改。
需要重新启动SQL Server,该值才会生效。
@@max_connections
select @@max_connections
它总是返回32767,它并不是指上面设置的user connections,实际上它表示user connections 最大可设置为多少。由于它的最大值是32767,那么user connections 为0 时,最大连接数也就是32767 了,并不是无限。
默认情况下user connections 值是0,也就是说默认情况下SQL Server 的最大连接数是32767。
获得当前设置的最大连接数:
select value from master.dbo.sysconfigures where [config]=103
如何监测SQLServer的连接数
/*查询连接数*/
select loginame,count(1) as Nums
from sys.sysprocesses
group by loginame
order by 2 desc
select spid,ecid,status,loginame,hostname,cmd,request_id
from sys.sysprocesses where loginame='' and hostname=''
方法二:
SP_WHO 'loginName'
loginName 是当然登陆Sql的用户名,一般程序里面都会使用一个username来登陆SQL这样通过这个用户名就能查看到此用户名登陆之后占用的连接了。
如果不写loginName,那么返回的就是所有的连接。
既然连接数是可预测、可监测的,那么它就是可度量的,那么我们就可以根据实际情况来评估或测试程序的并发放量了。
‘捌’ SQL里如何把查询得到的内容作为属性名
这个玩意儿太难了,我整整弄了一个下午,而且还查了不少材料,现在基本完成楼主你要的功能了,表结构是参照楼主来的,改改字段名就能用。先把代码都拷过去,跑一下,就知道效果了。
if exists(select * from sysobjects where name='xs')
drop table xs
create table xs
(
id char(5) primary key not null,
xm varchar(10) not null
)
insert into xs values ('10001','张三')
insert into xs values ('10002','李四')
insert into xs values ('10003','一五')
insert into xs values ('10004','田七')
if exists (select * from sysobjects where name='km') drop table km
create table km
(
id char(3) primary key not null,
mc varchar(20) not null
)
go
insert into km values ('101','java')
insert into km values ('102','C#')
insert into km values ('103','sql')
insert into km values ('104','html')
insert into km values ('105','xml')
if exists (select * from sysobjects where name='cj') drop table cj
create table cj
(
xhid char(5) references xs(id) not null,
kmid char(3) references km(id) not null,
cj float
)
go
insert into cj values ('10001','101',89)
insert into cj values ('10002','101',95)
insert into cj values ('10003','101',80.5)
insert into cj values ('10001','103',90)
insert into cj values ('10003','102',66)
insert into cj values ('10003','103',75)
insert into cj values ('10003','104',50)
insert into cj values ('10002','102',72)
insert into cj values ('10002','103',78)
insert into cj values ('10001','104',100)
insert into cj values ('10004','105',99)
--select * from xs
--select * from km
--select * from cj
--创建一个联接表临时表
if exists(select * from sysobjects where name='temp1')
drop table temp1
go
select c.xhid,a.xm,b.mc,c.cj into temp1 from xs a,km b,cj c where a.id=c.xhid and b.id=c.kmid
select * from temp1
----根据科目表创建一个新科目的表,新增字段id并递增,便于根据科目循环控制,前提是科目表中编号与成绩表中的科目编号主外键联
if exists(select * from sysobjects where name='temp2')
drop table temp2
go
select mc ,num=identity(int, 1,1) into temp2 from km group by mc
declare @sql varchar(8000),@t varchar(20), @n int
select @sql='', @n=max(num) from temp2
while @n>0
begin
select @t=mc from temp2 where num=@n
set @sql=',sum(case mc when '''+ @t + ''' then cj else '' '' end ) as '+ @t + @sql
set @n = @n - 1
end
set @sql = 'select xhid,xm' + @sql + ' from temp1 group by xhid,xm order by xhid'
exec(@sql)
--删除临时表
drop table temp1,temp2
兄弟,我不容易啊,好四五个小时啊,头都大了,这么辛苦,没别的,给分啊 ^_^
‘玖’ orcale统计报表存储过程怎么想写以及怎么调用
create or replace procere orderuser(cid in number,startime in varchar2,endtime in varchar2) is
begin
for i in(select c.id,c.name,sum(decode(state,1,1,0)) type1,sum(decode(state,2,1,0)) type2,count(c.id) ordernum,sum(b.atm) moneynub,count(b.id) nousenum,count(b.id)/sum(b.id)*100 useper
from a,b,c
where
a.id=b.aid and a.cid=c.id and c.id=cid and to_char(b.createdate,'yyyy-mm-dd')>startime and to_char('b.createdate','yyyy-mm-dd')<endtime and c.id in(102,103,104) and a.id not in (selece aid from b) group by c.id,c.name) loop
dbms_output.put_line(i.id||i.name);
end loop;
end;
--调用
exec orderuser(100,'2012-09-10','2012-09-15');
大概是这个玩意,你自己调试一下语法和你想要的输出结果就行了