GoConqr has a new look! Let us know what you think.

Mind map

FUNCIONES SQL

dreik roses Programacion Spanish

FUNCIONES SQL

Map content

FUNCIONES SQL

  1. Las funciones son metodos definidos por el usuario que aceptan parametros, realizan una accion, como un calculo complejo, y devuelven el resultado de esa accion como un valor.

    • DE SISTEMA
      • Las funciones del sistema permiten tener acceso a la información de las tablas del sistema de SQL Server sin tener acceso directamente a las tablas del sistema
        • SELECT COL_LENGTH('Employees', 'LastName') AS Col_Length, DATALENGTH(LastName) AS DataLength FROM Employees WHERE EmployeeID > 6;
    • ESCALARES
      • Una función escalar retorna un único valor. Como todas las funciones, se crean con la instrucción "create function". En una función escalar insertada no hay cuerpo de la función; el valor escalar es el resultado de una sola instrucción.
        • SINTAXIS: CREATE FUNCTION NOMBRE (@PARAMETRO TIPO=VALORPORDEFECTO) returns TIPO BEGIN INSTRUCCIONES RETURN VALOR END;
          • EJEMPLO: create function f_promedio (@valor1 decimal(4,2), @valor2 decimal(4,2) ) returns decimal (6,2) as begin declare @resultado decimal(6,2) set @resultado=(@valor1+@valor2)/2 return @resultado end;
    • DE TABLA
      • DE VARIAS INSTRICCIONES
        • Create function NOMBREFUNCION (@PARAMETRO TIPO) returns @NOMBRETABLARETORNO table-- nombre de la tabla --formato de la tabla (CAMPO1 TIPO, CAMPO2 TIPO, CAMPO3 TIPO ) as begin insert @NOMBRETABLARETORNO select CAMPOS from TABLA where campo OPERADOR @PARAMETRO RETURN end
          • create function f_ofertas (@minimo decimal(6,2)) returns @ofertas table-- nombre de la tabla --formato de la tabla (codigo int, titulo varchar(40), autor varchar(30), precio decimal(6,2) ) as begin insert @ofertas select codigo,titulo,autor,precio from libros where precio < @minimo return end;
      • EN LINEA
        • create function NOMBREFUNCION (@PARAMETRO TIPO=VALORPORDEFECTO) returns table as return ( select CAMPOS from TABLA where CONDICION );
          • create function f_libros (@autor varchar(30)='Borges') returns table as return ( select titulo,editorial from libros where autor like '%'+@autor+'%' );

Images and files in the map

  • FUNCIONES SQL
  • FUNCIONES SQL
  • FUNCIONES SQL

Information

Description
Programacion Mind Map on FUNCIONES SQL, created by dreik roses on 01/03/2018.
Created by
dreik roses
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?