在java spring mvc中获取oracle存储过程结果集

时间:2017-10-17 07:43:45

标签: java spring oracle stored-procedures

我有以下存储过程,它接受三个参数并返回三个ref游标。

let shareAction = UIAlertAction(title: "Share", style: UIAlertActionStyle.default, handler: {(alert: UIAlertAction!) in
        var objectsToShare: [AnyObject]?


        let titlePost = self.feeds[sender.tag].downloadURL

        if let postURL = URL(string: titlePost) {
            let postRequest = URLRequest(url: postURL)
            self.image?.setImageWith(postURL, placeholderImage: nil, options: SDWebImageOptions.progressiveDownload, completed: { (imageRequest, imageResponse, error) -> Void in
                // failure downloading image
                print("Error downloading Firebase post image")
                print(error)
            })
        }

        objectsToShare = [self.image!]
        let activityViewController = UIActivityViewController(activityItems: objectsToShare!, applicationActivities: nil)

        // present the view controller
        self.present(activityViewController, animated: true, completion: nil)
    })

我有三个结果集用于此存储过程输出。我如何在spring mvc中调用它并显示这三个结果集。我使用以下代码通过SQL查询获取数据。但现在我开发了一个存储过程。那么如何将这个SP输出称为我的查询输出。

variable id refcursor
variable item refcursor
variable amount refcursor
exec getdata(123,date1,date2, :id, :item, :amount) ;

print id;
print item;
print amount;

1 个答案:

答案 0 :(得分:0)

试试这个:

                    PopupMenu popupMenu = new PopupMenu(getBaseContext(), ch_specificDay);
                    MenuInflater inflater = popupMenu.getMenuInflater();
                    inflater.inflate(R.menu.weekdays, popupMenu.getMenu());

                 popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                     @Override
                     public boolean onMenuItemClick(MenuItem item) {


                         switch (item.getItemId()) {
                             case R.id.sun:
                                 if(item.isChecked())
                             {
                                 item.setChecked(false);
                                 sunCheck = false;
                             }else
                                 {
                                     item.setChecked(true);
                                     sunCheck = true;
                                 }
                                break;

                             case R.id.Mon:
                                 if(item.isChecked())
                                 {
                                     item.setChecked(false);
                                     monCheck  = false;
                                 }else
                                 {
                                     item.setChecked(true);
                                     monCheck = true;
                                 }
                                break;

                             case R.id.Tus:
                                 if(item.isChecked())
                                 {
                                     item.setChecked(false);
                                     TusCheck = false;
                                 }else
                                 {
                                     item.setChecked(true);
                                     TusCheck = true;
                                 }
                                break;
                             case R.id.Thu:
                                 if(item.isChecked())
                                 {
                                     item.setChecked(false);
                                     ThrChec= false;
                                 }else
                                 {
                                     item.setChecked(true);
                                     ThrChec = true;
                                 }
                                    break;

                             case R.id.Wed:
                                 if(item.isChecked())
                                 {
                                     item.setChecked(false);
                                     wenCheck= false;
                                 }else
                                 {
                                     item.setChecked(true);
                                     wenCheck = true;
                                 }
                                break;

                             case R.id.Sat:
                                 if(item.isChecked())
                                 {
                                     item.setChecked(false);
                                     satCheck = false;
                                 }else
                                 {
                                     item.setChecked(true);
                                     satCheck  = true;
                                 }

                                 break;
                             case R.id.fri:
                                 if(item.isChecked())
                                 {
                                     item.setChecked(false);
                                     FriCheck  = false;
                                 }else
                                 {
                                     item.setChecked(true);
                                     FriCheck   = true;
                                 }

                                 break;
                                default:
                                    break;


                         }
                         return true ;
                     }
                 });
                    popupMenu.show();
                    break;
                default:

我在数据库上有一个功能:

List<CommunicationContact> campaigns = jdbcTemplate.execute(
                    new CallableStatementCreator() {
                        public CallableStatement createCallableStatement(Connection con) throws SQLException {
                            CallableStatement cs = con.prepareCall("{? = call MY_SERVICES.GET_CAMPAIGNS(?,?)}");
                            cs.registerOutParameter(1, OracleTypes.CURSOR);
                            cs.setString(2, customer);
                            cs.setString(3, channel);

                            return cs;
                        }
                    },
                    new CallableStatementCallback<List<CommunicationContact>>() {

                        @Override
                        public List<CommunicationContact> doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
                            cs.execute();
                            ResultSet rs = (ResultSet) cs.getObject(1);
                            List<CommunicationContact> communications = commContactRsExtractor.extractData(rs);

                            return communications;
                        }
                    }
            );

我相信带有out参数的存储过程也可以。