简体   繁体   中英

Inserting row via stored procedure (Informix)

Is it possible to create a stored procedure which inserts a row into table with values taken from procedure parameters? I'm using Informix. :-(

Show how you are creating the procedure and executing.

The example you give on the comment to the question works:

[infx1210@tardis ~]$ dbaccess pavle -

Database selected.

> CREATE TABLE tab1(
>       col1 VARCHAR(8),
>       col2 INTEGER,
>       col3 INTEGER
> );

Table created.

> CREATE PROCEDURE sp1 (a VARCHAR(8), b INTEGER, c INTEGER)
>       INSERT INTO tab1 (col1,col2,col3) VALUES (a,b,c);
> END PROCEDURE;

Routine created.

> EXECUTE PROCEDURE sp1 ('test sp1',1,2);

Routine executed.

> SELECT * FROM tab1;


col1            col2        col3

test sp1           1           2

1 row(s) retrieved.

>

Database closed.

[infx1210@tardis ~]$

On SQuirreL you have to change the Statement Separator to something else temporarily.

Go to the File menu and select New Session Properties , go to the SQL tab and change the Statement Separator for something like \\ .

Connect again and try:

 CREATE PROCEDURE sp1 (a VARCHAR(8), b INTEGER, c INTEGER)
       INSERT INTO tab1 (col1,col2,col3) VALUES (a,b,c);
 END PROCEDURE\

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM