I’m trying to make a postgreql function, I’m a little confused on which syntax format to use when I’m passing a select statement that takes in a parameter (this parameter can be a string or a list of …
Tag: sql-function
Counting Business Days PostgresSQL
I am attempting to do something like this: SELECT t.id, t.startdate, t.enddate, FOO FROM table Where “Foo” is some sql mumbo-jumbo to calculate the business days between startdate and …
Postgresql, one function calls another function and get 2 out values to caller
Postgresql 12. Want to call function testA() from another function testB(), and assign two “out” values to the 2 local variables. Don’t know how to do the assignment, please help. create or …
How to update status for part with nothing data when this part is missed?
I work with SQL Server 2012 and have an issue: I can’t update status with No data returned where no result returned from select statement cross apply function. Meaning where no data returned when join parts and company to function then update status to this part with nothing data for that part when data is missing. When I run a
Replace function in SQL Server
I have a string of data I am trying to use the replace function to replace double commas with NULL values Solution But I keep ending up with (The ,,, needs to become ,NULL,NULL, but only becomes ,NULL,,) Here is my sample code I’m using Answer If you do the same replacement twice, any number of sequential commas will get
Wrong number or types of arguments in call to ‘||’
We are supposed to read a text file, insert that data into a table while taking care of exceptions. This the code for my function: This is how i’ve called the function (but i think it’s wrong): And this is the error I’ve got: I tried to remove the results in the dbms_output and this is what happened: After running
ORACLE SQL How to use custom function iside insert cte
I am trying to use function inside insert SQL, but I am getting error ORA-32034. Looks like that I couldn’t access this function in the cte. Maybe someone can help? Answer If the query containing the PL/SQL declaration section is not the top level query, the top-level query must include the WITH_PLSQL hint. Without this hint, the statement will fail
How to iterate over a record when the columns are dynamic
I have this function in postgres which takes PVH_COLS_DYNA that contains the columns that are going in to the query: CREATE OR REPLACE FUNCTION DRYNAMIC_DATA_F(PVH_COLS_DYNA VARCHAR) RETURNS numeric …
Average of Sum minus Minimum
I have an SQL statement that grabs the grades of different activity types (Homework, Quiz, etc), and if there’s a drop lowest for that type, it drops, else, it remains. The errors are below as well as the SQL Code. Here are the errors I’m getting: Answer Look into analytical functions. (SO question, Oracle documentation). Something like this: and: Set