procedure

How to make a Clojure function take a variable number of parameters?

折月煮酒 提交于 2019-11-28 18:04:50
I'm learning Clojure and I'm trying to define a function that take a variable number of parameters (a variadic function) and sum them up (yep, just like the + procedure). However, I don´t know how to implement such function Everything I can do is: (defn sum [n1, n2] (+ n1 n2)) Of course this function takes two parameteres and two parameters only. Please teach me how to make it accept (and process) an undefined number of parameters. In general, non-commutative case you can use apply : (defn sum [& args] (apply + args)) Since addition is commutative, something like this should work too: (defn

missing keyword error in oracle CASE WHEN sql statement

扶醉桌前 提交于 2019-11-28 14:34:07
I am writing a procedure in which i have sql statement which will insert values in TEMP_WF_WORKFLOW table using CASE WHEN statement. The condition is when STATUS_ID is 0 then the EVENT_ID=10003 and when STATUS_ID is 1 then EVETN_ID=10018 . When i try to use CASE WHEN for this its giving me error missing keyword.I dont know but is there any other way to do this if not using CASE WHEN statement. I am thinking about using cursor but dont know how to do this. Here is my query: CREATE OR REPLACE PROCEDURE ext_self_10003_sigwf AS BEGIN -- first empty TEMP_WF_WORKFLOW table EXECUTE IMMEDIATE

ORA-00900: invalid SQL statement- when run a procedure in oracle 10g

这一生的挚爱 提交于 2019-11-28 09:54:31
I am using Oracle 10g database and trying to run a procedure using SQL commands. create or replace procedure "exam" is begin DBMS_OUTPUT.PUT_LINE('Test'); end; Then click on Run button. It shows: "procedure created". When I try to execute it using: execute exam; then click on Run button, it shows: ORA-00900: invalid SQL statement Thanks for your help. be here now Just noticed a detail in your question. You press run button. Thus, you must be using an IDE. You cannot use execute in IDEs - it is an sql*plus command. It might work in Oracle SQL Developer though, but I wouldn't use it there anyway

Tricks on how to execute string inside a function in Sql Server

我与影子孤独终老i 提交于 2019-11-28 08:16:37
问题 Procedure FunctionX, Line 345 Invalid use of a side-effecting operator 'EXECUTE STRING' within a function. I get the above error when I execute a dynamic statement inside a function in SQL Server 2012. Is there a workaround for this? Any tricks? PS: The sproc (stored procedure) is much too lengthy for its body to be inserted as-is inside the function. DECLARE @execsql NVARCHAR(2000) Set @execsql = 'INSERT INTO @TABLE1 EXEC SPROC1 ' + @ID_COMPANY + ',' + @ID_COUNTRY exec (@execsql) Many thanks

fetch table name from a column for from clause

僤鯓⒐⒋嵵緔 提交于 2019-11-28 06:54:14
问题 I have a view t with me which has a column for table name and another column which has where clause condition. id| name|table_in| where_clause 1 | Sam | t1 | age = 22 2 | John| t2 | age = 23 and sex = 'male' and so on... Now, I have put the records in a cursor and I want to run each query. create or replace procedure create_cursor is CURSOR v_records is select * from t ; begin FOR temp IN v_records LOOP INSERT INTO myTable (id, name) select temp.id, temp.name from temp.table where temp.where

Searching a column containing CSV data in a MySQL table for existence of input values

筅森魡賤 提交于 2019-11-28 04:36:01
问题 I have a table say, ITEM, in MySQL that stores data as follows: ID FEATURES -------------------- 1 AB,CD,EF,XY 2 PQ,AC,A3,B3 3 AB,CDE 4 AB1,BC3 -------------------- As an input, I will get a CSV string, something like "AB,PQ". I want to get the records that contain AB or PQ. I realized that we've to write a MySQL function to achieve this. So, if we have this magical function MATCH_ANY defined in MySQL that does this, I would then simply execute an SQL as follows: select * from ITEM where

missing keyword error in oracle CASE WHEN sql statement

你离开我真会死。 提交于 2019-11-27 08:30:09
问题 I am writing a procedure in which i have sql statement which will insert values in TEMP_WF_WORKFLOW table using CASE WHEN statement. The condition is when STATUS_ID is 0 then the EVENT_ID=10003 and when STATUS_ID is 1 then EVETN_ID=10018 . When i try to use CASE WHEN for this its giving me error missing keyword.I dont know but is there any other way to do this if not using CASE WHEN statement. I am thinking about using cursor but dont know how to do this. Here is my query: CREATE OR REPLACE

MySQL - Define a variable within select and use it within the same select

主宰稳场 提交于 2019-11-26 22:29:54
Is there a possibility to do something like this? SELECT @z:=SUM(item), 2*@z FROM TableA; I always get NULL for the second column. The strange thing is, that while doing something like SELECT @z:=someProcedure(item), 2*@z FROM TableA; everything works as expected. Why? MySQL documentation is quite clear on this: As a general rule, you should never assign a value to a user variable and read the value within the same statement. You might get the results you expect, but this is not guaranteed. The order of evaluation for expressions involving user variables is undefined and may change based on

Are there any suggestions for developing a C# coding standards / best practices document? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 14:48:25
I'm a recent AI graduate (circa 2 years) working for a modest operation. It has fallen to me (primarily as I'm the first 'adopter' in the department) to create a basic (read useful?) C# coding standards document. I think I should explain that I'm probably the most junior software engineer going, but I'm looking forward to this task as hopefully I might actually be able to produce something half usable. I've done a pretty extensive search of the Internet and read articles on what a coding standards document should / should not contain. This seems like a good as place as any to ask for some

What is the difference between a “function” and a “procedure”?

时间秒杀一切 提交于 2019-11-26 12:40:00
Generally speaking, we all hear about the functions or procedures in programming languages. However, I just found out that I use these terms almost interchangeably (which is probably very wrong). So, my question is: What is the difference in terms of their functionality, their purpose and use? An example would be appreciated. A function returns a value and a procedure just executes commands. The name function comes from math. It is used to calculate a value based on input. A procedure is a set of command which can be executed in order. In most programming languages, even functions can have a