Jump to content


** Arena Jovem **

Member Since 19/11/2008
Offline Last Active 19/06/2009, 09:03
-----

Posts I've Made

In Topic: Qual A Sintaxe Da Stored Procedure E Dos Triggers?

10/06/2009, 15:52

Tenta dar uma olhada neste site lá tem tudo...

http://db.apache.org...fsqlj26498.html

Eu tenho a seguinte tabela


codigo      nome      telefone    endereco
1              teste        222222      rua abc
2              teste2      344556      rua end

como eu uso o stored procedure pra incluir um novo reg ,e pra alterar o nome do codigo 1?

alguem tem um exemplo de triggers?

Valeu
Até Mais


In Topic: [Resolvido] FunçãO Asp

14/05/2009, 16:30

Valeu Renan ..

Eu consegui resolver de outra maneira...

da uma olhada ai!!!!


abraçossss

seleciona o ano
			   var_fun_data=CStr(year(now))  
		seleciona os dois ultimos digitos do ano
				   var_ano_login=Right(var_Fun_Data,2)
	 
	 var_login_ano="M"&var_ano_login
	 var_login= var_login_ANO & string(8-len(var_mrc_login),"0") & var_mrc_login


	sql="select ms_codigo from mercosul_sequencial"
			rs_mrc=func_open(sql,1)
			if isarray(rs_mrc) then
				var_mrc=rs_mrc(0,0)
			end if
		

		var_mrc_login=var_mrc+1


		   e Por Fim 
				 
					var_login_ano="M"&var_ano_login
		var_login= var_login_ANO & string(8-len(var_mrc_login),"0") & var_mrc_login

Acho que isso pode lhe ajudar! ;-)
Script:

Function parametrizaLogin(login)

		Dim padrao : padrao = "00000000"
		Dim aux : aux = ""

		aux = Left(padrao, (Len(padrao) - Len(login))) & login
		parametrizaLogin = aux

	End Function

	Dim login1 : login1 = "1"
	Dim login2 : login2 = "10"
	Dim login3 : login3 = "11"
	Dim login4 : login4 = "200"
	Dim login5 : login5 = "1500"

	response.write "Login1: "& parametrizaLogin(login1) &"<br/>" &_
				   "Login2: "& parametrizaLogin(login2) &"<br/>" &_
				   "Login3: "& parametrizaLogin(login3) &"<br/>" &_
				   "Login4: "& parametrizaLogin(login4) &"<br/>" &_
				   "Login5: "& parametrizaLogin(login5) &"<br/>"
Retorno:
Login1: 00000001
Login2: 00000010
Login3: 00000011
Login4: 00000200
Login5: 00001500
Faça uns testes e confirme se estiver ok, mas se achar erro "melhor ainda" que ai a função fica legal (sem erros)!
Como disse um grande Gerente de Proj.: " Um bom testador é aquele que encontra erro no sistema 'perfeito'! "


In Topic: [Resolvido] FunçãO Asp

14/05/2009, 10:08

OK quase resolvido..

usei o seguinte

var_mrc_login=1

string(8-len(var_mrc),"x") & var_mrc_login
resultado
-> (xxxxxxx1) <-

mas tem um porem esse numero não pode passar de 8 digitos , quando a var_mrc_login=10 elefica com 9 digitos

xxxxxxxx1

mas quando a var_mrc_login=11 fica ok

-> (xxxxxx11) <-


alguem ai sabe oque pode estar acontecendo??

abraçosss

Boa tarde Galera..

Bom estou um um probleminha


Tenho um String1=000000000

e tenho outra String2=5

preciso fazer o seguinte...


tenho que unir elas..

a primeira String1 ela possue 9 zeros, preciso que o ultimo zero seja substituido pelo valor da string2

exempro:

A STRING DEVERIA SER ASSIM:
STRING3="000000005"

PARA ISSO PRECISO DE UMA FUNÇÃO ....

ALGUEM CONHECE ALGUMA FUNÇÃO QUE FAÇA ISSO???

xxxxxx

ABRAÇOSSS


In Topic: Spam

16/12/2008, 11:09

Valew vou dar um lida sim

brigadao abraçossss

In Topic: Valor Não é Enviado

15/12/2008, 15:27

Está passando vazio porque você não colocou um value no checkbox. Deixe com um valor padrão - 1, por exemplo. Na parte do asp você só verifica se ele existe ou se é 1.



na verdade meu codigo e o seguinte.

e meio complexo...
form
<!--#include virtual="/includes/lms_top.asp"-->
<%


' -------------------------------------------------------------------------------------------------
' CONFIGURAÇÃO DA TAG <BODY>
' Definição das constantes

	const ind_exibicao_img_background 	= false				'Exibe a imagem padrão do módulo em background.
	const ind_menu_contexto 			= false				'Habilita o MENU DE CONTEXTO.
	const ind_onhelp 					= true				'Habilita F1 para AJUDA PERSONALIZADA.
	const str_onload 					= ""				'Ex.: Iniciar(); return false;
	const str_onunload 					= ""				'Ex.: Reload(); return true;

	dim str_adicional 'TAGS adicionais
	str_adicional = ""



' -------------------------------------------------------------------------------------------------
' APRESENTAÇÃO DO CONTEÚDO

	'Lista Cargos
'	sql_perfil = "Select * from Lms_Perfil_Usuario where cod_perfil_usuario<>6 order by des_perfil_usuario"
'	fx_open rs_perfil, sql_perfil, 1, 1, 1


%>

&lt;script language="javascript">
	function mostrarFoto(caminho)
	{
		if (caminho.replace(' ', '') != '')
		{
			caminho = caminho.replace('\\', '\\\\');
			document.frmInclusaoGestores.fotoView.src = caminho;
		}
		
	}
	
</script>


<!--#include virtual="/includes/lms_body.asp"-->

		<!-- CONTEÚDO return v.exec() -->
	<form ID="frmInclusaoGestores" name="frmDados" action="adm_gestor_inc2.asp"  method="post" enctype="multipart/form-data" >
	<table width="736" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="736" height="32" valign="top"><img src="/images/titulos/tit_gestores.jpg" width="375" height="32"></td>
		  </tr>
		  <tr>
			<td width="736" height="1" valign="top"><img src="/images/layout/linha_interna.jpg" width="736" height="1"></td>
		  </tr>
		  <tr>
			<td width="736" height="5" valign="top"><img src="/images/layout/spacer.gif" width="736" height="5"></td>
		  </tr>
		  <tr>
			<td>
			  <table height="317" cellSpacing=0 cellPadding=5 width=720 align=center bgColor=#ffffff border=0>
				<tbody>
				  <tr>
					<td vAlign=top>
					<table width="390" height="386" cellpadding="0" cellspacing="0" class="td_janela_full">
					  <tr>
						<td class="td_janela_titulo_full">Cadastro de Gestores </td>
					  </tr>
					   <tr>
					<td width="710" valign="top" style="padding-left:15;padding-right:15;padding-top:10;padding-bottom:10">							
					<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
					  <tr> 
					  <td width="80"> 
						  <table width="80" border="0" cellspacing="0" cellpadding="0" class="input_botao">
							<tr onClick="java script:history.back();" onMouseOver="this.className='input_botao_sel';" onMouseOut="this.className='input_botao';"> 
							  <td width="25" height="25" align="center"><img src="/images/icones/ico_16x16_voltar.gif" width="16" height="16"></td>
							  <td>Retornar</td>
							</tr>
						  </table>
						</td>
						<td width="1"> </td>
						<td width="80"> <table width="80" border="0" cellpadding="0" cellspacing="0" class="input_botao">
							<tr  onClick="java script:Verifica();"  onmouseover="this.className='input_botao_sel';" onMouseOut="this.className='input_botao';"> 
							  <td width="25" height="25" align="center"><img src="/images/icones/ico_16x16_atualizar.gif" width="16" height="16"></td>
							  <td>Gravar</td>
							</tr>
						  </table></td>
						
						<td width="1"> </td>
						<td width="80">
						<table width="80" border="0" cellspacing="0" cellpadding="0" class="input_botao">
							<tr onClick="java script:frmInclusaoGestores.reset();document.frmInclusaoGestores.fotoView.src = document.frmInclusaoGestores.fotoOrigem.value;" onMouseOver="this.className='input_botao_sel';" onMouseOut="this.className='input_botao';"> 
							  <td width="25" height="25" align="center"><img src="/images/icones/ico_16x16_limpar.gif" width="16" height="16"></td>
							  <td>Limpar</td>
							</tr>
						  </table>
						</td>
						<td width="100%">  </td>
					  </tr>
					</table>					  
					<br><br><br>
					
					<input type="hidden" name="fotoOrigem" id="fotoOrigem" value="\images\fotos_usuarios\no_foto.gif">
					<input type="hidden" name="unidadeSelecionada" id="unidadeSelecionada" value="">
					  <table width="100%" border='1' cellspacing='0' cellpadding='2' bordercolor="#EEEEEE" style="border: 2px solid #DFDFDF">
						<tr>
						  <td height="25">
							
							  <table width="100%"  border="0" cellspacing="0">
							  <br>
								<tr>
								  <td width="63" rowspan="7"><img src="\images\icones\no_foto.gif" border="0" id="fotoView" name="fotoView" width="60" height="70"  /></td>
								  <td width="90" height="28" id="t_nome">  Nome: [*]</td>								  
								  <td colspan="4"><input id="nome" name="nome" type="text" size="60" maxlength="50" class="input_texto">
								   <% call fx_Ajuda_Form ("usuario","usu_nome","Nome") %></td>
								</tr>
								<tr>
								  <td width="90" height="28" name="t_login" id="t_login">  Login: [*]</td>
								  <td colspan="2"><input id="login" name="login" type="text" size="16" maxlength="16" class="input_texto">
								  <% call fx_Ajuda_Form ("usuario","usu_id","Login") %>								  </td>
								   <td width="62" height="28" id="t_senha" name="t_senha">  Senha: [*]</td>
								   <td width="194" ><input id="senha" name="senha" type="password" size="12"  class="input_texto">
								  <% call fx_Ajuda_Form ("usuario","usu_cadastro","Senha") %>								   </td>								  
								</tr>
								 <tr>								 
								  <td width="90" height="28" id="t_unidade" name="t_unidade">  Unidade: [*]</td>
								  <td width="211" onClick="fx_Popup('../../_compartilhado/unidade.asp', 'nome', 'scroll=auto', '400', '350', 'true')" style="cursor:hand">
								  <input id="unidade" name="unidade" type="text" size="30" maxlength="38" class="input_texto">
								  <img onClick="fx_Popup('../../_compartilhado/unidade.asp', 'nome', 'scroll=auto', '400', '350', 'true')" style="cursor:hand" src="/images/icones/home.gif"></td>

								  <td width="38"> <% call fx_Ajuda_Form ("usuario","uni_codigo","Nome") %></td>

								   <td width="62" id="t_cargo">Cargo:</td>
								   	<td valign="baseline" >
										<iframe src="cargo_seleciona.asp" id="selecionaCargo" name="selecionaCargo" width="182px" height="30px"></iframe></select>
										<input type="hidden" name="car_codigo" id="car_codigo">								   </td>
								</tr>

								<tr>
								  <td width="90" height="28" id="t_foto" name="t_foto">  Foto: [*] </td>
								  <td colspan="4"><input onFocus="mostrarFoto(this.value)" id="foto" name="foto" type="file" size="50" maxlength="50" class="input_texto">								  
								   <% call fx_Ajuda_Form ("usuario","usu_arquivo_foto","Foto") %>								  </td>								  
								</tr>
								<tr>
								   <td width="90" height="28" id="t_email" name="t_email">  E-mail:</td>
								   <td width="211" ><input id="email" name="email" type="text" size="40" maxlength="50" class="input_texto"></td>
								   <td width="38"> <% call fx_Ajuda_Form ("usuario","uni_codigo","Nome") %></td>
								  <td colspan="3">  Email Ativo: 		
									   <select id="emailativo" name="emailativo">	
									   		<option value="0">Caixa Postal</option>
											<option value="1">Email externo</option>
											<option value="2">Ambos</option>
									   </select>
									   <% call fx_Ajuda_Form ("usuario","usu_email_ativo","Email Ativo") %>								  </td>
								</tr>
								
								<tr>
								  <td colspan="2"></td>
								</tr>
								
								<tr>
								  <td width="90" height="28">  Data de Nascimento:</td>
									<td width="211" ><input id="data" name="data" type="text" size="20" maxlength="20" class="input_texto">
								  <% call fx_Ajuda_Form ("usuario","usu_data_nascimento","Data de Nascimento") %>								  </td>
								  <td width="38"> </td>
								  
								  <td width="62" height="28">  Telefone:</td>
								  <td width="194"><input id="Text1" name="telefone" type="text" size="20" maxlength="20" class="input_texto">
								   <% call fx_Ajuda_Form ("usuario","usu_telefone","Telefone") %>								  </td>
								</tr>
								
								<tr>								
								  <td> </td>								  
								  <td>Permissão Tutoria </td>
								  <td> 
								   <input name="per_tutoria" type="checkbox" value=""></td>
								 <% call fx_Ajuda_Form ("usuario","per_tutoria","Permissao Tutoria") %>
								  <td> </td>
								  <td> </td>
								  <td> </td>
								</tr>
								<tr>
								  <td colspan="6">[*] Campo de preenchimento obrigatório</td>
								</tr>
							</table>
						  </td>
						</tr>
					  </table>
					 
					  </td>
					   </tr>
					  <tr>
						<td class="td_janela_bot_full"></td>
					  </tr>
					</table>
					</td>
				  </tr>
				</tbody>
			</table></td>
		  </tr>
		</table>
		 </form>
		
		
