sql-function

Registering a SQL function with JPA and Hibernate

此生再无相见时 提交于 2020-01-19 16:23:36
问题 I would like to know what's the best way to register a custom SQL function with JPA/Hibernate . Do I have to go through extending the MysqlInnodb dialect or is there a better way? Can anyone please provide code samples and pointers to relevant documentation? 回答1: Yes extending the dialect is a good way of registering custom SQL function. Add something like this in your Dialect classes constructor. registerFunction("current_timestamp", new NoArgSQLFunction(Hibernate.TIMESTAMP) );

SQL FUNCTION LIKE SEARCH ISSUE

随声附和 提交于 2020-01-16 19:43:37
问题 please help to fix my sql function! in my sql function i have one temporary tables parameter passing to function @searchstring ---- "'%carrots%' AND tmp.ItemDescription like '%baby%'" Declare @tempvalues table (itemdescription nvarchar(max)) @tempvalues VALUES ----------------------- CARROTS, BABY, CLASS I, FRESH CARROTS, BABY, FROZEN CARROTS, CLASS I, FRESH ------------------ so in function iam passing value for searching data using like query and if matches i need to insert data in another

Array not being returned by SELECT query inside plpgsql test case

一笑奈何 提交于 2020-01-16 05:03:08
问题 SELECT query I am using: SELECT ARRAY[table_name,pg_size_pretty(table_size)] FROM ( SELECT table_name, pg_table_size(table_name) AS table_size, pg_indexes_size(table_name) AS indexes_size, pg_total_relation_size(table_name) AS total_size FROM ( SELECT ('"' || table_schema || '"."' || table_name || '"') AS table_name FROM information_schema.tables where table_schema not in ('pg_catalog', 'information_schema')and table_schema not like 'pg_toast%' ) AS all_tables ORDER BY total_size DESC ) AS

correlation name not found on SQL Anywhere

 ̄綄美尐妖づ 提交于 2020-01-11 13:14:08
问题 I have two tables called Employees and Salarygroup . PersonalID is the primary key of Employees and SalaryID is the primary key of Salarygroup. Inside the Employees table there is one more row called StartDat , which has date data type and tracks down the date when the employee started working at the company. Moreover, AmountInEuros is the salary that an employee gets every month and it has a numeric data type I need to make a function, which count the total amount of money, that the employee

MySQL: Selecting multiple fields into multiple variables in a stored procedure

☆樱花仙子☆ 提交于 2020-01-09 12:17:12
问题 Can I SELECT multiple columns into multiple variables within the same select query in MySQL? For example: DECLARE iId INT(20); DECLARE dCreate DATETIME; SELECT Id INTO iId, dateCreated INTO dCreate FROM products WHERE pName=iName; What is the correct syntax for this? 回答1: Your syntax isn't quite right: you need to list the fields in order before the INTO, and the corresponding target variables after: SELECT Id, dateCreated INTO iId, dCreate FROM products WHERE pName = iName 回答2: =========

MySQL Function to add a number of working days to a DATETIME

谁说胖子不能爱 提交于 2020-01-03 02:29:12
问题 I need a MySQL Function that will allow me to pass a number of working days (Monday - Friday) and a start DATE or DATETIME (doesn't matter for my implementation), and have it return a new DATE or DATETIME that many work days in the future. Example: SELECT AddWorkDays(10, "2013-09-01") returns "2013-09-16" assuming "2013-09-01" is a Monday. Similarly: SELECT AddWorkDays(-10, "2013-09-16") returns "2013-09-01" I found this function for an MSSQL database (I think) that is exactly what I need

Database Function VS Case Statement

本秂侑毒 提交于 2020-01-01 08:46:47
问题 Yesterday we got a scenario where had to get type of a db field and on base of that we had to write the description of the field. Like Select ( Case DB_Type When 'I' Then 'Intermediate' When 'P' Then 'Pending' Else 'Basic' End) From DB_table I suggested to write a db function instead of this case statement because that would be more reusable. Like Select dbo.GetTypeName(DB_Type) from DB_table The interesting part is, One of our developer said using database function will be inefficient as

Database Function VS Case Statement

不想你离开。 提交于 2020-01-01 08:46:15
问题 Yesterday we got a scenario where had to get type of a db field and on base of that we had to write the description of the field. Like Select ( Case DB_Type When 'I' Then 'Intermediate' When 'P' Then 'Pending' Else 'Basic' End) From DB_table I suggested to write a db function instead of this case statement because that would be more reusable. Like Select dbo.GetTypeName(DB_Type) from DB_table The interesting part is, One of our developer said using database function will be inefficient as

How to add non-standardized sql functions in Spring Boot application?

妖精的绣舞 提交于 2019-12-30 09:44:10
问题 My app needs to be portable between Postgres, Mysql and for testing Hsqldb. I've setup Flyway to make some custom functions available on all three, that I now want to use in my SQL/HQL queries. My current setup is using separate Dialect s that I switch between using application-{profile}.yml ; which works, but the function declarations need to be duplicated among the various dialects, and it feels suboptimal. Looking at 15.29. Non-standardized functions in the Hibernate documentation, it says

How to check date of last change in stored procedure or function in SQL server

余生长醉 提交于 2019-12-29 02:18:30
问题 I need to check when function was changed last time. I know how to check creation date (it is in function properties window in SQL Server Management Studio). I found that in SQL Server 2000 it wasn't possible to check modify date ( look at this post: Is it possible to determine when a stored procedure was last modified in SQL Server 2000?) Is it possible to check it in SQL Server 2008? Does MS add some new feature in system tables that allow to check it? 回答1: SELECT name, create_date, modify