Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create HTML drop-list from Oracle table?

Re: How to create HTML drop-list from Oracle table?

From: DIC <wilddic_at_rocketmail.com>
Date: Mon, 22 Feb 1999 16:11:53 GMT
Message-ID: <36d38182.7811966@soul>


On Fri, 19 Feb 1999 20:20:01 GMT, drider_trans_at_my-dejanews.com wrote:

>I am trying to create a drop-down list where the list items are generated
>from a table (Oracle). How would I do this in HTML (even though I am
>creating an application using Tango -- CGI host)? I really don't want to use
>Java and others, if possible. Thanks.
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

On my server I used next code:


procedure optionlist(tableName IN VARCHAR2, attr IN VARCHAR2 DEFAULT NULL) is

	c		integer;
	cnt		NUMBER;
	n_var	NUMBER;
	v_var	VARCHAR2(100);

begin

        c := dbms_sql.open_cursor;

        dbms_sql.parse(c,'select * from ' || tableName, dbms_sql.native);

	dbms_sql.define_column(c, 1, n_var);
	dbms_sql.define_column(c, 2, v_var, 100);
	cnt := dbms_sql.execute(c);

	htp.print('<html><body>');

	htp.prn('<select name="' || REPLACE(tableName,'.','_') || '" '
|| attr || '>');
	WHILE dbms_sql.fetch_rows(c) > 0 LOOP
		dbms_sql.column_value(c, 1, n_var);
		dbms_sql.column_value(c, 2, v_var);
		htp.print('<option value="' || n_var || '">' || v_var
|| '</option>');
	END LOOP;

	htp.print('</select>');

	htp.print('</body></html>');

	dbms_sql.close_cursor(c);

exception

	when others then
		dbms_sql.close_cursor(c);

	htp.print('</form></select><br>' || SQLERRM(SQLCODE) ||
'</body></html>');

end optionlist;


DIC
senior web-master [www.it.ru, www.boss.ru, www.it-scs.ru, www.infobooks.ru, www.smartcity.ru] Received on Mon Feb 22 1999 - 10:11:53 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US