Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

column value can be inserted

Tags:

excel

I know I can use CASE statement inside VALUES part of an insert statement but I am a bit confused.

I have a statement like,

like image 339
Noman K Avatar asked May 05 '14 12:05

Noman K


People also ask

How do I insert a specific value in a column in SQL?

INSERT INTO Syntax 1. Specify both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3, ...)

How we can insert values in table?

In syntax, First, you must specify the name of the table. After that, in parenthesis, you must specify the column name of the table, and columns must be separated by a comma. The values that you want to insert must be inside the parenthesis, and it must be followed by the VALUES clause.

Can we insert values in view?

You can insert data through a single-table view if you have the Insert privilege on the view. To do this, the defining SELECT statement can select from only one table, and it cannot contain any of the following components: DISTINCT keyword.


1 Answers

You can try also a procedure:

create or replace procedure insert_XYZ (P_ED_MSISDN         IN VARCHAR2,
                                        P_ED_OTHER_PARTY    IN VARCHAR2) is

begin  

    INSERT INTO TABLE_XYZ ( ED_MSISDN, 
                            ED_OTHER_PARTY,  
                            ED_DURATION) 
      VALUES (P_ED_MSISDN , 
              P_ED_OTHER_PARTY , 
              CASE  
                  WHEN P_ED_OTHER_PARTY = '6598898745' THEN 
                      '9999999' 
                  ELSE
                      '88888' 
              END);

END;
like image 189
Giacomo Garabello Avatar answered Oct 09 '22 05:10

Giacomo Garabello