forked from biblat/Biblat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbiblat.sql
49 lines (45 loc) · 1.51 KB
/
biblat.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--Biblat database tables
CREATE DATABASE biblat;
\connect biblat;
CREATE TABLE "logSolicitudDocumento" (
database numeric(1,0),
sistema character varying(9),
nombre character varying,
email character varying,
instituto character varying,
telefono character varying(20),
ip character varying(15),
pais character varying,
ciudad character varying,
datetime timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone,
session_id character varying(40)
);
CREATE TABLE "advancedSearchHash"
(
hash character varying(32) NOT NULL,
search character varying,
query character varying,
CONSTRAINT "advacedSearchHash_pkey" PRIMARY KEY (hash)
);
CREATE OR REPLACE FUNCTION "advancedSearchHashInsert"(character varying(32), character varying, character varying)
RETURNS text
AS $$
DECLARE
vhash ALIAS FOR $1;
vsearch ALIAS FOR $2;
vquery ALIAS FOR $3;
retval text;
BEGIN
UPDATE "advancedSearchHash" SET search=vsearch, query=vquery
WHERE hash=vhash;
IF (FOUND) THEN
retval := 'registro actualizado';
ELSE
INSERT INTO "advancedSearchHash" (hash, search, query)
VALUES (vhash, vsearch, vquery);
retval := 'registro insertado';
END IF;
RETURN retval;
END;
$$
LANGUAGE 'plpgsql';