package com.alibaba.druid.sql.parser;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.List;

public class OracleCursorOpenTest extends TestCase {
    public void test_open_cursor_with_method() {
        String sql = "create or replace procedure proc_test1 (myArray in self_define_array) is \n" +
                "\n" +
                "CURSOR c_test (p1 varchar2) is\n" +
                "select\n" +
                "     *\n" +
                "from\n" +
                "     test1\n" +
                "where\n" +
                "     id = p1;\n" +
                "\n" +
                "BEGIN OPEN c_test (myArray (1));\n" +
                "\n" +
                "END proc_test1;";
        List<SQLStatement> sqlStatements = SQLUtils.parseStatements(sql, DbType.oracle);
        System.out.println(sqlStatements);
        Assert.assertFalse(sqlStatements.isEmpty());
    }
}
