View previous topic :: View next topic
|
Author |
Message |
Andi1982
New User
Joined: 27 Mar 2008 Posts: 42 Location: Karlsruhe / Germany
|
|
|
|
Hi,
i hava a spufi member with several selects and deletes.
Code: |
Delete from table.table1 where Keynumber = 1234 and Secondnumber = 54323;
insert into table.table1 (col1, col2, col3)
select col1, col2, col3
where Keynumber = 1234 and Secondnumber = 54323;
....
....
|
Is it possible to set a variable at first step so that i just have to change once the value of keynumber and secondnumber.
I tried something like that:
Code: |
SET KEYNUM = 1234;
SET SECONNUM = 54323;
Delete from table.table1 where Keynumber = KEYNUM and Secondnumber = SECONNUM;
insert into table.table1 (col1, col2, col3)
select col1, col2, col3
where Keynumber = KEYNUM and Secondnumber = SECONNUM;
....
....
|
This example does not work, but is something like this possible in spufi? We have DB2 Version 8, and 9 will follow soon.
Regards
Andi |
|
Back to top |
|
|
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 Location: chennai
|
|
|
|
I guess In SPUFI member, You can use "CHG" or "CHG ALL" command to replace. I think this will work. Then why you need "SET" command |
|
Back to top |
|
|
Andi1982
New User
Joined: 27 Mar 2008 Posts: 42 Location: Karlsruhe / Germany
|
|
|
|
Normally this was the way i did my changes. But sometimes
KEYNUM = 1234
and SECONNUM = 1234
but then
KEYNUM should be 5689
and SECONNUM should be 21454.
So the "change all" command is not possible anymore. I thought it would be easier to have one part in member where i can define the used variables.
My example is just a little one to show you my problem. I have much more Variables in my spufi. But i think i have to do this changes manual anymore. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
If I am remembering correctly, you can set variables if you wrap your SQL in a BEGIN and END SQL statement. |
|
Back to top |
|
|
Andi1982
New User
Joined: 27 Mar 2008 Posts: 42 Location: Karlsruhe / Germany
|
|
|
|
hm,
i can't find such syntax anywhere. I got an error when i tried this. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
if you would write your sql with conditions on separate lines, you could use a combination of x all, chg all nx. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
As i remember, BEGINN & END encloses a series of Transact-SQL statements so that a group of Transact-SQL statements can be executed. BEGIN and END are control-of-flow language keywords for Transact-SQL.
Transact-SQL (T-SQL) is Microsoft's and Sybase's proprietary extension to the SQL language. |
|
Back to top |
|
|
|