&lt;script language="JavaScript1.2" type="text/javascript">

//	document.frmInclusaoTutores.nome.focus();
//	var a_fields = {'nome':		{'l':'Nome',		'r':true,	'f':'texto',	't':'t_nome','mn':3,'mx':60},
//					'login':	{'l':'Login',		'r':true,	'f':'texto',	't':'t_login','mn':2,'mx':60},
//					'senha':	{'l':'Senha',		'r':true,	'f':'texto',	't':'t_senha','mn':2,'mx':60},
//					'unidade':	{'l':'Unidade',		'r':true,	'f':'texto',	't':'t_unidade','mn':2,'mx':60}},										
					//'foto':		{'l':'Foto',		'r':true,	'f':'texto',	't':'t_foto','mn':2,'mx':300}},

//		o_config = {'to_disable' : ['Submit', 'Reset'],'alert' : 1}

//	var v = new validator('frmInclusaoTutores', a_fields, o_config);
	
//function Send()
//{
//	document.frmInclusaoTutores.target='';
//	document.frmInclusaoTutores.action='adm_tutor_inc2.asp';
//	return v.exec();
	
//}	
	function Verifica()
	{		
		if(document.getElementById('nome').value== ""){
			alert('O campo Nome é de preenchimento obrigatório!');
			return;
		} 
		if(document.getElementById('login').value== ""){
			alert('O campo Login é de preenchimento obrigatório!');
			return;
		} 
		if(document.getElementById('senha').value== ""){
			alert('O campo Senha é de preenchimento obrigatório!');
			return;
		} 
		if(document.getElementById('unidade').value== ""){
			alert('É necessário que  Unidade seja selecionada!');
			return;
		} 
		if(document.getElementById('unidade').value== ""){
			alert('É necessário que  Unidade seja selecionada!');
			return;
		}
		
		document.getElementById('frmInclusaoGestores').submit();
			
	}
