C# SQL Method to Oracle -


i need rewrite number of methods work clients oracle database. have work simple select statements, having trouble finding out how declare variable, setting info in variable, , inserting table; inside of command text sql. here simplified version of have sql version of method. appreciated. thank in advance.

public void sqloraclequestion(int numid)     {         exception exception = null;         try         {             stringbuilder sb = new stringbuilder();             sb.append(" declare @item varchar(5), @id int ");             sb.append(" set @id = " + numid.tostring() + " ");             sb.append(" select @item = max(cast(docid int)) table1 id = @id ");             sb.append(" set @item = cast(cast(isnull(@item, 0) integer) + 1 varchar(12)) ");             sb.append(" insert table2 (id, item, time) ");             sb.append(" select @id, @item, '" + datetime.now.tostring() + "' " );              sqlcommand cmd = new sqlcommand(sb.tostring(), _conn);             cmd.commandtype = commandtype.text;             _conn.open();              cmd.executenonquery();         }         catch (exception ex)         {             exception = ex;         }                 {             if (_conn.state != connectionstate.closed)                 _conn.close();              if (exception != null)             {                 throw exception;             }         }      } 

if dont have oracle database can create online schema , run queries using oracle website , test queries.

https://livesql.oracle.com/apex/f?p=590:1:106725498548660::no:::

oracle pl sql different t sql.

how declare variables in oracle:

declare     mynumber number(19,0) := 0;     mystring varchar2(100) := 'hello'; 

how put value variable:

select mycolumn mynumber mytable; 

how use declared variable. no @ required:

select * mytable mycolumn = mynumber; 

how insert in oracle using regular data or variable. 2 methods. note dual table in second method. special table dual sort of stuff. google it.

insert mytable (mycolumn, mycolumn2, mycolumn3) values (mynumber, 1, 1234); insert mytable (mycolumn, mycolumn2, mycolumn3) select mynumber, 1, 1234 dual; 

manually change variable:

mynumber := mynumber + 1; 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -