dynamic query for package does not work

Dear members,

I have problems with a package in the creation and analysis of a dynamic query in the WHERE clause. Here is an example of what I'm trying to do:

PROCEDURE test_status_proc)
wtd_cursor ON cur_type
date_1 IN date
date_2 IN DATE
status in VARCHAR2,
flag in VARCHAR2)

IS

status_sql VARCHAR2 (250): = NULL;
flag_sql Varchar2 (100): = NULL;

BEGIN


Status of the IF = 'A' THEN
lv_status_sql: = 'A ';
lv_flag_sql: = 'Y ';
END IF;
Status of the 'I' = IF THEN
lv_status_sql: = 'A ';
lv_flag_sql: = 'n';
END IF;

Status of the 'R' = IF THEN
lv_status_sql: = "R";
lv_flag_sql: ='* ';
END IF;

Status of the IF = n THEN
lv_status_sql: = 'n';
lv_flag_sql: ='* ';
END IF;

IF status_code = 'IRN' THEN
"lv_status_sql: = '('' N'','' R'');
lv_status_sql: = lv_status_sql | ' OR (s.status = s.flag = "A" AND "N")';
lv_usecalc_sql: ='* ';
END IF;

Status of the = IF'* ' THEN
lv_status_sql: ='* ';
lv_flag_sql: ='* ';
END IF;

OPEN FOR Test_cursor

SELECT * from test_status s
WHERE
s.Daytime BETWEEN date_1 AND date_2
S.status AND decode (lv_status_sql,'* ', s.status, lv_status_sql)
S.flag AND decode (lv_flag_sql,'* ', s.flag, lv_flag_sql);

The problem I have is especially with the condition 'IRN '. The suite WHERE the part of the clause looks like the following in the lv_status_sql, but the query returns all the values:

-(', 'R') OR (s.status = 'A' AND s.flag =' only)

Any help would be much appreciated.

Kind regards

dreporter wrote:

Thanks for your reply and I completely understand your frustration. The problem is sometimes it is very difficult to describe all of the problem due to several reasons. Please take a look at my last post to see if that makes sense.

If you really need SQL dynamic - true dynamic SQL which includes dealing with dynamic number of bind variables - then DBMS_SQL are an excellent interface to use.

You can generate the dynamic SQL statement based on the question of whether the filter criteria is null (do not use) or not null (use as a predicate). For example

if someParam10 is not null then
  // someParam10 needs to be used as a filter predicate
  dynamicSQL := dynamicSQL || ' and some_col_10 = :someParam10 ';
end if;

This statement can then be analyzed using the DBMS_SQL interface. The binding of values uses the same logic that was used to create predicates. For example

if someParam10 is not null then
  // someParam10 is used and needs to be bound
  DBMS_SQL.Bind( myCursor, 'someParam10', someParam10 );
end if;

So, with this approach simplistic, you can easily create a dynamic SQL with variable predicates, dynamically bind these and run the slider.

Bind variables are used in the dynamic SQL statements, as there are very few threats of SQL injection. And the basic principles observed for shareable SQL creation - the same set of parameters not null to filter, will result in the same SQL statement, which allows the cursor within the Pool shared for this SQL statement to be reused.

So, technically, dynamic SQL is not a major problem (if used correctly). The major problem is that if really necessary to address the requirements of the business at hand.

The problem I have with many comments here want to use dynamic SQL statements, is that it is used as one would use a file i/o interface.

For file IO you want standard Open(), Read(), Write() and Close() calls. And you, the appellant, simply pass the name of the file and the data to write or to receive the data read.

Similarly, these posters want to use SQL to open a table and read and write the data column - and do it by calling simply (and dynamically) by specifying the name of the table and column. Approaches to dynamic SQL based on one such concept is wrong. And shows that much of the ignorance of what a RDBMS is and how to use an RDBMS.

Tags: Database