</SCRIPT>
	<!-- FIM CONTEÚDO -->
<!--#include virtual="/includes/lms_bot.asp"-->
<%
' -------------------------------------------------------------------------------------------------
' CÓDIGO COMPLEMENTAR
' Executado após a apresentação do conteúdo.


%>

pagina que grava os dados no banco

<!--#include virtual="/includes/lms_top.asp"-->
<!--#include virtual="/scripts/funcoes.asp"-->


<%
  
dim sql
dim cargo, perfil, nome, login, telefone, email , data 
dim foto , codigoCadastrador , unidadeSelecionada , cliente , emailativo , per_tutoria
dim Upload, fsPasta, Diretorio_Publica, Diretorio_Temp, count

Set Upload = Server.CreateObject("Persits.Upload.1")
Set fsPasta = Server.CreateObject("Scripting.FileSystemObject")
Diretorio_Publica = Server.MapPath("/images/fotos_usuarios/")
Diretorio_Temp = Server.MapPath("/images/galeria/publica/temp/")
a=request("nome")
response.Write(a)

'é necessário salvar o arquivo antes de recuperar os dados da tela anterior.
count = Upload.Save(Diretorio_Temp)	

'----------------------------------- RECUPERA DADOS DO FORM -------------------------------------------

	For Each Item in Upload.Form		
		if Item.Name = "nome" then
			nome = Item.Value
		end if
		if Item.Name = "login" then
			login = Item.Value
		end if
		if Item.Name = "senha" then
			senha = Item.Value
		end if
		if Item.Name = "email" then			
				email=Item.Value						
		end if  
		if Item.Name = "data" then
			data = Item.Value
			data = FormataDataUSA(data)
		end if
		if Item.Name = "foto" then
			foto = Item.Value
		end if
		if Item.Name = "emailativo" then
			emailativo = Item.Value				
		end if
		if Item.Name = "car_codigo" then
			car_codigo = Item.Value
		end if
		if Item.Name = "unidadeSelecionada" then
			uni_codigo = Item.Value
		end if
	Next
	
	for each File in Upload.Files
	if File.Name = "foto" then
			foto = File.ExtractFileName
		end if	
	next

	'PERFIL DE GESTOR
	perfil = 3
	'Variavel utilizada para ver se a gravação da foto ocorreu corretamente
	frmOK = true

	
	'Codigo de quem esta logado
	codigoCadastrador = Session("usuario_codigo")
	'Codigo do cliente logado
	strSQL = "SELECT cli_codigo, uni_codigo, uni_codigo_pai FROM Unidade WHERE uni_codigo = " & uni_codigo
	fx_Open rsUnidadeTutoria, strSQL, 1, 1, 1

	cli_codigo = rsUnidadeTutoria("cli_codigo")
	uni_codigo  = rsUnidadeTutoria("uni_codigo")
	uni_codigo_pai = rsUnidadeTutoria("uni_codigo_pai")
	fx_Close rsUnidadeTutoria
	
