11
Views
4
Comments
Solved
Insert Into Select
Question
Application Type
Reactive

I want to use a process to create invites whenever an Activity Is Created, for that I'm using an Insert Into Select query to avoid a for each loop over the users to be invited.
Can anyone help me in the query syntax because I'm sure it is full of error as it is my first time doing something like this.

UpdatedOn and UpdatedBy not mandatory

Champion
Solution

You need to create like my example in previous answer, it's the same case. Will fits perfectly what you need.

Another example:

INSERT INTO table2 (column1, column2, column3, ...)
SELECT column1, column2, column3, ...
FROM table1
WHERE condition; 

Solution

What about the values that are coming as inputs, how would I manage them in the select?


Edit: Does this work?? It returns no errors but is it what you were talking about??

Champion

Your syntax is incorrect, check here examples: https://www.w3schools.com/sql/sql_insert.asp


Example:

INSERT INTO OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER_AUX (OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER_AUX.[FiscalIncomeStmntInstanceId], OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER_AUX.[DossierId], OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER_AUX.[CustomerId])

SELECT DISTINCT OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER.[FiscalIncomeStmntInstanceId], OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER.[DossierId], OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER.[CustomerId] FROM OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER

WHERE OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER.[FiscalIncomeStmntInstanceId] = 82

AND OSUSR_95i_FISCAL_INCOME_STATEMENT_HOLDER.[DossierId] = 1700

Hello Paulo.


Something like this does the job or am I still not there?

Champion
Solution

You need to create like my example in previous answer, it's the same case. Will fits perfectly what you need.

Another example:

INSERT INTO table2 (column1, column2, column3, ...)
SELECT column1, column2, column3, ...
FROM table1
WHERE condition; 

Solution

What about the values that are coming as inputs, how would I manage them in the select?


Edit: Does this work?? It returns no errors but is it what you were talking about??

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.