Using the SQL with CFQUERY statement variable

I generate a SQL statement based on user input. I use loops, etc. to create the string of the current statement.

Once the SQL string is created I can display it on the screen and it seems fine.

If I copy the text that appears on the screen and paste it into a CFQUERY, it works very well.

BUT if I try to the variable output directly in the CFQUERY tags set string - it fails... what gives?

Here is the text of the string I am generating in a variable called #insertString #.

INSERT INTO atblProduct (PRODUCTTITLE, RELATEDPRODUCTS, PARTCODENAME, DISPLAY, PRODFAMILYID, DETAILEDDESCRIPTION, overview, APPLICATION type, SPECIALTAB) VALUES (' product ', '1,2,3', ' Code Name', 1, 1, 'Detailed Description', 'Preview', 1, 1)

in the code below, you will see how I try to run this sql using the variable in a CFQUERY tag. Do I need to use a CF function to ensure it is passed verbatim to the SQL engine?

< CFQUERY datasource = "mydb" >
#insertString #.
< / CFQUERY >

Try the function PreserveSingleQuotes.

Tags: ColdFusion

Similar Questions

  • Using the procedure with multiple output variables in a query

    Hello

    We have a process that takes time, which returns 4 variables as out parameters:
    procedure calc_values(id in number, val1 out number, val2 out number, val3 out number, val4 out number) is
    The id uniquely identifies a product in our database.

    I would use it in a query (or view), in the form
    select s.id, val1, val2, val3, val4 from something s, product_table p
    where s.id = p.id
    I tried the following approach, but I'm kinda stuck

    define the type
    define an array of this type
    write a wrapper function that calls this procedure and returns the results as a table
    * the PivotTable in columns
    * join this with the product table

    It's like I'm on the wrong track, I'm struggling to retrieve the id of the product table in the wrapper function.

    Is there a better approach for this? I'm on oracle 10g

    Thank you!

    Rob

    Below is my interpretation of what you were asked to do. I don't really know what you want to do or what you need to do.

    CREATE TYPE prod_vals_def
    AS OBJECT
     (VAL1      NUMBER,
      VAL2      NUMBER,
      VAL3      NUMBER,
      VAL4      NUMBER
    );
    
    create or replace
    TYPE   prod_vals_tab
    AS TABLE OF prod_vals_def;
    
    CREATE FUNCTION pvals (p_prod_id  NUMBER)
    RETURN prod_vals_tab PIPELINED
    AS
    
      TYPE         ref0 IS REF CURSOR;
      cur0         ref0;
      out_rec      prod_vals_def
                := prod_vals_def(NULL,NULL,NULL,NULL);
    
    BEGIN
      -- CASE replacing SELECT against table I'm not going to create
      CASE p_prod_id
        WHEN 1 THEN
          out_rec.val1 := 1;
          out_rec.val2 := 2;
          out_rec.val3 := 3;
          out_rec.val4 := 4;
        WHEN 2 THEN
          out_rec.val1 := 2;
          out_rec.val2 := 3;
          out_rec.val3 := 4;
          out_rec.val4 := 5;
        WHEN 3 THEN
          out_rec.val1 := 3;
          out_rec.val2 := 4;
          out_rec.val3 := 5;
          out_rec.val4 := 6;
        WHEN 4 THEN
          out_rec.val1 := 4;
          out_rec.val2 := 5;
          out_rec.val3 := 6;
          out_rec.val4 := 7;
        ELSE
          out_rec.val1 := 0;
          out_rec.val2 := 0;
          out_rec.val3 := 0;
          out_rec.val4 := 0;
      END CASE;
      PIPE ROW(out_rec);
    END pvals;
    
    WITH s_tab AS
      (SELECT 1 AS prod_id FROM dual
       UNION ALL
       SELECT 2 AS prod_id FROM dual
       UNION ALL
       SELECT 3 AS prod_id FROM dual
       UNION ALL
       SELECT 4 AS prod_id FROM dual
      )
    SELECT s.prod_id, p.val1, p.val2, p.val3, p.val4
    FROM   s_tab s,
           TABLE(pvals(s.prod_id)) p
    
    PROD_ID  VAL1     VAL2     VAL3     VAL4
    -------- -------- -------- -------- --------
    1        1        2        3        4
    2        2        3        4        5
    3        3        4        5        6
    4        4        5        6        7     
    
  • A question, when you use the sql Profiler features!

    Hi all.

    I have a question, when using feautre profile sql to oracle 10 g 2.

    As you know, 'DBMS_SQLTUNE. Procedure EXECUTE_TUNING_TASK' gives us
    a sql plan imploved automatically.

    However, in the event that the sql recommended plan of 'DBMS_SQLTUNE. EXECUTE_TUNING_TASK ".
    is not good enough to accept the plan sql generated, and instead, I have a better plan of sql.
    What should I do?

    Is it possible to force oracle to use my plan sql instead of plan recommended by oracle sql?
    The stored outline is not an option.

    Thanks in advance.
    Best regards.

    It seems that you really want to use the sql Profiler then?

    You can grant not only the instruction for this plan you want?

    If you want to manually create a profile, and then see the post below Kerry Osborne, essentially, you can remove the indicators needed to education to listen to v$ sql_plan and then their card in a profile for the original statement:
    http://kerryosborne.Oracle-guy.com/2010/07/SQLT-coe_xfr_sql_profilesql/

    See also the paper of Christian Antognini on profiles:
    http://Antognini.ch/papers/SQLProfiles_20060622.PDF

    11 g, base lines offer a much better facility to trace a plan from a single statement in a reference to another database.

  • creation of database using the SQL command * more

    Hello

    This isn't a matter of urgency.

    I learn the Oracle DBA. I have installed Oracle 9.2 in my windows system. And I'm trying to create a database using the SQL command.

    OracleVersion: 9.2
    Windows XP operating system

    CREATE DATABASE suri
    USER SYS identified by manager
    USER system identified by surendra
    LOGFILE GROUP 1 ('F:\Oracle\oradata\suri\redo01.log') SIZE 100M,
            GROUP 2 ('F:\Oracle\oradata\suri\redo02.log') SIZE 100M,
            GROUP 3 ('F:\Oracle\oradata\suri\redo03.log') SIZE 100M
       MAXLOGFILES 5
       MAXLOGMEMBERS 5
       MAXLOGHISTORY 1
       MAXDATAFILES 100
       MAXINSTANCES 1
       CHARACTER SET US7ASCII
       NATIONAL CHARACTER SET AL16UTF16
    DATAFILE 'F:\Oracle\oradata\suri\system01.dbf' size 200M EXTENT MANAGEMENT LOCAL
    UNDO tablespace undots datafile 'F:\Oracle\oradata\suri\undots01.dbf' size 200M
    DEFAULT TEMPORARY TABLESPACE tempts1 DATAFILE 'F:\Oracle\oradata\suri\temp01.dbf' SIZE 100M EXTENT MANAGEMENT LOCAL
    I get the error like below when executing the CREATE DATABASE command.

    ERROR at line 16:
    ORA-25139: invalid option for CREATE TEMPORARY TABLESPACE
    I have validated the syntax but not able to find where is the error.

    Please let me know if you need more details.

    Thanks in advance for your help.


    Kind regards
    Suri

    OracleVersion: 9.2

    Why a so old version (and desupported)? In any case...

    TEMPORARY TABLESPACE tempts1 DATAFILE 'F:\Oracle\oradata\suri\temp01.dbf' SIZE 100 M EXTENT MANAGEMENT LOCAL default

    .. try change DATAFILE with TEMPFILE.

  • How to make a bootable USB using the disc with El Capitan utilities?

    Anyone know how to make a bootable USB key using the disc with El Capitan utilities?

    Try this its worked perfectly.

    http://www.Macworld.com/article/2981585/operating-systems/how-to-make-a-bootable - os-x-10-11-el-capitan-installer-drive.h...

  • Rotation of the photos in iPhoto I could simply use the trackpad with 2 fingers turning motion.  In pictures, it seems that I have to use the Edit menu, etc etc?

    In iPhoto, I could simply use the trackpad with 2 fingers rotating motion to change photos quickly to stand.  In the Photos but it seems I have to use the Edit menu, etc. etc.?

    command + r or command + option + r, depending on the direction you want.

    Also, right-click on the image to the same command, hold the option for the choice

  • 4 is not compatible with the protection of the identity of simple past on my HP using the player with the tips of the fingers. How can I make it work? IE9 works very well. Should I stop using FireFox?

    I have a HP DV7-4165 which has Windows 7 64 bit and simple features of the HP pass identity protection using the drive with the tips of the fingers. My Firefox support says "If you have the Firefox browser on your computer when your HP SimplePass Identity Protection software is installed, a Firefox extension will also be installed which enables support for the use of the fingerprints with the browser Firefox." Once I updated to Firefox 4 it no longer works.

    You can get Firefox 3.6.16 here:

    http://www.Mozilla.com/en-us/Firefox/all-older.html

  • Satellite A300 - how to use the recovery with external DVD drive disc?

    Hello

    I bought a toshiba Satellite A300 - 15 d

    FTM the tsscorp drive that is installed in the camera no longer works (does not detect any type of media what so ever). ) need to recover the laptop, so I used a USB DVD drive to boot from the restore disc, but after that the charges of recovery console it says waiting for media in the f: drive, which is the tsscorp drive although I used an external drive to load the disc.

    What files should I edit to make it to load from the drive externally and if this isn't the solution, what do I do?

    Thanks in advance

    Hey Buddy,

    Unfortunately I think that it of not possible to use the recovery with external CD/DVD drive disc. Therefore, place the internal for use the recovery disc.
    You can get a new drive to an authorized service provider.

    But if the original OS from Toshiba is installed, you can use the function of disk recovery HARD reinstall Windows as well. Go to the advanced boot menu (F8) and select Repair my computer :)

  • After the upgrade to El Capitan, I get "the scanner is attributed to ImageCapture. Using the scanner with TWAIN? What to say?

    I have XP Epson-610 and have scanned on it successfully for years. To date, but when tried to open I get the ap scanner, the scanner is attributed to ImageCapture. Using the scanner with TWAIN? ImageCapture does not work on El Capitan? What is TWAIN, a printer-scanner driver?

    Thank you.

    TWAIN is an old scanner interface. OS X now use ICA, Architecture (?) of Capture of Image.

    Never seen this message, but I guess that means Capture of Image is using the scanner, or is configured to use the scanner and it is not necessary for the third party software. You open picture Capture, or did the scanning software provided with the scanner by Epson?

  • I brought an old Sidewinder Precision Pro joystick for use with old Microsoft Flight Sim 2000 Edition Pro, I can use the joystick with my Vista Home Premium laptop

    I installed Microsoft Flight Simulator 2000 Professional Edition, on my laptop. I bought an old Microsoft Sidewinder Precision Pro joystick. Can I use the joystick with my Vista Home Premium OS?.

    Hello

     
    What is the model of the sidewinder Precision Joystick?
     
    You can use it with Vista, but sometimes it can cause a problem. Check the link and if you have a problem follow the steps in the article.
    You experience problems when you use a Sidewinder Force Feedback Pro joystick with Flight Simulator on a Windows 2000, Windows XP, or Windows Vista-based computer
    http://support.Microsoft.com/kb/294672
  • To use the computer with the different Flight Simulator equipment that is only compatible with 32-bit versions of Windows

    Original title: change the version of Windows

    I have a computer used only for Flight Simulator and is running Windows 7 Home Premium 64-bit.  I want to use the computer with the different Flight Simulator equipment that is only compatible with 32-bit versions of Windows.  Is there a way I can upgrade to Windows 7 64 bit for Windows 10 32 bit and enjoy free upgrade of Windows 10?

    No, the upgrade program will replace existing windows with the same number of bits, 32 to 32 and 64 to 64.

    Even within the same version of Windows, passing from 32 to 64 and vice versa requires a clean installation.

  • Scanner EPSON Perfection V200 Photo: PDF button does not work since I use the scanner with an ASUS i5 running Win 7 Ultimate desktop computer.

    The PDF button does not work since I use the scanner with an ASUS i5 running Win 7 Ultimate desktop computer. I downloaded the 64-bit Epson software for the scanner.

    I found the solution to the problem, and it is indeed with the revised in Windows 7 Control Panel.

    Here how to solve the problem:
    Go to the control panel in Windows 7.
    Search scanner in the upper search box to the right
    You will see a "view scanners and cameras".
    Click it, you will see the Epson Perfection V200. Highlight.
    Click Properties, then Yes, then events.
    Where it says select an event, you MUST choose the event suitable for each option.
    To the Start button, choose Start the series of creativity
    For the copy button Choose launch Epson Scan
    E-mail button also Epson scan
    PDF includes Epson scan
    There you go.
    Now, all this was not necessary before, there are no instructions, and the fault lies with MS. how much more confused MS will do the control panel?
  • When I try to use the webcam with Skype it blocks Skype and said "Skype has stopped working, windows is checking for a solution."

    Original title: lifecam 3000 and Skype does not?

    Hello, I tried the two 5.5 beta and 5.3. When I try to use the webcam with Skype it blocks Skype and says "Skype has stopped working windows is checking for a solution." I have windows update connection bars 4/5 drivers and my computer ==> http://www.newegg.com/Product/Product.aspx?Item=N82E16883103361 help is appreciated, thanks

    Hello, I had just fixed yesterday. I deleted the drivers and programs that accompanies it, it ends up being the lifecam software that comes with it interfering with Skype, thanks to all who help :)

  • Is it possible to load your phone with the Office using the cord with head phone the ends of both sides?

    Is it possible to load your phone with the Office using the cord with head phone the ends of both sides?

    No, only USB.

    Taken head phones don't have any power.

  • I can't fix my mouse to use the option with a single click in windows 8. The two click works fine, but I prefer the one click option

    With Windows Vista and Windows 7, I put the mouse to use the option with a single click to open files and programs desktop.  I can't find this option in Windows 8.

    Hello
     
    Thanks for the post about Microsoft Community.
     
    I understand that you don't want to use the simple click instead of double click of the mouse that you used in Windows Vista and 7.
     
    I would ask you to please follow the steps below to activate the option just click on the button of the mouse in Windows 8.
     
    un) Please move the cursor to the bottom right and click on the search box, which is the first option in this Panel.
     
    b) in the search box, type Control Panel, and then click Control Panel.
     
    c) after opening the Control Panel, you will see many programs such as the system, network and security, Internet, hardware and sound, and other programs. Click "appearance and personalization".
     
    d) now click on the folder option to open it.
     
    e) now you will see many options in the folder option. Now, click single-click to open an item (point to select).
     
    f) now click on apply and ok to turn this feature on your computer.
     
    I hope your problem is solved now. Please feel free to write back if the problem still persists.

Maybe you are looking for