Trouble with variables

Can someone help me figure out how I can do the following?

I have a query stored in the "Queries", column "Code". For example: "" Select * from sales; ""

I can do this to return the stored query results:
declare
 v_sql varchar2(1000);
begin
select code into v_sql from queries where id=13;
return v_sql;
end;
It works well, but I can't get a variable works correctly. That is to say. I want to use a date for the WHERE clause.

Something like:
Query:
Select * from sales where sale_date = :v_date;

Code:
declare
 v_sql varchar2(1000);
 v_date date;
begin
v_date := to_date('01/07/2012', 'DD/MM/YYYY');
select code into v_sql from queries where id=13;
return v_sql;
end;
Obviously, this doesn't work. Is this possible to do?

Oracle 11g, Apex 4.0.1

Thank you very much!!
~ P

Edited by: pearlyred 24/01/2013 16:56 Versions added

An essential difference is when you use the Apex.

With a normal client, written in Java, .net, C/C++ and so on, that you would typically use the PL/SQL to apply the logic required, creates the SQL cursor and returns the handle for this SQL cursor in the memory of the server as a reference cursor (pointer) to the client.

There are several ways to apply the PL/SQL code that creates the ref cursor. This approach uses static SQL like on {message identifier: = 10390039}. Another approach uses dynamic SQL, as shown in {message identifier: = 10805597}.

The complexity of this approach is mandatory. You can dynamically create a SQL with a variable number of bind variables. However, the ref cursor requires coding with a fixed set of bind variables. A ref cursor doesn't support dynamic linking (where the number of bind variables is only known at run time). There are alternatives - such as DBMS_SQL (which supports the dynamic SQL statements, dynamic linking and dynamic recovery) and then by converting the variable of DBMS_SQL cursor in a Ref mouse pointer that can be passed to the client.

Well, then, how is this different from the Apex?

Apex of PL/SQL. He cannot use ref Cursor that you create with your PL/SQL code and pass it to render in a report. REF CURSOR is designed to be used by external clients in this way. No PL/SQL.

Apex uses DBMS_SQL for this - it's the equivalent of ref cursor in PL/SQL.

So if you want to pass a SQL for Apex, you do not like a ref cursor You do it rather like a SQL string - where the string contains the SQL statement Dynamics (and bind variable names) to use. Apex receives this and he uses DBMS_SQL parse, link and run like a slider. (in fact, it uses the system version of DBMS_SQL that allows him to run the cursor as the owner of this application of the Apex).

With Apex, there
(a) returns a SQL statement
(b) ensure that the SQL includes the names of variables relevant to the link

Simple example. A function that can be called from any page of the Apex to return the SQL code required to make a report of the Ministry employee.

create or replace function EmployeesInDept( deptVar varchar2 ) is
begin
  return(
   'select * from emp where deptno = :'||deptVar
  );
end;

This seems a little weird. A normal customer would have passed the dept value. Apex needs to pass the variable there (page element) that contains the value.

This function will be used as follows on page 123 app Apex:

--// page item P123_DEPT contains deptid
EmployeesInDept( deptVar => 'P123_DEPT' );

And on page 234:

--// page item P234_DEPT contains deptid
EmployeesInDept( deptVar => 'P234_DEPT' );

The alternative is more complex - create a PL/SQL procedure that receives the value of the variable actual (as opposed to the variable name). Create the cursor. Through the DBMS_SQL. Display the cursor as an html, via PTHreport. But it goes much of the rendering features of Apex report in this custom procedure - and results in a huge loss in the reports feature.

Comment - dynamic SQL approach as described above is practically an exception in the Apex. It's often much easier to create several regions report (each report supporting a set of combinations of filter criteria) and then apply the conditional rendering rules to determine which report to render to the specified filter criteria combination.

Tags: Database

