如何在oracle 10g中使用成员

时间:2016-03-10 06:20:24

标签: oracle plsql oracle10g

我想检查一个元素是否是sys.odcinumberlist varray的成员。

但它不起作用......

我的代码出了什么问题?

    fbloginButton.registerCallback(callbackmanager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            AccessToken accessToken = loginResult.getAccessToken();
           GraphRequest graphRequest=GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
               @Override
               public void onCompleted(JSONObject object, GraphResponse response) {

                   if (response.getError()!=null)
                   {
                       Log.e(TAG,"Error in Response "+ response);
                   }
                   else
                   {
                       email=object.optString("email");
                       Log.e(TAG,"Json Object Data "+object+" Email id "+ email);
                   }


               }
           });

            Bundle bundle=new Bundle();
            bundle.putString("fields","id,email,name");
            graphRequest.setParameters(bundle);
            graphRequest.executeAsync();

        }

此代码抛出的错误是

DECLARE
  v_list sys.Odcinumberlist := sys.Odcinumberlist( 1, 2, 3, 4 );
BEGIN

  FOR i IN 1..v_list.COUNT LOOP
    dbms_output.put_line( v_list(i) );
  END LOOP;

  IF 1 MEMBER OF v_list THEN
    dbms_output.put_line( 'yes' );
  ELSE
    dbms_output.put_line( 'no' );    
  END IF;

END;

2 个答案:

答案 0 :(得分:2)

SYS.Odcinumberlist是VARRAY,并且VARRAYS不支持嵌套表的比较。 更多信息在这里 - &gt; https://docs.oracle.com/cd/B12037_01/appdev.101/b10799/adobjcol.htm
您可以使用SQL和表函数。请参阅下面的示例

	(function(document) {
	'use strict';

	var LightTableFilter = (function(Arr) {

		var _input;

		function _onInputEvent(e) {
			console.log(e);
			_input = e.target;
			var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
			Arr.forEach.call(tables, function(table) {
				Arr.forEach.call(table.tBodies, function(tbody) {
					if(e.code === "Backspace"){
						Arr.forEach.call(tbody.rows, _defaultfilter);
					}else{
						Arr.forEach.call(tbody.rows, _filter);
					}
					
				});
			});
		}

		function _defaultfilter(row) {
			console.log(row);
			var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
			row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
		}

		function _filter(row) {
			console.log(row);
			var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
			console.log(_input.value);
			if(val.length >= 3){
				row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
			}
		}

		return {
			init: function() {
				var inputs = document.getElementsByClassName('light-table-filter');
				Arr.forEach.call(inputs, function(input) {
					input.addEventListener("keyup", _onInputEvent);
				});
			}
		};
	})(Array.prototype);

	document.addEventListener('readystatechange', function() {
		if (document.readyState === 'complete') {
			LightTableFilter.init();
		}
	});

})(document);

或者,您可以遍历集合

<section class="container">

	<h2>Light Javascript Table Filter</h2>

	<input type="search" class="light-table-filter" data-table="order-table" placeholder="Filter">

	<table class="order-table table">
		<thead>
			<tr>
				<th>Name</th>
				<th>Email</th>
				<th>Phone</th>
				<th>Price</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>John Doe</td>
				<td>john.doe@gmail.com</td>
				<td>0123456789</td>
				<td>99</td>
			</tr>
			<tr>
				<td>Jane Vanda</td>
				<td>jane@vanda.org</td>
				<td>9876543210</td>
				<td>349</td>
			</tr>
			<tr>
				<td>Alferd Penyworth</td>
				<td>alfred@batman.com</td>
				<td>6754328901</td>
				<td>199</td>
			</tr>
		</tbody>
	</table>

</section>

答案 1 :(得分:1)

  

由于SYS.Odcinumberlist是VARRAY并且不支持比较。   您可以使用嵌套表类型,如下所述..

SET SERVEROUTPUT ON;
DECLARE
TYPE v_list_tab
IS
  TABLE OF NUMBER;
  v_list v_list_tab:=v_list_tab(1,2,3,4,5);
BEGIN
  FOR i IN 1..v_list.COUNT
  LOOP
    dbms_output.put_line( v_list(i) );
  END LOOP;
  IF 1 MEMBER OF v_list THEN
    dbms_output.put_line( 'yes' );
  ELSE
    dbms_output.put_line( 'no' );
  END IF;
END;