Sql/plsql que

hi to all,
sql> desc test
Name Null? Type
DEPTNO NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
sql>begin
execute immediate 'alter table test add lid number';
insert into test values (12,'hyd','sys',45);
end;
these are statements i excute but i got an error.
insert into test values (121,'hyd','sys',45);
ERROR at line 3:
ORA-06550: line 3, column 13:
PL/SQL: ORA-00913: too many
values
ORA-06550: line 3, column 1:
PL/SQL: SQL Statement ignored
pls clarify my queston
thanks&regards
nataraj kesana
Edited by: nataraj kesana on Jan 7, 2011 2:35 AM
Edited by: nataraj kesana on Jan 7, 2011 4:38 AM

As everyone told, this doesn't sound the perfect way to do. But, if you are doing this one time, and I hope you have a ALTER TABLE... DROP COLUMN statement before executing this.
Try this, the INSERT statement is now part of the DYNAMIC SQL.
declare
curid NUMBER;
sql_stmt1 varchar2(300);
sql_stmt2 varchar2(300);
BEGIN
sql_stmt1 := 'alter table test12 add lid number';
sql_stmt2 := 'insert into test12 values (12,''hyd'',''sys'',45)';
curid := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(curid, sql_stmt1, DBMS_SQL.NATIVE);
dbms_output.put_line(DBMS_SQL.EXECUTE(curid));
DBMS_SQL.PARSE(curid, sql_stmt2, DBMS_SQL.NATIVE);
dbms_output.put_line(DBMS_SQL.EXECUTE(curid));
END;