Similar Questions

  • trouble with variable refresh

    Hi all fans of ODI,

    I have a project variable, text, value data type default 'something' that contains a query (to refresh button) valid (that get 1 deposit the registration form).
    After press the button refresh in the story I get the error message:

    java.lang.Exception: error: no value to assign to this variable for DefDate:null

    Someone has an idea, what does that mean?
    Thaks a lot, have a good day
    Gejza

    Hi Gejza,

    Yes according to the Bos says, you need to get the value by default when you "use" this variable in packages/procedures. During the standalone test ODI will be "run" this query in the Backend and retrieve the result.

    It seems odd, even if you have 1 row in the underlying table, and still you get this error. U can do a safe/cross check if recording still exist in the underlying table as such and the logic diagram points to the correct schema?

    Thank you
    Guru

  • Shock wave of trouble with the structure of multidimensional data list

    I have the following fairly simple code. Shockwave throws an error executing non-descript and shut unexpectedly on glTireData [symbol (myBrandSymbol)] .count () and I'm sure she would have trouble with the following line, if he ever had of him. The code works correctly in a standard projector as well as in the authoring environment. I had a look on the variables using the debugger and everything is as it should be, the following short example (the complete data structure glTireData is much larger, but it is an example of the format):

    myBrand = "Firestone".
    myBrandSymbol = "Firestone".
    glTireData = [#Firestone [#FD690PLUS [#tireBrand: 'Firestone', #tireDesign: 'FD690 PLUS', #feFactor:169.35, etc...]]]

    My bad... the initial project used PrintOMatic and I had already removed the functions of POM (we knew that it was not sure Shockwave) except that I neglected the xtra registration in Manager startMovie... just below the registration code has the code to load my tire reinscriptible... apparently the registration code has been stop startMovie Manager prior to the loading of the data structure by simply removing the code reg cured the problem.

  • Im having trouble with my iphone 16 GB ios 9.3.3 5s (G 13, 34) receive error code 22 tries to connect to the server, and nowhere suggestions?

    Im having trouble with my iphone 16 GB ios 9.3.3 5s (G 13, 34) receive error code 22 tries to connect to the server, and nowhere suggestions? I have tried almost everything turn power switch wifi in the middle and doing it to try to track down the problem in the Device Manager and im completely disgusted

    Have you tried turning off and back on again?

  • Trouble with Touch ID when you want to put one, it says that it does not recognize the finger

    Trouble with my ID touch, when I want to configure it says it cannot recognize my finger

    Apple Watch is not TouchID. Let us know what device you are using so that we can this post moved.

  • Trouble with the Satellite Pro L300 Ethernet controller driver

    Hello

    I bought a Toshiba Satellite Pro L300 Model (PSLB9A - 064022)

    Put XP Pro/SP2-Having trouble with the Ethernet controller driver.

    I downloaded the driver from the appropriate list (Toshiba support) only network via another PC memory = car lappy

    Realtek_LAN_56861032008_XP.exe

    install
    installed in a folder named c:\ "DELL"-(WHICH can not be move?)
    drivers R86360
    OF this dossier, I do the "setup."

    broad com 440 x - installs as everything is good,
    made just TWO yellow controllers.in etha...
    \
    but isn't she suppose to be integrated realtek 10/100 Mbit / s Ethernet TX.

    Can someone please point me in the right direction.

    Thanks in advance...

    Steve

    Hello

    It seems that the Australian model, try this one:

    http://file.MyToshiba.com.au/file/Download/Resource/File/13002/Realtek_LAN_56861032008_XP.exe

  • recorder with variable unit

    Hallo!

    I tried to use the recorder with variable units. It does not it? Can I change the units of the recorder of the version of the runtime somehow?

    Thanks for your advice.

    Hilby

    Hello again!

    I found the solution:

    Even when it is not possible to use a variable in the context menu, it is possible to put a global string in the recorder manually. I put "${Unit_Ch1}" on the ground for the unit, and it worked.

    Have a good day everyone.

  • Just set up a Win 2 K server 8 and trouble with FTP.

    FTP on windows 2008 server
     
    Just set up a Win 2K 8 Server and have trouble with FTP. FTP and IIS roles are installed and port 21 is open on the firewall but still can't connect. Any suggestion would be appreciated. Thank you

    Hello Spacekowboy

    If the suggestions of the Ing. Ladislav Cermak do not work then repost it please your question in the Windows Server forums from the link below. Thank you.

    http://social.technet.Microsoft.com/forums/en/winservergen/threads

  • Having a lot of trouble with updates.

    Having a lot of trouble with updates. Windows updates do not settle with error code 0 x 643. Fix from MS Computer Center said as he repaired software update. This does not resolve the issue. Fix MS datacenter failed with code 16977922-2147024894. Troubleshooting MS Wizard had had to close with an unexpected error code 0 x 80040154.  Norton updates fails with an error unexpected 0x000003E8. Update of Skype have also failed.

    Hello

    I suggest you to follow these steps and check if that helps:

    Method 1:
    If you have installed a security software on the computer, then I suggest you try to disable temporary and check to see if the same problem happens. Make sure that you enable security software back once the diagnosis is made to prevent the computer from virus attacks.

    Method 2:
    Try to perform the clean boot, and then check if it helps:
    http://support.Microsoft.com/kb/310353

    NOTE: When you are finished troubleshooting, make sure that you reset the computer in start mode normal such as suggested in step 7 of the above article.

  • Anyone who has other trouble with redcross haqve anti-virus software?

    original title: redcross anti virus

    Anyone who has other trouble with redcross haqve anti-virus software?

    Hello

    Red Cross Antivirus is a fake antivirus, a scam to force you to pay for it while he has no advantage at all.

    Red Cross Antivirus remove (uninstall Guide)<-- read="" this="">
    http://www.bleepingcomputer.com/virus-removal/remove-red-cross-antivirus

    It can be made repeatedly in Mode safe - F8 tap that you start, however you must also run them
    the Windows when you can.

    Download malwarebytes and scan with it, run MRT and add Prevx to be sure that he is gone. (If Rootkits run UnHackMe)

    Download - SAVE - go to where you put it-right on - click RUN AS ADMIN

    Malwarebytes - free
    http://www.Malwarebytes.org/

    Run the malware removal tool from Microsoft

    Start - type in the search box-> find MRT top - right on - click RUN AS ADMIN.

    You should get this tool and its updates via Windows updates - if necessary, you can download it here.

    Download - SAVE - go to where you put it-right on - click RUN AS ADMIN
    (Then run MRT as shown above.)

    Microsoft Malicious - 32-bit removal tool
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=AD724AE0-E72D-4F54-9AB3-75B8EB148356&displaylang=en

    Microsoft Malicious removal tool - 64 bit
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=585D2BDE-367F-495e-94E7-6349F4EFFC74&displaylang=en

    also install Prevx to be sure that it is all gone.

    Download - SAVE - go to where you put it-right on - click RUN AS ADMIN

    Prevx - Home - free - small, fast, exceptional CLOUD protection, working with other security programs. It comes
    a scan only, VERY EFFICIENT, if it finds something to come back here or use Google to see how to remove.
    http://www.prevx.com/   <-->
    http://info.prevx.com/downloadcsi.asp  <-->

    Choice of PCmag editor - Prevx-
    http://www.PCMag.com/Article2/0, 2817,2346862,00.asp

    Try the demo version of Hitman Pro:

    Hitman Pro is a second scanner reviews, designed to save your computer from malicious software (viruses, Trojans,
    Rootkits, etc.) that has infected your computer despite all the security measures that you have taken (such as
    the anti-virus software, firewall, etc.).
    http://www.SurfRight.nl/en/hitmanpro

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

    If necessary here are some free online scanners to help the

    http://www.eset.com/onlinescan/

    New Vista and Windows 7 version
    http://OneCare.live.com/site/en-us/Center/whatsnew.htm

    Original version
    http://OneCare.live.com/site/en-us/default.htm

    http://www.Kaspersky.com/virusscanner

    Other tests free online
    http://www.Google.com/search?hl=en&source=HP&q=antivirus+free+online+scan&AQ=f&OQ=&AQI=G1

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

    Also do to the General corruption of cleaning and repair/replace damaged/missing system files.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Run checkdisk - schedule it to run at the next startup, then apply OK then restart your way.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

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

    If we find Rootkits use this thread and other suggestions. (Run UnHackMe)

    http://social.answers.Microsoft.com/forums/en-us/InternetExplorer/thread/a8f665f0-C793-441A-a5b9-54b7e1e7a5a4/

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • Trouble with conversion email from POP to IMAP Comcast: Code: 800ccc0f

    Original title: POP IMAP conversion

    Trouble with conversion email from POP to IMAP Comcast:

    Code: 800ccc0f
    Your server suddenly put an end to the connection. Your IMAP command could not be sent to the server, due to non-network errors.

    I'm on Windows 7 Home edition, Service Pack 1.

    Using e-mail with Comcast Email Client programs
    http://customer.Comcast.com/help-and-support/Internet/email-client-programs-with-Xfinity-email/

    Instructions for:

    Outlook Express
    Outlook 2003
    Outlook 2007
    Outlook 2010
    Windows Mail or Windows Live Mail
    Windows 8
    Mozilla Thunderbird
    Mail for Mac
    Eudora

  • I had trouble with my windows 7 Home premium, I downloaded again and ended up with 2 windows 7 hard disk, how can I delete one?

    I had trouble with my windows 7 Home premium, so I downloaded it again, now when I connect it has windows7 and windows Home premium, but the family version premium won't load, how to remove this version of my hard drive?

    Click Start, type: msconfig

    Press enter on your keyboard

    Go to the Startup tab

    Select the entry you want to delete

    Click on delete

    Then set the time to '0'

    Then click on apply and OK

    Restart if prompted.

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

    If the problem persists, try the following

    Click Start, right click on computer

    Click on properties

    Under control panel home

    Click on "advanced system settings".

    Go to the Advanced tab

    Under Startup and recovery, click settings

    In the default operating system list, select Windows 7

    Uncheck the "time to display list of operating systems".

    Click OK

    Then apply and OK

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

    If it still does not respond, try the following:

    EasyBCD by NeoSmart Technologies would be your answer, it provides a graphical front-end to the BCDEdit Command line that makes it easy for you to set the boot settings and change the entries start on the new Windows Boot Manager.

    http://NeoSmart.NET/DL.php?id=1

  • trouble with userinit.exe is an error like (0 x 0000000005) and I don't see anything on the screen, it's all black what should I do?

    IM have trouble with userinit.exe, there a like (0 x 0000000005) of the error, and I don't see anything in the screen is all black, what I have to do?

    I would also like to run a file system check to verify and repair the operating system files

    Run a file system check to check and repair your system files.

    To do what type cmd in start search box, and then right-click to run as administrator, then
    SFC/SCANNOW

    It may need be performed up to three times before success
    Let us know the results of the report at the end

    Read here for more information
    http://support.Microsoft.com/kb/929833

  • Problem with variables not excluding search terms not

    People,

    I'm having a problem with variables, when used in topic titles.

    We produce two distinct versions of a webhelp. The text is almost exactly the same, but the product has a different name in each version. In one version, he is called FLOW; in another, it is called Service generator. We use the user-defined variables to control which name is used to identify the product, when we generate the webhelp.

    So, I have (for example), a subject that begins with the heading:

    Construction of a FLOW script

    where the text occupied by 'FLOW' is provided by a variable with two values - FLOW and Service constructor.

    So when I generate the generator using the web Service version, I put Robohelp using the Service Builder variable defined, and all contained text and the table of positions generate fine; FLOW is nowhere to be seen.

    But when I type "FLOW" in the search box, the system identifies each of the three subjects that are built as in the example above, with a topic title that contains the variable used to set the name of the product. In addition, it displays in the search results using STREAM in the title of the topic, not Service Builder (but when I open the topic, the text in the header is rendered correctly).

    In addition, the system uses the "FLOW" and not "Service Builder" in the headings found by the search, regardless of what research the term is used.

    Everyone comes through this? Nobody knows how to solve this problem, please?

    Thanks in advance,

    NA.

    What version of RoboHelp do you use?

    I use the 2015 Release version. It used to be version 11.

    In the Release version of 2015, my topic Properties dialog box looks like this:

    I think that version 11 may have introduced the possibility of having a variable in the title of the topic. If your version is older and does not seem to offer a way through the dialogue box to deal with this, I was wondering if you could fudge by manipulating the code manually. For example, I see that when I use a variable in a topic title, I end up with this:

    So I was wondering if you could add just in the bit that reads:

    < InsertVariableNameHere >

    Of course, you want to replace the text InsertVariableNameHere with the actual name of your variable.

    It can fail miserably because the process of generation of RoboHelp doesn't know how to cope. But in fact, it might work! You won't know until you try.

    And even if it fails, I may be able to offer another approach that you will overcome the problem.

    See you soon... Rick

  • Hello, I recently bought a new iMac and I am wanting to install Lightroom for her, but I'm having some trouble with the key to series is not recognized. There is no disk drive on the new Mac, so I can't just pop the disc in. Is there anyway I

    Hello, I recently bought a new iMac and I am wanting to install Lightroom for her, but I'm having some trouble with the key to series is not recognized. There is no disk drive on the new iMac, so I can't blow my disc. Is there a way I can download it simply by using the key to series on my package? I tried the section "Redeem Code", but said air key is not valid. Thank you

    Download & install instructions https://forums.adobe.com/thread/2003339 can help

    -includes a way to go to a page to download the Adobe programs if you do not have a disk or drive

    -Cloud desktop http://helpx.adobe.com/creative-cloud/help/creative-cloud-desktop.html

    -Cloud Getting Started https://helpx.adobe.com/creative-cloud.html

    -you will need to enter your original serial number during the installation for non-Cloud programs

    - or kglad links in response to #1 here can help https://forums.adobe.com/thread/2081216

    Also go to https://forums.adobe.com/community/creative_cloud/creative_cloud_faq

Maybe you are looking for