HOW CAN I CRETE TABLE WITH STORED LIKE HER PROCEDURE?

CREATE OR REPLACE PROCEDURE CREATE_TABLE

(P_1 VARCHAR2, VARCHAR2, P_3 P_2) AS

V_TABLE VARCHAR2 (100);

BEGIN

IF P_1 = 'C' THEN V_TABLE: = ' CREATE TABLE AS SELECT P_2 * OF P_3';

ELSIF P_1 = A ' THEN V_TABLE: = 'DELETE TABLE P_2 ";

END IF;

IMMEDIATELY RUN V_TABLE;

END;

/

RUN

BEGIN

Create_Table ("C", "DEPT_EMPS", "EMPLOYEES");

END;

/

VIEW THE ERROR

So, here's what you're trying to do...

SQL > create or replace procedure create_table (create_or_delete varchar2
2, table_name varchar2
3, source_table_name varchar2
4                                           ) as
VARCHAR2 (32767) dyn_sql 5.
6 start
7 if upper (create_or_delete) = 'C' then
8 dyn_sql: = 'create table' | table_name |' in select * from '. source_table_name;
9 upper (create_or_delete) elsif = ' then
10 dyn_sql: = 'truncate table' | table_name;
11 end if;
12 immediately execute dyn_sql;
13 end;
14.

Created procedure.

And here is what one of the more fundamental reasons that you should not...

SQL > declare
2 cnt number;
3. start
CREATE_TABLE 4 (' this, 'dept_emps', 'emp');
5. select count (*)
6 in the NTC
7 of dept_emps;
8 dbms_output.put_line (' count on my new table: ' |) CNT);
9 end;
10.
of dept_emps;
*
ERROR on line 7:
ORA-06550: line 7, column 10:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 5, column 3:
PL/SQL: SQL statement ignored

You cannot use the table in the static SQL/DML instructions until it is created.  The code compiles even because the table does not exist.

The only way to use this table would be to write more dynamic SQL.  And you're just stupid!

If you write your code like this, you are creating an absolute mess.  You need to learn that this is NOT the right way to create tables or write code.

It is also likely to be victims of violence for the injection of SQL code.  If you are unsure what is SQL Injection, it is a major security vulnerability in your code that can allow people to steal data or remove data or otherwise damage to your database.

Tags: Database

