procedure

mariadb fonction, procedure error You have an error in your SQL

孤人 提交于 2019-12-24 18:31:38
问题 DELIMITER / CREATE FUNCTION filltimeDim () BEGIN DECLARE vQuarter VARCHAR(6); DECLARE vMonth_Name VARCHAR(20); DECLARE vdate_id date; DECLARE vyear_id CHAR(4); DECLARE vweekly_Name VARCHAR(20); DECLARE vMonth_Num TINYINT(10); DECLARE vweekday_Num TINYINT(10); BEGIN SET vdate_id = CONVERT('1998-01-01', DATE); WHILE (CONVERT('vdate_id' USING utf8) <= '2002-12-31') LOOP SET vyear_id = YEAR(vdate_id); SET vQuarter = QUARTER(vdate_id); SET vMonth_Name = MONTHNAME(vdate_id); SET vweekly_Name =

Informix: procedure with output parameters?

独自空忆成欢 提交于 2019-12-24 10:16:09
问题 I searched a lot, but couldn't find anything.. I just want to ask if there's any way to create and call a procedure ( Informix ) with out parameters. I know how to return one or more values (for procedures and for functions), but this is not what I want. It would be really strange, if Informix does not allow output parameters.. Thanks in advance! EDIT : Yes, I saw it's possible, but I still can't execute such procedure. For example: CREATE PROCEDURE mytest(batch INT,OUT p_out INT) DEFINE inc

SQL Proc 'Conversion failed' from varchar to int. Why the conversion?

こ雲淡風輕ζ 提交于 2019-12-23 21:43:41
问题 My question here would be... Why is it converting to int from varchar? I'm not sure what it is trying to do CREATE PROCEDURE #myTestProcedure ( @TransId VARCHAR(15) ) AS BEGIN DECLARE @Result VARCHAR(15); WITH TestCTE (TransId, AdjRefTransId) AS ( SELECT TRANSID, ADJREFTRANSID FROM dbo.MyTable WHERE TRANSID = @TransId UNION ALL SELECT pet.TRANSID, pet.ADJREFTRANSID FROM dbo.MyTable AS pet JOIN TestCTE ON TestCTE.ADJREFTRANSID = pet.TRANSID ) SELECT @Result = ( SELECT MAX(MyResult) FROM dbo

Create an event inside a procedure - SQL

你说的曾经没有我的故事 提交于 2019-12-23 17:10:51
问题 I need to create an event inside a procedure, I read somewhere that it's possible but I don't know the syntax. I'm trying: CREATE PROCEDURE DUMMY_PROCEDURE() BEGIN CREATE event e on schedule every 1 second DO INSERT INTO test.t values (current_timestamp); END; But it throws: Any ideas on how to do this?, thanks for reading. '#1576 - Recursion of EVENT DDL statements is forbidden when body is present Edit1: The reason I want to create an event within an event procedure is because it acts as an

Oracle Procedure error (PLS-00428)

半城伤御伤魂 提交于 2019-12-23 11:46:45
问题 This is the error message: PLS-00428: an INTO clause is expected in this SELECT statement. Meanwhile, this is the procedure for testing displaying the system date: CREATE OR REPLACE PROCEDURE "TEST_PROCEDURE" AS BEGIN SELECT SYSDATE FROM DUAL; END; In the first place I don't need to use that INTO Oracle is insisting for me to do. Is there other way around beside using a cursor (I've seen it here https://stackoverflow.com/a/6029963/1983024)? I think it should not be like that, this does run

how to validate integer datatype in oracle procedure

╄→尐↘猪︶ㄣ 提交于 2019-12-23 04:18:28
问题 I have a parameter with integer data type in a Oracle procedure which produces number of rows mentioned in the parameter into a table. I want to validate the parameter with its data type. that means, if the parameter value is 5.0 then it creates 5 rows and if the value is 5.2 then it produces error. How do I create this logic? 回答1: Oddly, PL/SQL does not enforce INTEGER parameters. I would expect Oracle to either implicitly convert the data or throw an error if 5.2 was passed to an INTEGER

Can an SQL procedure return a table?

淺唱寂寞╮ 提交于 2019-12-21 04:36:14
问题 Can an Oracle SQL procedure return a table? I'm currently using a dbms_output to print out the outputs of two cursors which are in a loop, although this would look nicer if it was returning two columns instead. Would that be possible within a procedure? 回答1: A PL/SQL function can return a nested table. Provided we declare the nested table as a SQL type we can use it as the source of a query, using the the TABLE() function. Here is a type, and a nested table built from it: SQL> create or

How to call a mysql stored procedure, with arguments, from command line?

不打扰是莪最后的温柔 提交于 2019-12-20 10:30:46
问题 How can I call a stored procedure from command line? I have a procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `insertEvent`(IN `dateTimeIN` DATETIME) NO SQL BEGIN SET @eventIDOut = NULL; IF EXISTS(SELECT * FROM `events` WHERE `eventDate` = dateTimeIN) THEN SELECT `eID` INTO @eventIDOut FROM `events` WHERE `eventDate` = dateTimeIN LIMIT 1; ELSE INSERT INTO `events` (`eventDate`) VALUES(dateTimeIN); SET @eventIDOut = last_insert_id(); END IF; SELECT CONCAT(@eventIDOut); END I tried this:

Oracle: How to use procedure local variables for “EXECUTE IMMEDIATE” statements in procedures

末鹿安然 提交于 2019-12-20 06:28:27
问题 We have a procedure starting with following code: CREATE OR REPLACE PROCEDURE get_id (id_ IN OUT number, type_ IN number) IS PRAGMA AUTONOMOUS_TRANSACTION; local_id number; BEGIN EXECUTE IMMEDIATE 'SELECT SYS_LOCAL_ID_SERIAL_SEQ.NEXTVAL into :local_id FROM dual'; ... Now if i execute this, the variable "local_id" is not filled with the next sequence value, but with null (although the sequence is raised by 1). If i change this to "... into local_id ..." i get ORA Error 1008 . What is going

Error declaring integer variable inside MySQL stored function

吃可爱长大的小学妹 提交于 2019-12-19 18:22:54
问题 I'm getting an error when trying to declare a new stored function in MySQL (Server version: 5.5.13) Basically, I have a large table which classifies strings depending on how they start. My function takes a string (from user input) and then tells you the classification of that string by searching the database for the classification. It's a bit like a LIKE query, except in reverse as it's the user input that contains the full string and the database contains the string being searched for. Hope