1 | /* |
2 | * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, |
3 | * and the EPL 1.0 (http://h2database.com/html/license.html). |
4 | * Initial Developer: H2 Group |
5 | */ |
6 | package org.h2.command.ddl; |
7 | |
8 | import java.util.ArrayList; |
9 | import org.h2.command.CommandInterface; |
10 | import org.h2.command.Prepared; |
11 | import org.h2.engine.Procedure; |
12 | import org.h2.engine.Session; |
13 | import org.h2.expression.Parameter; |
14 | import org.h2.util.New; |
15 | |
16 | /** |
17 | * This class represents the statement |
18 | * PREPARE |
19 | */ |
20 | public class PrepareProcedure extends DefineCommand { |
21 | |
22 | private String procedureName; |
23 | private Prepared prepared; |
24 | |
25 | public PrepareProcedure(Session session) { |
26 | super(session); |
27 | } |
28 | |
29 | @Override |
30 | public void checkParameters() { |
31 | // no not check parameters |
32 | } |
33 | |
34 | @Override |
35 | public int update() { |
36 | Procedure proc = new Procedure(procedureName, prepared); |
37 | prepared.setParameterList(parameters); |
38 | prepared.setPrepareAlways(prepareAlways); |
39 | prepared.prepare(); |
40 | session.addProcedure(proc); |
41 | return 0; |
42 | } |
43 | |
44 | public void setProcedureName(String name) { |
45 | this.procedureName = name; |
46 | } |
47 | |
48 | public void setPrepared(Prepared prep) { |
49 | this.prepared = prep; |
50 | } |
51 | |
52 | @Override |
53 | public ArrayList<Parameter> getParameters() { |
54 | return New.arrayList(); |
55 | } |
56 | |
57 | @Override |
58 | public int getType() { |
59 | return CommandInterface.PREPARE; |
60 | } |
61 | |
62 | } |