Similar Messages

  • Need advise on SQL,plsql developer career and future

    Hi all,
    I need all your advise in making an important decisions of my career path.I work in the IT field and have about total 4-5 years of work experience involving development and testing in a product based organization.
    Presently-i have got chance since last 4-5 months to work with writing PLSQL code,SQL etc on a part basis. I am very much interested to continue my career path as a PLSQL developer.
    But, unfortunately -in the total of my work experience-in the past 2-3 years-i worked with a internally developed DB query language(similar to SQL) and then from last few months with plsql. But this chance to work with PLSQL has been for less time and limited scope after which i will have to work on something different.
    Ii want to fully take on my career in SQL,PLSQL as Database Developer.
    Please advise me if my thinking seems logical and good and if I could do it. I have planned on applying for relevant SQL,PLSQL profile jobs.
    Now, My serious worry and concern is I feel that since i have worked very less with PLSQL-so am low in confidence that I feel i wont be able to answer ,or tell or not knowledgeable enough to be able to clear the technical interviews for SQL,plsql development profile which would need at least some years of experience.
    I have started studying and practsing PLSQL,sql by myself for from internet. So, can you all please advise me on how could i prepare myself for hard core technical interviews of SQL,PLSQL knowledge for about 2-3 years expertise.
    I know its not much possible to be competent so much in the subject by just studying and practicing.Its easy as saying to study and get it by myself-but i want to try and will put my best for it.
    Please help me with your inputs,all interview questions,hard ones-suggestions,links,any study materials, real time problems which i can try solving of SQL, PLSQL development.
    Thanks All

    Hi,
    A very good starting point is (in my opinion): [Steven Feuerstein PL/SQL Obsession|http://www.toadworld.com/Knowledge/DatabaseKnowledge/StevenFeuersteinsPLSQLObsession/tabid/153/Default.aspx]. Also the official site [PL/SQL Technology Center|http://www.oracle.com/technology/tech/pl_sql/index.html]
    Regards,

  • Problem with variables in dynamic SQL/PLSQL

    Hi, I have a problem I am trying to solve using a very short piece of dynamic SQL/PLSQL but I am having problems getting the variable values out of the dynamic block.
    I need to increment a counter which could be any one of 16 counters I am using and I want to avoid using nested IF statements.
    The variable to be incremented is made up of the 'scheme', the 'contributory category' and the 'employment category' (although not every combination is valid)
    The 'scheme' can be either 'no1', 'no2', 'off', 'cg' or 'amc'
    The 'contributory category' can be either 'cont' or 'noncont'
    The 'employment category' can be either 'ft' or 'pt'
    For example the total variable name could be 'v_cg_noncont_ft_count'
    I have created a variable by concatenating the various elements called v_incr_count_name which holds the name of the variable I want to increment.
    I am running this within an anonymous PLSQL block so I cannot use global variables meaning that my variables are not visible within a dynamic PLSQL block.
    As a result I think I will need to use bind variables with a PLSQL block or a SELECT FROM INTO SQL string
    I have tried various solutions including the following PLSQL solution:
    v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'BEGIN :a := :a + 1; END;';
    EXECUTE IMMEDIATE sql_stmt USING v_incr_count_name;
    Unfortunately I am getting the 'IN bind variable bound to an OUT position' error which I suppose makes sense as I am trying to change the value of a variable in the main PLSQL block from within the dynamic block.
    Another (SQL) solution I tried was:
    v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'SELECT '||v_incr_count_name||' + 1 FROM DUAL';
    EXECUTE IMMEDIATE sql_stmt INTO v_return;
    While this executes and returns the incremented value into v_return, I am still left unable to copy the returned value into the variable whose name is stored in v_incr_count_name
    Any help appreciated
    Cheers, Dan

    this shows the syntax for the using clause
    declare
    a number := 1;
    b number := null;
    v varchar2(10) := 'A';
    begin
    execute immediate 'begin :v1 := :v1 + 1; end;' using in out a;
    dbms_output.put_line(a);
    end;
    /but what you want cannot be done
    SQL> declare
      2  a number := 1;
      3  b number := null;
      4  v varchar2(10) := 'A';
      5  begin
      6  execute immediate 'begin '||v||' := :v1 + 1; end;' using in out a;
      7  dbms_output.put_line(a);
      8  end;
      9  /
    declare
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'A' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at line 6the variable "V" contains the name of the desired output variable ("A"). this errors because "A" is not defined within the scope of the dynamic sql.
    "into the variable whose name is stored in v_incr_count_name"
    pl/sql does not support dereferencing variables, so you can't do it.

  • Hide or encrypt password in SQL/PLSQL code

    Hi,
    I need some help or suggestions to hide or encrypt database user password in SQL/PLSQL code. In our environment, we use a connect string with username/password for the JDBC connection. Our goal is to take out the password string and read it or pass it to the code on the fly.
    Thanks,
    Subroto

    So in the database somewhere you are storing username and password credentials? How do those credentials get sent to the Java application? Presumably, the Java application has to connect to the database, requiring a JDBC connection string, in order to query the table in order to get the username and password you've stored in the database.
    Assuming there are two different JDBC connection strings-- one in the Java application that connects to the database and a second that is stored in the database and used later by the Java application, who do you want to protect the data from? Do you want to protect it from other database users? Or do you want to protect it from the Java developers? Or something else?
    Justin

  • How create query based .txt, .pdf file in SQL/PLSQL

    Hello,
    I am sending email alerts for new employements/resigns.
    I want to create ry based .txt, .pdf file in SQL/PLSQL and email it.
    How i can create file
    queyy : select dempartment,empid,name,joining_date from employee;
    Thanks

    Andreas Weiden wrote:
    There is a commercial tool called plpdf, but i can't tell if its good..
    Also possible would be to create an XML-FO with sql or pl/sql.
    And then use Apache-FOP to convert the XML-FO into a pdf, rtf or whatever you want.
    No extra costs but the effort to learn a bit about the fo elements/syntax.
    I think the newer Apex-Versions can doing something like this also. Maybe additionally ask in the Apex Forums.

  • Requirement for finishing OCA - Oracle 9i SQL-PLSQL

    Hi,
    I am planning to give the OCA certification in SQL-PLSQL Oracle 9i.
    Please let me know, after successful completion of both the SQL and PLSQL exams, do I also require to have the Oracle certified training to get the certificate from Oracle.
    On the below URL
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=152
    There is no such mention. Howerver for OCP, it is required to have the training.
    I called up few of the test centers and they all told me that I have to undergo the Oracle training, then only I will get the certificate. However, I dont feel that I need training to clear the OCA certification Oracle 9i.
    Please confirm me on the requirement of training for getting the Certificate from Oracle on succesful completion of both SQL and PLSQL exams.
    Regards,
    Saurabh

    SaurabhAg wrote:
    Hi,
    I am planning to give the OCA certification in SQL-PLSQL Oracle 9i.
    Please let me know, after successful completion of both the SQL and PLSQL exams, do I also require to have the Oracle certified training to get the certificate from Oracle.
    On the below URL
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=152
    There is no such mention. However for OCP, it is required to have the training.
    I called up few of the test centers and they all told me that I have to undergo the Oracle training, then only I will get the certificate. However, I dont feel that I need training to clear the OCA certification Oracle 9i.
    Please confirm me on the requirement of training for getting the Certificate from Oracle on succesful completion of both SQL and PLSQL exams.
    Regards,
    SaurabhFor PL/SQL OCA you do not require training to get the certification. Nor do you for PL/SQL OCP (For a lot of OCP's you do have to have training).
    - Of course Oracle would recommend ou have training.
    Please note that the PL/SQL OCA and OCP certifications are non version specific.
    With the best will in the world a (Pearson VUE) test center only really deals in exams, they do not deal in certifications.
    However some Test Centers may also be associated with training establishments.
    You may have been given mis-information for one of three reasons I can think of:
    1) They may have misunderstood your question.
    2) The may have genuinely not known the answer, and because DBA OCP needs training they may have thought and not checked Pl/SQL OCA needs it.
    3) They may have been fraudulently trying to sell you training you did not need.
    You can always book the required exams online anyway.
    BUT HOLD ON A SECOND ... ;-) ... BEFORE I SLANDER PEOPLE OFF: :-) [ There's meant to be a smiley here bu it keeps disappearing ]
    The link you have given is for 9i DBA OCA/OCP .... and to get the 9i DBA OCP you DO need to have training.
    The certification you have asked about is (9i) PL/SQL OCA/OCP ..... and the required page for that is here .....
    .... http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=155
    If you look at this carefully you may be able to begin to confirm what you want.
    Edited by: bigdelboy on 17-May-2011 09:18 Ensuring something is taken as a joke... have added smiley. (Am already in doghouse with missus today for saying something wrong way).
    Edited by: bigdelboy on 17-May-2011 11:08 trying to tidy this up.

  • How the SQL Query Parsing is processing inside SQL/PLSQL engine?

    Hi all,
    Can you explain how the SQL Query Parsing is processing inside SQL/PLSQL engine?
    Thanks,
    Sankar

    Sankar,
    Oracle Database concepts - Chapter 24..
    You will find the explanation required under the heading parsing.
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm

  • How Track&monitor the history of executed sql /plsql on 10g database server

    I want to keep and track the history of all sql/plsql that is being execute on database server. how it is to be done.
    pls help
    prabhaker

    To keep track of executed SQL statements, you can use database auditing : see http://oraclelon1.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4007.htm#i2059073
    I am not sure that PL/SQL execution can be traced using database auditing.

  • String formatting in SQL/PLSQL

    How can we format strings (Varchar) using sql/plsql? Are there any functions using which I can format varchar variables. e.g., to convert an amount 100000 to 100,000.00 .

    Hi Swamy,
    You will get this error if you try to format a char column.
    If you are sure that the value is numeric try converting by TO_NUMBER and then use the TO_CHAR function for formatting purpose.
    Eg:
    SQL> select to_char(to_number('643455'), '9,999,999.99') from dual;
    Cheers.
    Jeeva.

  • Please recommend a SQL / PLSQL training book

    Anybody could recommend a SQL / PLSQL training book:
    1. problem-solution style,
    2. from beginner to advanced level
    Or do we have any website which have this function ?
    I want to practice, practice, practice....
    Thanks.

    It has that part also.
    But, this is a good book to learn oracle.
    Perhaps, your requirement make me nostalgic about my childhood days when we are solving dummy question and answers from Question Bank. ;)
    If you are really hungry for such oracle problem and it's solution. Then why not join regularly in OTN forum here? ;)
    Regards.
    Satyaki De.

  • How to get sql/plsql links?

    Hi All,
    This is Anoo.. where i am working on Apex projects.. Now are looking for a guy where he can handle Sql/Plsql.
    I have tried to search in google for interview questions bascially on Sql/Plsql, but i was not able to get any proper links.
    can any body help me out where i can get the or proper links for sql/plsql interview questions?
    So that i can proceed and have a interview with him or her..
    The role of particular person would be Developer..
    Thanks,
    Anoo.

    Hi Anoo,
    You haven't mentioned what level of expertise you are looking for in the developer. You may find some common questions at the links below.
    http://matrixl.net/oradev/intrv01.htm
    http://www.coolinterview.com/type.asp?iType=63
    http://www.orafaq.com/wiki/PL/SQL_FAQ
    I would suggest to test the candidate based on your requirements, rather than on the answers available for the questions.
    Edited by: Preta on Mar 26, 2010 3:00 PM Corrected typo

  • SQL & PLSQL Practice

    Hi All,
    I know the SQL & PLSQL and now i want to do the practice for the same but for that i need to install it first. From where i can install it free so that i can do the practice.
    I gone through the Download tab there i found window 32/64 etc. What is that as i know, Window is OS but what is 32/ 64 bit?
    How can i check that in my PC/Laptop?
    Pls reply ASAP so that i can start my practice
    Thanks in advance

    <p>The 32/64 bit refers to the Windows version you are using. Windows has both 32 bit and 64 bit versions of its software. If you don't know what you have, you might want to go <b>here</b>.</p>
    Tom

  • Where get test paper for sql & plsql

    Dear,
    I would like to attempt test for sql & plsql for oracle 9i but before this where can i get question dumps.
    Thanks.

    Dumps are illegal .
    9i

  • Problem returning variables from dynamic SQL/PLSQL

    Hi, I have a problem I am trying to solve using a very short piece of dynamic SQL or PLSQL but I am having problems getting the variable values out of the dynamic block.
    I have 16 counters whose names are made up of three variable parts - 'scheme', 'contributory category' and 'employment category'
    The 'scheme' can be either 'no1', 'no2', 'off', 'cg' or 'amc'
    The 'contributory category' can be either 'cont' or 'noncont'
    The 'employment category' can be either 'ft' or 'pt'
    (There are only 16 because only 16 combinations are possible)
    For example the total counter name could be 'v_cg_noncont_ft_count'
    I have created a variable by concatenating the various elements called v_incr_count_name which holds the name of the counter I want to increment.
    I am running this whole thing within an anonymous PLSQL block so I cannot use global variables meaning that my variables are not visible within a dynamic PLSQL block.
    I believe this means that either I need to bind the variables within a PLSQL block or use a SELECT FROM INTO SQL block.
    I have tried a few solutions with no luck such as the following PLSQL:
    v_incr_count := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'BEGIN :a := :a + 1; END;';
    EXECUTE IMMEDIATE sql_stmt USING v_incr_count_name;
    Unfortunately I am getting the 'IN bind variable bound to an OUT position' error which I believe is because it is trying to return a value into v_incr_count_name which has been defined by default as an IN variable. The problem is that I need to store the returned value into the variable whose name is stored in v_incr_count_name.
    Another solution I tried is:
    v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'SELECT '||v_incr_count_name||' + 1 FROM DUAL';
    EXECUTE IMMEDIATE sql_stmt INTO v_return;
    This solution gives me an 'Invalid colum error'
    Any help would be greatly appreciated
    Cheers, Dan

    Repost:
    Problem with variables in dynamic SQL/PLSQL

  • New features of SQL & PLSQL

    Hi
    Could anyone please guide me to the oracle documentation where I can find the new features of SQL and PLSQL?
    Thanks

    What Oracle calls new features is not necessarily everything that is a new feature.
    Here are my personal lists:
    http://www.morganslibrary.org/reference/new_in_11gR1.html
    http://www.morganslibrary.org/reference/new_in_11gR2.html
    http://www.morganslibrary.org/reference/new_11_2_0_2.html
    http://www.morganslibrary.org/reference/new_11_2_0_3.html <-- still being built
    These lists include undocumented unsupported features as well as supported ones so review for a better understanding of the Oracle database but only implement those you find in the online Oracle docs and which are supported. You, the user, assume all risks for making bad choices.

