- Create TableTablea (idInt, IpVarchar(15), appsVarchar(10 ))
- Insert IntoTableaSelect23,'2017. 0.0.1','Aaa'
- Go
- Declare@ Variable1Varchar(15), @ Variable2Varchar(10)
- Select@ Variable1 = ip, @ Variable2 = appsFromTableaWhereId = 23
- Select@ Variable1, @ Variable2
- /*
- -------------------------
- 127.0.0.1 aaa
- (One row is affected)
- */
- Go
- Drop TableTablea
The multi-character value assignment method of SQLSERVER is as shown above. You can directly SELECT
However, in Oracle PLSQL, select into can only assign values to a single variable, but cannot assign values to multiple variables at the same time.
For example, select count (*) into nb_count from t_khz where fzbh = V_fzbh;
Multi-variable value assignment generally adopts the cursor FETCH method:
- CursorC_rwIs
- Select*FromT_kh
- R_rw c_rw % rowtype;
- OpenC_rw;
- Loop
- FetchC_rwIntoR_rw;
- ExitWhenC_rw % notfound;
- Dbms_output.put_line (r_r1_khbh |''| R_r1_khxm |''| R_rw.yzbm );
- EndLoop;
- CloseC_rw;
Another way is to use ROWTYPE.
- -- Local variables here
- IInteger;
- V_kh t_kh % rowtype;
- Gin
- -- Test statements here
- Select*IntoV_khFromT_khWhereRownum = 1;
- Dbms_output.put_line (v_kh.khbh |''| V_kh.khxm |''| V_kh.yzbm );
- D;
For more information about Oracle, see Oracle topics page http://www.bkjia.com/topicnews.aspx? Tid = 12