using variable in a procedure stored

Hello
I have a select statement that returns a numeric value.
I need to store the value in a variable and pass it to an insert...
to do this, I created a stored procedure that accepts two variables... one for the select statement and the other for the Insert...

the stored procedure:
---------------------------------------------------------------------------------------------------------------------------

create or replace procedure ins_state (State in varchar2, countr in varchar2)
as
var I digital;
Start
I: = select country_id of countries where country_name = countr.
insert into statement (country_id, state_name) values (i, State);
commit;
end ins_state; /

---------------------------------------------------------------------------------------------------------------------------

the problem is that I m getting the error: -.

---------------------------------------------------------------------------------------------------------------------------

ERROR on line 6: PLS-00103: encountered the symbol "INSERT".

4. start
5 i: = select country_id of countries where country_name = countr.
6. Insert the values of the State (country_id, state_name) (i, State);
7 validation;
8 end ins_state; /

---------------------------------------------------------------------------------------------------------------------------

Any help...
Thank you
Zita, India

Find the right syntax below:

create or replace procedure ins_state (State in varchar2, countr in varchar2)
as
i the number;
Start
Select country_id in I country where country_name = countr.
insert into statement (country_id, state_name) values (i, State);
commit;
end ins_state; /

Tags: Database

Similar Questions

  • Using variables in a procedure

    Hello experts,

    I am new in odi, but did very well but I'm not reached to use variables ate a bunch of odi.
    Let me explain the problem:

    (1) I create three variables non-persistent to odi that retrieves the value of a sql statement select, like this, for example:

    Select '< % odiRef.getPrevStepLog ("SESSION_NO") = >' FROM DUAL; (Variable name-SESS_NO)
    Select '< % odiRef.getPOP ("POP_NAME") = >' FROM DUAL; (Variable name-INTER_NAME)
    Select '< % odiRef.getPrevStepLog ("STATUS") = >' FROM DUAL; (Variable name-FLAG_STA)
    ...

    (2) then I create an odi procedure that insert values into a table of newspaper: insert into < table_name > values ('#SESS_NO', 'INTER_NAME', '#FLAG_STA')

    (3) then I create a package that has the following:

    Interface (success)-> procedure (with the insert statement)

    The question is, where do I put the variables? Everywhere where I put them, the operator gives me an error message which, during the execution of the insert statement, indicate that the variable has no value. I'm trying to insert then before the intervention, (Interface (success)-> var1 (success)-> Var2 (success)-> Var3 (success)-> procedure (with the insert statement)), but they, of course, an error because the previous step of the var1 var2, where should be the interface.

    I'm trying to create a scenario (new package) with the variables and the main package becomes like this:

    (Interface (success)-> script (new package) (success)-> procedure (with the insert statement)

    But the error still occurs, and no value is assigned to the variables.

    Any help will be appreciated gratefully.

    Thanks in advance,

    Daniel huh

    Published by: user10470648 on November 10, 2008 04:11

    Hi Daniel,.

    Sorry for my delay to answer you...

    To solve the problems...

    (1) OK

    (2) you must repeat the "refresh state variable' running after each interface or the procedure. It is possible to paralallel the execution but it's a different architecture.

    (3) on the variables, simply drag and drop it to the package and leave it as declaring type. This wll allow you, after creating a scenario, use these variables as stamped.

    I'll send you an ODI paper on how to use it (in replay to the email you sent me)

    This help you?

    Published by: Cezar Santos on 11/12/2008 11:34

  • Problem running procedure using Variables

    Hi all

    I am trying to execute the procedure in a statement declared/Begin/End and using variables as parameters of entry in my interior but I get away to an invalid SQL statement error. My code is below:
    declare
    
      START_dt  VARCHAR2(30);
      END_DT VARCHAR2(30);
      
         
      begin
            
        SELECT '01-APR-2011'
        INTO END_DT
        FROM DUAL;
      
        SELECT '01-APR-2020'
        INTO END_DT
        FROM DUAL;
             
           
         BEGIN EXECUTE IMMEDIATE 'INSERT_PROV_ACSC_IND_REF('||START_dt||','||END_DT||')';END;COMMIT;
    
     end;
    
    Error at line 1
    ORA-00900: invalid SQL statement
    ORA-06512: at line 18
    Is the way that I normally run my procedure outside this statement Declare/Begin/End: EXECUTE INSERT_PROV_ACSC_IND_REF('01-APR-2011','01-APR-2020');

    The table that takes the data from the procedure does not correct timestamp but my procedure takes the varchar above dates and turns them into dates in the procedure so that the entry date settings are left as a string.

    Any help would be appreciated.

    Thank you

    And if you want to use variables:

    declare
        START_dt  VARCHAR2(30);
        END_DT VARCHAR2(30);
    begin
        START_dt := DATE '2011-04-01';
        END_DT := DATE '2011-04-01';
        INSERT_PROV_ACSC_IND_REF(START_dt,END_DT);
    end;
    /
    

    SY.

  • Insert multiple records in a database using the DB adapter and stored procedure

    Hi all

    I want to insert multiple records in a database using a stored procedure. I wanted to insert these records using a data adapter and data adapter must be called by a mediator.

    Can anyone suggest me some ideas if it's possible with capabtilities OOB in SOA suite or not?

    Thank you for your help in advance.

    Thank you
    Shiv

    The trick is in the stored procedure. You must use a data type that will handle multiple records I use varray. An example can be found in this post.

    Re: Mutiple calls to AppsAdapter (pl/sql) when the payload has multiple records

    When you read the procedure stored in the db adapter wizard looks and xsd / xml if you have maps accordingly.

    see you soon
    James

  • Using variables such as table names. Ideas for alternative designs

    Hello

    I am the design of an application that uses synonyms to pull information from the 'client' DBs via links from DB. Synonyms are created with a DB_ID in name (example: CUSTOMER_100, CUSTOMER_200... where the 100 and 200 are DB IDs of 2 separate DBs customer.)

    I have a procedure that selects data in the synonym based on what DB_ID is passed to the procedure. I want to be able to perform this procedure for any entered DB_ID. I know now I can't use variable for the table names names and using EXECUTE IMMEDIATE does not seem suitable for what I'm trying to do.

    Does anyone have suggestions or re-design options, I could use to achieve this generic procedure which will select a certain synonym based on the information of DB input parameters? Thank you.

    CREATE or REPLACE PROCEDURE CUSTOMER_TEST (p_host IN VARCHAR2, p_db_name IN VARCHAR2, p_schema in VARCHAR)

    IS

    v_hostname VARCHAR2 (50): = UPPER (p_host);

    v_instance VARCHAR2 (50): = UPPER (p_db_name);

    v_schema VARCHAR2 (50): = UPPER (p_schema);

    v_db_id NUMBER;

    v_synonym VARCHAR2 (50);

    CURSOR insert_customer

    IS

    SELECT

    c.customer_fname,

    c.customer_lname

    OF v_synonym_name c;

    BEGIN

    -MADE BASED ON INPUT PARAMETERS DB_ID

    Select d.db_id

    in v_db_id

    of t_mv_db_accounts ac.

    t_mv_db_instances I,.

    t_mv_dbs d,

    t_mv_hosts h

    where ac.db_ID = d.db_ID

    and i.db_ID = d.db_ID

    and i.HOST_ID = h.host_id

    and upper (H.HOST_NAME) = v_hostname

    and upper (D.DB_NAME) = v_instance

    and upper (Ac.ACCOUNT_NAME) = v_schema;

    -ADD DB_ID TO NAME SYNOYNM

    v_synonym: = 'CUSTOMER_ | v_db_id;

    FOR cust_rec IN insert_customer

    LOOP

    INSERT INTO CUSTOMER_RESULTS (First_Name, Last_Name)

    VALUES (cust_rec.customer_fname, cust_rec.customer_lname);

    END LOOP;

    COMMIT;

    END;

    /

    RGS,

    Rob

    EXECUTE IMMEDIATE ' INSERT IN CUSTOMER_RESULTS (First_Name, Last_Name) SELECT customer_fname, customer_lname FROM ' | v_synonym;

  • Captivate 7 text truncated when using variables.

    I use 7 Captivate and feels truncated text when I use variables in text captions. I have a text entry area that I assigned to a variable of 'v_name' to. In a text caption, I have the following text: "$$ v_name$ $ to view the text stored in the variable.» I know there is a way to adjust the length of the variable, but I can't seem to find in this version!

    Do not type "$$var$ $" in the text of the legend, but Insert button X (near the button symbol) in the role of composition of the properties panel. In the dialog box, you will find a way to increase the length of the inserted variable.

  • With the clause in a procedure stored with update

    create table TEMP_STAGE as
    (select ' 111111' student_id, ' don't TMP_TEST FROM DUAL ")
    UNION
    Select '111111' student_id, ' don't TMP_TEST FROM DUAL
    UNION
    Select ' 222222' student_id, ' don't TMP_TEST FROM DUAL;
    )

    CREATE OR REPLACE PROCEDURE TEMP_SEC_TEST
    AS
    BEGIN
    UPDATE TEMP_STAGE S
    SET S.TMP_TEST = 'Y '.
    WHERE STUDENT_ID IN
    (
    WITH MARK AS
    (
    SELECT '111111' DOUBLE STUDENT_ID
    )
    Select STUDENT_ID in BRAND
    );
    END;

    I have a huge SQL statement with several "with" of tables in the statement. It works if I run it as a script but it doesn't work when I put it in a stored procedure.
    When I run the above, it gives me an error...
    Syntax error (8:9) check
    Found 'BOOKMARK' waiting...

    It gives me an error the TSF online brand...

    I have to do it in the stored procedure that the statement is very complicated...

    Help, please.

    Which tool you use to create the procedure? Error syntax Check (8:9) is not a mistake, Oracle, or what I know from any Oracle product.

    It works very well in sqlplus.

    SQL> CREATE procedure my_p AS
      2  BEGIN
      3     UPDATE t
      4     SET descr = 'Un'
      5     WHERE id IN (WITH tmp AS (
      6                     SELECT 1 x FROM dual)
      7                  SELECT x FROM tmp);
      8  END;
      9  /
    
    Procedure created.
    
    SQL> SELECT * FROM t;
    
            ID DESCR
    ---------- ----------
             1 One
    
    SQL> exec my_p;
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT * FROM t;
    
            ID DESCR
    ---------- ----------
             1 Un
    

    John

  • updating of a variable in a procedure

    Hello!

    I know this thread has already posted several times, but I am doing everything as it is explained and it still does not work.

    I created the variable STARTDATE: TEXT, the most recent value and a package with following steps:

    (1) declare the Variable STARTDATE
    (2) update the Variable STARTDATE
    (3) procedure

    The procedure uses the variable, but does not recognize it.

    Update Table1 set eof_timestamp_2 = eof_timestamp_1 where eof_timestamp_1 > = to_date ('#ODS.) STARTDATE ',' dd.mm.yyyy hh24:mi:ss')

    Thanks for help
    Marcin

    It should work... seems that ODI is not translating the variable.

    Let me suggest something to debug this variable...

    Creat a step before update like:

    Technology: Java BeanShel
    Check ignore error checkbox

    Command:

    throw new Exception ("' \n\n is the value of the variable: #STARTDATE \n\n '")

    This command should show if ODI can recognize the variable inside the procedure.

    Run and tell me what you have to tab performance (operator)

    Cezar Santos
    [www.odiexperts.com]

  • What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?

    Hi all

    I am new to TestStand. Still in the learning process.

    What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?

    Thanks in advance,

    LaVIEWan

    I'm sorry... I discovered that... its not at all possible to pass data to another sequence using variables... it must be through settings... once again I apologize for the display of such a stupid question

  • Impossible to use variables shared when deploying an exe file

    I tried to use variables shared for some time. I have been all over the forums and still have had no luck. I can get these VI to work until I have install on another PC while they do any work. I don't know what I'm doing wrong. I forced libraries to deploy, but they still do not work on the machine, that I install the exe file. I don't think that libraries are being installed. I can't see in the Distributed System Manager. I can see libraries on other machines, but not on the one that I have.

    Have you included libraries in section always included the source files.  You did, and then change the destination of the library of media files on the Source code file settings tab?

    In the code are you using the correct path when calling the libraries deployment method.   Current path of the VI should be stripped twice and have "data\name.lvlib" built in the end.

  • Using variables on localization files

    Hi all!

    I would like to know if it is possible to use variables on the HR files, so they could be replaced by a dynamic text while the application is running.

    My point is, I need to post this message on an alert:

    "Hi Carlos, the pleasure of you review", "Carlos" is the user name and of course it's different for each installation.

    Must be something like this:

    key: GREETINGS_MSG

    value: Hi %s, the pleasure to see you

    And then.

    Dialog.Alert (_res.getString (GREETINGS_MSG, "Carlos").

    So, is it possible to do this?

    Thank you!

    According to what you're asking, it's what I found.

    See if you can try this:

    http://www.BlackBerry.com/developers/docs/5.0.0api/NET/rim/device/API/i18n/MessageFormat.html

    http://Java.Sun.com/J2SE/1.3/docs/API/Java/text/MessageFormat.html

    Example:

    Object[] arguments = {     new Integer(7),     new Date(System.currentTimeMillis()),     "a disturbance in the Force" };
    
     String result = MessageFormat.format(     "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",     arguments);
    
  • You can use variable substitution in the Calc script.

    Hi guys,.

    I want to use variable substitution in the calculation script. I v_SECSUBAREA that my substitution variable and its value would be like C12.00 or C13.00 or C12.00, C13.00.

    But it gives me error mentioned below by checking the syntax of the calculation script.

    Error: parsing formula [statement of DIFFICULTY] (line 15) 1200315 error: invalid object type

    Calculation script:

    -----------------------------

    FIX (& v_CLEARYEAR, & v_CLEARMON)

    FIX (& v_SECSUBAREA)

    DIFFICULTY ('REPGBP', 'REPEUR', 'REPUSD', 'local', @DESCENDANTS ("DIVISION"), @LIST(&v_SECDNBENTITY), @DESCENDANTS ("SubAnalysis"),

    @DESCENDANTS ("RTNROW"), @DESCENDANTS ("RTNCOL"))

    CLEARDATA "RESUB."

    ENDFIX;

    ENDFIX;

    ENDFIX;

    Variable substitution:

    ----------------------------------

    PRCCOR_ALLv_SECSUBAREAC12.00

    Calculation script does not have C12.00 as the value for the variable substitution. If I give FY15 then Script gives me a correct syntax.

    Please help me to get this resolved.

    Thank you

    Shruti

    Hello

    Assuming that you calculate in the PRC. Database COR_ALL.

    You may set the C12.00 value in quotes like "C12.00".

    Kind regards

    Philip Hulsebosch.

  • How can I use variable presentation logic SQL

    Hi Experts,

    How can I use variable SQL logical presentation. I need the exact syntax. Kindly help me to achieve this goal.

    "Time". "" Date "between the Date of 2014 '-1-17 'and Date' ' 2014-2-16

    Thanks in advance

    Asim

    It's done... We can use it in the logical query with the same syntax where we use in converting this filter as SQL...

  • How will I know use db_link on the procedure or function?

    If PROCEDURE A use YES dblink

    PROCEDURE AN ACE

    CURSOR CUR_1 IS

    SELECT * from oracle. DEPT@YES;

    BEGIN

    .....

    END;

    Is there a way to select ?


    SELECT * FROM DBA_DB_LINKS;

    The PROCEDURE has use YES DB_LINE...




    You can use the view all_dependencies to get the name of the db link. Try the following query

    SELECT REFERENCED_LINK_NAME FROM ALL_DEPENDENCIES WHERE name = 'proc_name"AND the TYPE = 'PROCEDURE '.

    (GOLD)

    SELECT * FROM ALL_DEPENDENCIES WHERE REFERENCED_LINK_NAME IS NOT NULL';

    If you want more, you can check below link

    Ask Tom & quot; addiction & quot;

  • Call procedures stored in adf

    Hi all

    is it possible to call procedures stored in the adf.

    Thank you

    Hello

    It's my first chance to "pay it forward". Please visit this link (which helped me): Blog of Zeeshan Baig: the PL/SQL procedure call and function in the Oracle ADF application

    James

Maybe you are looking for