sql - db2 set multiple varchar variables -


How do you set multiple varchar variables for later use in multiple selective constraints?

is an integer example

  SET (NEW_VAR.SALARY, NEW_VAR.COMM) = (50000, 8000);  

I do not know how to do this for a varchar

  SET (NEW_VAR.var, NEW_VAR.var1) = ('Hello World%' ); SELECT * FooSchema.barTable as new WHERE b.first_name such as new_var.var and b.last_name such as new_var.var1;  

As Mustaccio said, you use a variable between a compound statement Can be a trigger or a routine. For your example (a trigger):

create trigger trigger 1 after referencing it on mytable referenced for NEW_VAR DECLARE val INT for each line; Set (NEW_VAR.var, NEW_VAR.var1) = ('% hello%', '% world%'); Select the new_var.var1 like new_var.var and b.last_name such as f WHERE b.first_name as valve from fooSchema.barTable. END @

or in a compound statement

  start var varchar (32); DECLARE var1 varchar (32); DECLARE val INT; Set (NEW_VAR.var, NEW_VAR.var1) = ('% hello%', '% world%'); Select the new_var.var1 like new_var.var and b.last_name such as f WHERE b.first_name as valve from fooSchema.barTable. END @  

Note that I have used an additional variable to output the selection. This type of query should only require one line. Otherwise, you should use the cursor.

Remember that you should execute these scripts with the following options:

  db2 -td @ ​​-f yourFilename.sql  
< / Div>

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -