简体   繁体   English

使用游标Oracle插入数据

[英]insert data using cursor Oracle

Database: Oracle 11gr2; 数据库:Oracle 11gr2; Web application : JSP(Java) I have two tables: Web应用程序:JSP(Java)我有两个表:

Cities(***Id***, Name); Id is the Primary Key
Persons(***IdPers***, Name, IdCity_FK); IdCity is Foreign Key

IdCity_FK reffers to column Id from Cities. IdCity_FK引用来自城市的ID列。

The question: how to insert data from a insert.jsp page which has the following fiels:Person's name, City. 问题是:如何从具有以下字段的insert.jsp页面插入数据:人名,城市。

I want the user to enter his name and to select a city from some ListBox dynamically generated (using Cursor Oracle or a other method). 我希望用户输入他的名字,并从一些动态生成的列表框(使用Cursor Oracle或其他方法)中选择一个城市。
For instance, one does not enter : Andrew, 12, but enters Andrew and select New York. 例如,不输入:12岁的安德鲁,但输入安德鲁并选择纽约。 I managed to do this by using Oracle REF CURSOR, but when clicking submit I get error. 我通过使用Oracle REF CURSOR做到了这一点,但是单击“提交”时出现错误。 I think it does not pass an int value as parameter. 我认为它没有将int值作为参数传递。

The code 编码

 create or replace 
FUNCTION GET_CITIES
RETURN CITYPKG.ref_cursor
AS cities_cursor CityPkg.ref_cursor;
BEGIN
  OPEN cities_cursor FOR
  SELECT id, nume FROM CITY;
  RETURN CITIES_cursor;
END;

In the JSP page for editing I have a jspforward tag which sends me to a page which handles the form with request.getParameter... and calls a function which has 2 parameters: one is String the other one is int. 在用于编辑的JSP页面中,我有一个jspforward标记,该标记将我发送到处理带有request.getParameter ...的表单的页面,并调用一个具有2个参数的函数:一个是String,另一个是int。 The int one inserts the corresponding foreign key in the database. int将相应的外键插入数据库。 Thank you in advance. 先感谢您。

JSP文件(参数)出错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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