stored-procedures

Using a comma-separated parameter in an IN clause

左心房为你撑大大i 提交于 2021-02-04 15:10:42
问题 I have 'param1, param2, parma3' coming from SSRS to a stored procedure as a varchar parameter: I need to use it in a query's IN clause but then need to change its format like this first: select * from table1 where col1 in('param1', 'param2', 'param3') What is the best way to reformat the parameter without creating functions and parameter tables? 回答1: Try this one, Just need to add commas at the beginning and at the end of @params string. Declare @params varchar(100) Set @params = ',param1

PostgreSQL functions and triggers

孤街醉人 提交于 2021-02-04 13:38:25
问题 I am trying out functions and triggers int postgreSQL, however i am having a problem, when the function is triggered it is giving me an error ERROR: control reached end of trigger procedure without RETURN this particular procedure is only executing an insert into command so i do not see why it needs a return this is the script: CREATE OR REPLACE FUNCTION forest_aud_func() returns trigger as $tree_stamp$ BEGIN insert into Audit values('k',124,'l'); END; $tree_stamp$ LANGUAGE plpgsql; create

SQL Server stored procedure and execute in VB.NET

天涯浪子 提交于 2021-02-04 12:34:58
问题 This is a bit old-contents to be discussed but I need someone who can explain me how to create stored procedure in SQL Server for returning a value from procedure, example: SELECT NAME, ADDRESS FROM CUSTOMER WHERE IDCUSTOMER = 'DS212'; Then I need the name of its customer and the address instead. I need to make it as a stored procedure and show me how to execute it on VB.NET. Perhaps we assume that the name will be prompted to LABEL1.TEXT and the address will be prompted to LABEL2.TEXT. I've

SQL Server stored procedure and execute in VB.NET

試著忘記壹切 提交于 2021-02-04 12:34:28
问题 This is a bit old-contents to be discussed but I need someone who can explain me how to create stored procedure in SQL Server for returning a value from procedure, example: SELECT NAME, ADDRESS FROM CUSTOMER WHERE IDCUSTOMER = 'DS212'; Then I need the name of its customer and the address instead. I need to make it as a stored procedure and show me how to execute it on VB.NET. Perhaps we assume that the name will be prompted to LABEL1.TEXT and the address will be prompted to LABEL2.TEXT. I've

Datetime conversion from mongoDB string to SQL

為{幸葍}努か 提交于 2021-02-04 08:27:27
问题 I am trying to insert record from MongoDB to MSSQL database. createdAt field in mongoDB is a mixture of datetime and string values for some reason. so some records are like = "createdAt" : ISODate("2020-01-17T23:45:00.000Z") and some records are like = "createdAt" : "2020-04-18T07:00:00Z" Here is my stored procedure : ALTER PROCEDURE [dbo].[spInsertInOutAggregate] (@passingInOutAggregate dbo.tempInOutAggregateData1 READONLY) AS BEGIN MERGE dbo.inoutaggregatedata AS target USING

Is a DbSet required to run a stored procedure?

两盒软妹~` 提交于 2021-01-29 18:34:59
问题 I have a stored procedure that returns data from a multi-table query. To do this do I need to create a DbSet for each of the tables that are involved in the query? All the examples I find that use FromSql have a DbSet (e.g., Books in the below example) specified before the FromSql clause. using (var context = new SampleContext()) { var books = context.Books .FromSql("EXEC GetAllBooks") .ToList(); } My understanding is a DbSet represents an table. Note that I am working against an existing DB

Avoiding frequent call to same view inside a Oracle procedure

僤鯓⒐⒋嵵緔 提交于 2021-01-29 18:11:40
问题 I have a oracle view it returns 5 million records from different tables and i use this view to insert into different tables using a single procedure, inside this procedure i use this several times and this is affecting the performance, is there any way we can query the view once and later i can use it multiple places? 回答1: A view is a stored query; itself, it doesn't contain any data. If its code is complex and fetches data from several tables, using different conditions, aggregations,

Create procedure that deletes data from several tables. SQL Server

早过忘川 提交于 2021-01-29 14:54:01
问题 I need to create a procedure that allows me to delete data from several tables at once, searching through the CUIT . There are four tables shown here: I must pass a CUIT value in, and if it matches any item saved in the database, I need it to be deleted. I could not find the syntax to be able to erase more than two tables at once, if you could give me a hand I would greatly appreciate it. I clarify by the doubts that the procedure is actually much larger, in total it would be about 12 tables,

Is a DbSet required to run a stored procedure?

南楼画角 提交于 2021-01-29 11:06:05
问题 I have a stored procedure that returns data from a multi-table query. To do this do I need to create a DbSet for each of the tables that are involved in the query? All the examples I find that use FromSql have a DbSet (e.g., Books in the below example) specified before the FromSql clause. using (var context = new SampleContext()) { var books = context.Books .FromSql("EXEC GetAllBooks") .ToList(); } My understanding is a DbSet represents an table. Note that I am working against an existing DB

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