I have a logic in my plsql code and that uses a IF THEN ELSE logic . I want to move the logic to sql. How do I convert the logic of the IF THEN ELSE to SQL.
plsql logic
IF sns.quantity >= 0 /*stage_na_shipment sns*/
THEN
l_code := 'O';/*l_code is local variable*/
ELSE
l_code := 'C';
END IF;
SELECT bt_id INTO l_bt_bt_id FROM bill_type
WHERE code = l_code
AND ds_ds_id = 1;
how can i do the above logic using sql,i need to append the bt.id to this query
SELECT sns.order_num_cos,
1,
sns.ship_date,
sns.haulier_name,
sns.haulier_num,
sns.ship_date,
sns.order_num_cos,
sf.sf_id,
c.cust_id,
2,
1,
m.mkt_id,
0,
sns.ship_date,
sns.po_number,
sns.ship_date,
bt.bt_id,
sns.ship_date,
sns.stor_loc
FROM stage_na_shipment sns,
market m,
ship_from sf,
customer c,
bill_type bt
WHERE m.code = DECODE(SUBSTR(TO_CHAR(sns.client), 1, 4), 'US23', 'MM', 'US99', 'AFFCO')
AND sf.source_key = sns.ship_from
AND c.true_gcdb_source_key = TO_CHAR(sns.del_point);