Maybe you are looking for

  • Query Print Layout - Generated PDF Document Name?

    Hi All, Query Print Layouts associated to my user queries work great for printing...but does anyone know if there is a way to set a more appropriate document file name when attaching an edited PDF report to an email? It seems to always automatically

  • Trying to override the default af:tree expanded and collapsed icons

    Hi, I initially hijacked a thread from 2010 that was vaguely similar to what I need to ask, but a kind forum moderator split my post out to stand on its own merits. I am trying to override the default af:tree expanded and collapsed icons I am using t

  • Error Message when copying text between sequences

    I hadn't had this issue until updating to the most recent version of FCP. Basically, I am trying to copy text from one segment to another. The text has edge wipe transitions at their heads and tails. I get a message that says 'This edit cannot be don

  • Value Objects still  relevant in EJB 2.0?

    I came across the concept of using Value Objects to get better performance from EJBs as they reduce the number of remote calls to invoke to retrieve object property values. However, with the introduction of LocalHome and Local interfaces for EJB 2.0,

  • Incomplete Gift Certificate and no response from the Apple Store

    On Dec. 22nd I purchased a gift certificate through iTunes for my sister. She received an email telling her how to redeem the card, it came without a redemption code and instead of my name she got [?]. The message said: "You have received an iTunes G