stored-functions

Oracle query to Exclude weekends, and 6PM to 9PM

独自空忆成欢 提交于 2021-01-29 11:03:34
问题 I am trying to achieve a query that returns the time difference between two dates excluding weekends(Saturday and Sunday) and excluding time (6 pm-9 am). For now, I have a function that is excluding the weekends, But I am unable to exclude time from the query. Can anyone help with this? The article from which I take help is this CREATE OR REPLACE FUNCTION get_bus_minutes_between( p_start_date DATE, p_end_date DATE ) RETURN NUMBER DETERMINISTIC -- ***** Can't hurt IS days_diff NUMBER := 0; end

Postgresql Function with optional parameters

£可爱£侵袭症+ 提交于 2021-01-29 09:59:56
问题 Is there a way to create a function which can be called with a variable number of parameters (comma separated, so positional). For example, calling a such function with function1(param1,param2) and possibly calling it with function1(,param2) or function1(param1,) ? I've created a function with default parameters but I've errors when calling it : select * from iDxi('3 days',) order by "Date" asc ERROR: syntax error at or near ")" LINE 1: select * from iDxi('3 days',) order by "Date" asc My

How to apply a <forcedType> to a stored function in jOOQ?

风格不统一 提交于 2020-06-28 05:40:50
问题 A common question among jOOQ users is how a <forcedType> can be applied to a stored function return type in the code generator. The manual specifies that <includeExpression> matches qualified or unqualified identifiers, so given this HSQLDB function: CREATE FUNCTION stored_functions.f_1 (p_i int) RETURNS int BEGIN ATOMIC RETURN p_i; END The parameter of the function can be forced to String using: <forcedType> <userType>java.lang.String</userType> <converter> org.jooq.Converter.ofNullable

Passing parameters to stored procedure in OBIEE 12c rpd from OBIEE 12c dashboard

大憨熊 提交于 2020-05-30 04:24:21
问题 I am trying to create an OBIEE report using stored procedures. I have created a function in SQL Developer which takes a parameter and returns refCursor as output. I, then, set the following query as default initialization string in physical layer of rpd: Select * from table(pipelined_emp(HR_DATA.GETCURSORS(parameter))) GETCURSORS(parameter) is my function. For now, in place of parameter , I am passing a constant value. While, I wish to pass a value from the OBIEE dashboard, similar to a

Create view using postgres function

与世无争的帅哥 提交于 2020-04-30 07:01:05
问题 I'm trying to build a parametrized view using a postgres function: CREATE FUNCTION schemaB.testFunc(p INT) RETURNS TABLE AS RETURN (SELECT * FROM schemaZ.mainTable WHERE id=p) The problem is always the same: SQL Error [42601]: ERROR: syntax error at or near "AS" Any idea on what could I be doing wrong? 回答1: You need to specify the columns of the "return table", this is either done using returns table(col_1 integer, col_2 text, ...) In your case you are returning only rows of one table, so it

SQL Server : select column with 3 matching characters

徘徊边缘 提交于 2020-01-16 09:09:29
问题 I am selecting the records from 2 tables in which the 1st table column named DESC (first 3 characters) should match with the project column of the 2nd table. I want to get the last 2 characters from Table 1 column DESC to be added in my output, but the last 2 characters are not present in Table 2 column project. select SUBSTRING(a.[DESC], 1, 3) from Table1 a join Table2 b on SUBSTRING(a.[DESC], 1, 3) = b.project Input: 1st Table DESC Column: Value: '2AB F YY' 2nd Table Project Column: Value:

Sql query for selecting the first 3 characters

不打扰是莪最后的温柔 提交于 2020-01-16 09:08:09
问题 I am trying to select the records from 2 tables in which the 1st table column named DESC (first 3 characters) should match with the project column of the 2nd table. select SUBSTRING(a.[DESC],1,3) from Table1 a left outer join Table2 b on a.[DESC] = b.project where SUBSTRING(a.[DESC],1,3) like b.project Input: 1st Table DESC Column: Value: '2AB F YY' 2nd Table Project Column: Value: '2AB' Expected Output: Return all the records of value 2AB 回答1: PLEASE VOID USING RESERVED KEYWORDS LIKE DESC

How to return rows based on the database user and the table's contents?

℡╲_俬逩灬. 提交于 2020-01-06 05:26:52
问题 I have a following table: id name score 1 SYS 4 2 RHWTT 5 3 LEO 4 4 MOD3_ADMIN 5 5 VPD674 4 6 SCOTT 5 7 HR 4 8 OE 5 9 PM 4 10 IX 5 11 SH 4 12 BI 5 13 IXSNEAKY 4 14 DVF 5 I want to create a policy function in Oracle SQL that makes sure of the following things: If a user(Leo) is executing a select statement on this table, it only gets 3 LEO 4 . sys_dba gets all the results no matter what. I have given select permissions to Leo on this table created by Scott. I am getting stuck at writing this