Similar Questions

  • How can I open disc with .fpbf?  The disc has some pictures I would like to see.

    How can I open disc with .fpbf?  The disc has some pictures I would like to see.

    It is not a photo format, this is a backup image

    http://FILExt.com/file-extension/FPBF

    and that means CD.fpbf Untitled

  • How can I change the data stored with JDeveloper Java classes?

    Hello!
    First of all, I am experienced PL/SQL coder, but I'm quite beginner what comes to Java.
    JDeveloper is also a new tool for me and the reason why I am interested, it's the good Java Editor.
    With the good Java editor I can create classes and store them in the Oracle database and executing those inside PL/SQL code.

    I am currently faced with a minor problem, and I'm not able to find the answer to this:
    How can I change/edit/create stored with JDeveloper, Java classes to database (Toad for Oracle can do but it's not good editor Java)?

    I can navigate to Java classes with database browser, but I can't change those. Just view and drop it.

    [http://users.metropolia.fi/~jokkek/Oracle/jdeveloper.png]


    Thanks to all helpers!
    ARO
    Jokke Heikkila

    Published by: user10385021 on 2.6.2009 03:56

    JDeveloper is not a direct modification of the classes inside the database. Instead, you must change your java classes locally (including the management of versions, unit tests etc.) and then load them into the database. Load in the datab ase could be done using the Loadjava and the deployment profile stored procedure Java (file-> New-> General-> profiles of deployment-> Loadjava and Java Stored Procedures). I think it's even better let your build tool do the work. An example of task of Ant describing this is shown at http://davidmoten.blogspot.com/2007/11/oracle-loadjava-ant-task.html (I have not tried this, but have used a similar approach in a project)

    Trygve

  • How can I get assistance with my Apple Care Protection Plan when I am abroad

    How can I get assistance with my Apple Care Protection Plan when im abroad?

    I brought an iPhone 6Plus in Europe and now I am traveling

    I would like to know if Apple Care Protection Plan cover me in the United States and what I can do

    Hey there, Aleji!

    Based on your post, I understand you have a few questions about your AppleCare protection + plan, and where coverage is available.

    You can get more information on your cover in the next article.

    About your coverage options and support services

    Additional information about the warranty is also available on the link below. Simply select your device and the region.

    The hardware guarantee

    Have a great day!

  • How can I start firefox with new tab instead of the blank page?

    Today I've updated firefox to 13.0. I like the new 'new type '. I want to know how can I start firefox with new tab instead of the blank page?
    I don't want to change the home page to about: newtab.

    Sorry for my bad English.

    You can add about: newtab to the command line in the shortcut to the desktop Firefox to open this page on startup (target).

    • "C:\Program Files\Mozilla Firefox\firefox.exe"-new - tab on: newtab
  • How can I get my photos stored in Adobe Photoshop Album Starter Edition 3.2 out of this program, I am a frame of 76

    How can I get my photos stored in Adobe Photoshop Album Starter Edition 3.2 out of this program, I am a 76 year old lover

    Your photos must be stored on your disk. If I recall Starter is a database system, so just the thumbnail and its changes are stored in the database with a link to the original image.

    It was long, so I could be wrong. If I do, look in the file menu of options to save or export. First select the files, then choose this option.

    Sorry, I wish I could be more help but as I said, it has been a long time.

  • How can I import tables to a different schema in the relational model existing... to add these tables in the existing model? PLSS help

    How can I import tables from a different schema in the relational model... to add these tables in the existing relational/logic model? PLSS help

    Notes; I already have a schema ready relational/logic model... and I need to add more tables to this relational/logic model

    can I import the same way like I did before?

    But even if I do the same how can I add it in the template? as the logic model has been designed...

    Help, please...

    Thank you

    To view the diagram of logic model in Bachman notation, you right-click on a blank area of the diagram and select the rating > Bachman Notation.

    David

  • How can implement you not with Tim Capsule and AirPort their simulation on the iMac?

    Hello

    How can implement you not with Time Capsule and AirPort their simulation on the iMac?

    I don't know what you're asking.

    AirPort Extreme is a wireless router.

    A Time Capsule airport is an AirPort Extreme with a built-in hard drive for data storage.

    An iMac is a Mac computer.

    An iMac is not a wireless router, so he is unable to perform the functions of a wireless router.

  • How can I restart firefox with the same tabs and windows?

    How can I restart firefox with the same tabs and windows?

    It is not in the file menu or tools. I get nothing when searching for help. FF still knows how to do it, say to update extensions.

    I know that I can do by saving my session, coming out, reboot and restore the session but is there a single command to do this?

    Thank you. -David

    I have attached a screenshot showing how to select restore automatic session just above the setting of the Home Page where it says "When Firefox starts".

    With this set, you can restart Firefox manually out using the menu-

    • "3-bar" menu button > button "power".
    • (menu bar) File > Exit

    -and then restart Firefox.

    If you want a real reboot with a click of button, you can check something on the Add-ons site: https://addons.mozilla.org/firefox/

  • How can I make Android V35 behave like the V24?

    I use FF on Android, I've been holding until the update since 24 V for all newer versions will not auto play mp3 for download without interaction. I use this to play on Google voice email messages. How can I make 35 V behave like a 24 V?

    Thanks Roland, I guess all I can ask is that you can do occur in future releases and maybe make an adjustment if it is a problem for other users to access this feature.

    Thanks Bob

  • How can I sync lightning with the iphone calendar?

    How can I sync lightning with the iphone calendar? I saw online that I need to use a google calendar? I added google calendar as they described, but I have no idea where from here

    To synchronize with the iPhone (also known as iCalendar) schedule you must use a calendar based on a cloud. If you already have the lightning, install the addon Google provider and Setup Google Calendar. If you have already done so, go to settings on your iPhone. In the e-mail box, Contacts and calendars, add your Google account and turn on the calendar. This will synchronize your Google Calendar with the iPhone.

  • How can I reduce the amount stored?

    How can I reduce the amount stored?

    The amount is stored where? You must provide specific information about what it is you want to do.

    GB

  • 5.6.1 pages: How to create a table with more than 999 lines?

    5.6.1 pages: How to create a table with more than 999 lines?

    The table on Pages v5.6.1 line selector is limited 3-digit, as it is in Pages ' 09 v4.3. Either use LibreOffice Writer, who does not have any constraint line on processing tables 3-digit, or any application spreadsheet for top 3-digit row needs.

  • How can I send emails with outlook express from firefox

    How can I send emails with outlook express from firefox

    See change the program used to open e-mail links for how to configure Firefox to use Outlook Express.

  • How can I access Comcast with Apple Mail?

    How can I access Comcast with Apple Mail? I use OS X El Capitan (Version 10.11.3). The last update of the system made accessing Comcast inoperable, confirmed twice with the Apple Support. Is there a workaround yet?

    DMcCormick,

    Read: set up messaging 9 on Mac OS X (El Capitan) for the Comcast Email.

Maybe you are looking for