I have a variable called c_kilometers. I have a cursor that grabs a bunch of records that have those kilometers. I need to run two separate SELECT statements in the cursor that simply grab a kilometer from one table based on values in the cursor, and run another SELECT doing the same thing on another table.
SELECT t.kilometers INTO c_kilometers FROM table_name WHERE WHERE l.code = cursor_t.code_att SELECT g.kilometers INTO c_kilometers FROM table_name WHERE l.code = cursor_t.code_aff
My question is can I add the c_kilometers together without creating a temporary variable to hold on of the values? I haven’t used PL/SQL in awhile, and I don’t remember having to do this ever, so this is more of a learning question than anything.
Provided that both your queries always return exactly one row, you can do either of the following:
If they’re in the same table as you posted, you can use:
It seems that it will be more efficient to put
table_nameinto yourSELECTquery that produces the cursor.If you post this query, I’ll probably can help to do this.