' -----------------------------------------------------------------------------------------------------

	if foto <> "" then
		For Each File in Upload.Files
		
			if UCASE(File.Ext) <> ".JPG" and UCASE(File.Ext) <> ".GIF" then
				File.Delete
				Response.Write("&lt;script LANGUAGE=""javascript\""> ")
				Response.Write("alert('O arquivo não é compatível com o tipo de arquivo selecionado.\n\nSão aceitos apenas .GIF e .JPG'); ")
				Response.Write("window.history.go(-1); ")
				Response.Write("</SCRIPT> ")
				frmOK = false
			end if
		
			Tamanho = File.Size
			if Tamanho > 1048576 then 'tamanho de arquivo fixo em 1mb
				
				File.Delete
				
				Response.Write("&lt;script LANGUAGE=""javascript\""> ")'Response.Write("<!-- ")
				Response.Write("alert('O arquivo deve ter no máximo 1Mb!'); ")
				Response.Write("window.history.go(-1); ")
				'Response.Write("//--> ")
				Response.Write("</SCRIPT> ")
				frmOK = false
			End If
			
				if fsPasta.FileExists(Diretorio_Publica & "\" & File.ExtractFileName) then
				File.Delete
				Response.Write("&lt;script LANGUAGE=""javascript\""> ")'Response.Write("<!-- ")
				Response.Write("alert('Já existe um arquivo com este nome em uma galeria!'); ")
				Response.Write("window.history.go(-1); ")
				Response.Write("</SCRIPT> ")	
				frmOK = false
			end if
				
			if frmOK then
				File.Move Diretorio_Publica & "\" & File.ExtractFileName
				Imagem = File.ExtractFileName
			end if
		next
			
		' GERA O THUMB DA IMAGEM
		if frmOK then
			call fx_Thumb( Imagem, Diretorio_Publica, Diretorio_Publica & "\small\", true, 80, 90 )
		end if
	end if
						   

if 	frmOK then
	' EFETIVA A GRAVAÇÃO EM BANCO
	sql =	"insert into usuario (cod_perfil_usuario, "&_
			"usu_nome, "&_
			"usu_id, "&_
			"usu_telefone, "&_
			"usu_email, "&_
			"usu_data_nascimento, "&_
			"usu_cadastro, "&_
			"usu_arquivo_foto, "&_
			"usu_cod_cadastrador, "&_
			"uni_codigo, "&_
			"uni_codigo_principal, "&_
			"cli_codigo, "&_
			"usu_ind_exclusao, "&_
			"usu_email_ativo, "&_
			"usu_gestor_perm_tutor, "&_
			"usu_online, " &_
			"car_codigo) "
	sql = sql & "values (" & perfil & ", " &_
			"'" & Ucase(nome) & "', "&_
			"'" & login & "', "&_
			"'" &telefone & "', "&_
			"'" & email & "', "&_
			"" & data & ", "&_
			"'" & senha & "', "&_
			"'" & foto & "', "&_
			"'" & codigoCadastrador & "', "&_
			"'" & uni_codigo & "', "&_
			"'" & uni_codigo_pai & "', " &_
			"'" & cli_codigo & "', " &_
			"'0', " &_
			"'" & emailativo & "', " &_
			response.Write(per_tutoria)	&_
			"'" & per_tutoria & "', " &_
			"'0', " &_
			"'" & car_codigo &"')"			

	fx_Open rssql, sql, 1, 1, 1
	fx_Close rssql
	
	sql = "select max(usu_codigo) as usu_codigo from usuario"
	fx_Open rsMax, sql, 1, 1, 1
	usu_codigo = rsMax("usu_codigo")
	fx_Close rsMax
	
	sql = "Insert into usuario_unidade (usu_codigo, uni_codigo) " &_
		  "Values (" & usu_codigo & ", " & uni_codigo & ")"
	fx_Open rsUniUsu, sql, 1, 1, 1	
	fx_Close rsUniUsu 
		
	response.redirect "adm_gestor_inc.asp"
end if

%>
<!--#include virtual="/includes/lms_bot.asp"-->


assim acho q fica mais facil de ver com meu forme completo e a pagina que recebe ele.

IPB Skin By Virteq