sql >> Database >  >> RDS >> Oracle

Zoeken in tabeltype records

declare 
characteristic CLONE_PRODUCT_CHAR_TABLE:=CLONE_PRODUCT_CHAR_TABLE(
      CLONE_PRODUCT_CHAR_RECORD(2,'ZIKA','ZIKA'),
      CLONE_PRODUCT_CHAR_RECORD(3,'MIGO','MIGO'),
      CLONE_PRODUCT_CHAR_RECORD(4,'ZAG','ZAG')
);
char_record CLONE_PRODUCT_CHAR_RECORD;
BEGIN
  for i in 1 .. characteristic.count loop
      if characteristic(i).characteristicID = 3 then
         char_record := characteristic(i);
         exit;
      end if;
  end loop;
  dbms_output.put_line(char_record.newValue);
  dbms_output.put_line(char_record.newValueName);
END;
/

U kunt ook proberen

declare 
characteristic CLONE_PRODUCT_CHAR_TABLE:=CLONE_PRODUCT_CHAR_TABLE(
      CLONE_PRODUCT_CHAR_RECORD(2,'ZIKA','ZIKA'),
      CLONE_PRODUCT_CHAR_RECORD(3,'MIGO','MIGO'),
      CLONE_PRODUCT_CHAR_RECORD(4,'ZAG','ZAG')
);
char_record CLONE_PRODUCT_CHAR_RECORD;
BEGIN

  select CLONE_PRODUCT_CHAR_RECORD(characteristicID, newvalue, newvaluename)
    into char_record from
   table(characteristic)
   where
      characteristicID = 3;

  dbms_output.put_line(char_record.newValue);
  dbms_output.put_line(char_record.newValueName);
END;
/



  1. Zoek een gebruikerspositie op een geordende SQL-tabel

  2. Met behulp van SQL Server opgeslagen procedures van Python (pyodbc)

  3. Hoe SQLite Total() werkt

  4. EXTRACT (datetime) Functie in Oracle