Similar Questions

  • Adding images dynamically - tutorial for examples does not work

    I am using the SDK Gold and work through the tutorials. I want to add dynamically images of C++. The tutorial that I use is here:

    https://developer.BlackBerry.com/cascades/documentation/dev/integrating_cpp_qml/ (under the heading "Injecting C++ objects in QML").

    I have copy and paste the main.cpp, TestApp.hpp and TestApp.cpp into a new project. He compiled and ran on my device, but when I click on the button 'Add the container' seg application vulnerabilities and ends.

    I understand that this is caused by a NULL pointer, so I added:

    This-> mRootContainer = new bb::cascades::Container();

    for the Builder. Now it does not segfault when I press the button 'Add the container', but again, it does not actually add the container (it adds nothing visible).

    How can I use the concepts described in this tutorial to add an image at run time?

    I managed to understand. The example provided in the tutorial defnitely badly, which is very annoying and frustrating for those of us learning to code for BB10. Not only that, but the "barrier to entry" is hard enough, and if Blackberry to their ecosystem to flourish, documentation and tutorials must be accurate and easy to follow.

    The constructor should be something like:

    TestApp::TestApp(bb::cascades::Application *app) : QObject(app)
    {
      QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
      qml->setContextProperty("injection", this);
      Page *appPage = qml->createRootObject();
      mRootContainer = appPage->findChild("rootContainer");
      app->setScene(appPage);
    }
    
  • Serial number for lightroom does not work

    my serial number for lightroom does not work

    Maritah has made education institution give you an indication of the place where you need to download the installation files from?

    You can download Lightroom 5.6 from the following locations:

    The updates contain the complete installation files and should accept your serial number.

  • Xbox 360 controller/joystick for PC does not work properly in Battlefield bad company 2

    I recently black battlefield 2 and bad company xbox 360 wired to use with the game controller. Once both parties had been settled, I went to the settings in the games options and tried to attribute the actions with the buttons of the gamepad /, but here the rub. Not all the buttons of the gamepad a response, as the right analog stick and the arrow keys. Some of the buttons that do not give an answer have different names /-are mixed with other keys, as the right trigger. When I try to assign the right trigger for fireing, she appears as axe1 x and does not work in the game.

    Some of the buttons that work are the x button and the stick analog left and right and left bumber.

    I did not so much to try to solve the problem, as I have really no idea what to do. I thought to uninstall and reinstall the game, but that would help? Also perhaps reinstall the controller, or by downloading a driver for him on internett. It was installed using the disk resulting.

    The problem, in the game or in the controller? Perhaps driver? Where would I go to file a complaint, get my money back?

    Any help would be much appreciated!

    -Mathiasshow

    Hello

    ·        This problem happens only when playing Battlefield Bad Company 2 and other games as well?

    I suggest you run another game on your XBOX360 and check to see if the same problem happens.

    If the problem occurs with all the games then I suggest you to contact the hardware manufacturer.

    If the problem does not occur with a different game then I suggest you uninstall and reinstall the game and see if the problem is resolved.

    Please visit the link provided below for more information on how to uninstall a program in Windows 7:

    http://Windows.Microsoft.com/en-us/Windows7/uninstall-or-change-a-program

    You can also post your question on the link below:

    http://www.xbox360forum.com/Xbox-Forum/Forum.php

    Thank you, and in what concerns:
    Naman R - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Volume F4 - F5 key on the keyboard for mac does not work on the microsoft side

    Volume F4 - F5 on the keyboard for mac key does not work... on the side of microsoft may not decrease or increase volume

    Hello

    ·         What do you mean by Microsoft Side?

    ·         Have you tried to update the latest audio drivers for the computer?

    ·         Were there any changes made on the computer before the show?

    Also I suggest you to contact the Apple support:

    http://www.Apple.com/support/Mac/

    See also: http://windows.microsoft.com/en-US/windows/help/no-sound-in-windows

  • application of foxpro for Dos does not work under Windows 7 Home Premium 64-bit

    Dear Expert help me!

    My foxpro for Dos application does not work under Windows 7 Home Premium 64-bit. Please advice me! How can I do for running under Windows 7 64-bit

    waiting for early response
    Thank you and regards

    SAIF Ali Sabri
    Faisalabad, Pakistan
    E-mail address is removed from the privacy *.
    + 923007960782

    16-bit applications are not taken charge/does not not on 64-bit Windows

  • Flash player for mac does not work?

    I tried to update flash player several times for games on pogo, that looks like it works on my end, but when I go to pogo to play games, it is said that I have to update? I tried to fix it with the help page his does not work?

    Apple has changed the default behavior of plugin Safari 10 (disabled by default).  Please make sure that Flash Player is enabled in the browser, Activate Adobe Flash Player for Safari

  • Applications for iOS does not work after update from cli 6.3.0

    After an update on August 3, when the Service of Build upgrade cli 6.3.0 my apps did not work for iOS, I have an iPhone 4 running iOS 7.1.2 and an iPad running iOS 9.3.3. After the build service update, no matter if I specify a lower version of cli, on the iPhone he asked a more recent software when I try to install from iTunes, but the iPhone and iTunes running on the latest version. On the iPad it installs, but the application icon does not appear on the iPad, so I can't access the application.

    Everyone knows a similar problem? I tried to look for documents but did not find any significant syntax change that could cause the problem. I even did a restore on my code (I had an old version of the compiled application and it worked, then I did a restore to this date on my code) and it does not work yet.

    ryanskihead not really, we test with 2 models, an iPad 2 running iOS 9.3.3 and an iPhone 4 iOS running 7.1.2 in both cases, the application does not, but the behavior is different:

    -On the iPad it installs successfully on iTunes, but the icon does not appear on the iPad

    -On the iPhone it says that it can not be installed because it requires a newer version of the iOS, but the iPhone is running the latest available version of iOS.

    If I specify a deployment target, say iOS 7 for example, it doesn't do anything on the iPhone. This and a similar thread I've seen on the target community deployment cli 6 ignorant, I would say that there is a bug with phonegap cli 6 + versions used on the Build Server.

    The problem now solved in time by doing a restore to phonegap cli 5.2.0, TI began works fine after that, so I don't know if there is a bug on higher versions of cli phonegap or there is a syntax change not yet published on config.xml

  • Adobe dynamic link cc 2014 does not work!

    Hello everyone

    Usually, I use Adobe Dynamic Link between Premiere Pro and After Effect, but in this version, the update does not work.

    Anyone know the difficulty of this kind of problem?

    OK I found the solution!

    The problem is that I used to import the AE composition by right-clicking on the project tree, and then file import AE and I chose the composition.

    It's been my standard until the cs6.

    Do the same thing now, I have to click file > Adobe Dynamic Link > Import AE composition!

    I don't know because the old way does not work, but I'm happy too

    Thank you guys!

  • Locales for Spanish does not work in flex plugin

    I use the parameter following the compiler flex with Flex builder 3 and it works very well in local Spanish support.

    -local = en_US, es_US

    But the same setting does not work in eclipse installed with plugin flex4 running on flex SDK 3.5. I'm unable to build the project with this setting. If I remove es) WE then, it works very well.

    Here's my setting of the compiler

    -local = en_US, es_US-allow-source-path-to overlap = true - source-path = locale / {local}

    I've never used Eclipse for flex development, but yes it sounds like you are configuring the sdk ok.

    It fails to build, but gives no error, very weird

  • The add-on Adblock Plus for Firefox does not work on a Livestream page.

    I just install it because I get a video ad on a web page of Livestream. It does not work.
    Disable all is checked.

    Maybe you can ask the team of Adblock, you're very likely to get the best help there.

  • Automatic download of cal Open Office for excel does not work

    I have nominated files in excel to open in OpenOffice cal under Tools, Options, applications, but whenever I want to open an excel file I always get the message that says 'Browse' and go to the open office programs, etc. Why does not work?

    Hello

    Please try to delete the in mimeTypes.rdf the Firefox profile folder right out of Firefox. You can also open the profile via Firefox help (Alt + H) folder > troubleshooting information > Open the containing folderand the release of Firefox. The file will be recreated the next time you start Firefox.

    Files & Firefox profile folder

  • Scanning drive for errors does not work - PC freezes

    A scan of disc scheduled to start at the start, the opportunity to cancel the account up to 1 second and the computer freezes.  The scan does not work and I have to kill power PC (and then cancel analysis so it doesn't freeze again).

    Then I tried the following experiment.  I have connected to my administrator account and demand there from there.  Then it worked fine.  So should I assume that this must always be done from the administrator account?  If so, Win7 should not allow you to schedule a chkdsk from a nonadministrator account.  Comments?

    Thank you.

    You can schedule a chkdsk only the administrator account. If you plan it no admin is a standard account, you must run the command prompt mode elevation and elevation itself to give the administrator previllege. So what you want to say about it. Are you talking about the built in Administrator account by any chance? If so, then the user account where you have planned is corrupted try to create a new and check.

  • CC for flash does not work in Windows RTM 8.1

    CC Flash does not work in Windows RTM 8.1, by clicking on the icon of the program to inicialo it starts or comes to show the error code it does not start, what is the problem? It worked fine on Windows 8 and Windows RTM 8.1 now it won't start? I tried to run in compatibility with Windows 8 mode still doesn't work!

    It is a known problem with CC Pro Flash - generation of GM.

    This accident has been fixed in the update that came out recently. Please update to 13.0.1.808 version and it should fix this.

    Please answer if it persists after the update.

    -Reynaud

  • maxColumnWidth for ColumnSeries does not work?

    It looks like a simple attribute but I can't get maxColumnWidth to change the width of my series of column in a ColumnChart.

    I put it like that...

    < mx:ColumnChart id = "Graphic".
    Width = "100%" height = "100%".
    dataProvider = "{fakeData}".
    maxColumnWidth = "15".
    showDataTips = "true" >

    And also tried like this in the element of the series...

    < mx:series >
    < mx:ColumnSeries
    xField = "scenario".
    displayName = 'energy '.
    yField = 'energy '.
    maxColumnWidth = "15".
    / >
    < / mx:series >


    It seems so simple, but it does not work... the bar extends even beyond this width that the graph occupies space in its container.

    Any suggestions are greatly appreciated!

    -Daniel

    Hello

    Column width is calculated as minimum of the maxColumnWidth and columnWidthRatio.

    columnwidthRatio is 0 to 1. Bydefaultit is 0.65;

    So if you want that your column width must be dependent only maxColumnWidth then do columnWidthRatio = "1" and change your maxColumnWidth

    According to your requirement.

    Hope this helps

    Rush me

Maybe you are looking for