Query of queries: insert into another datasource

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Query of queries: insert into another datasource

    Hey guys,

    Essentially I need to get some info from one datasource and then insert that
    data into another datasource. Rather than using cfloop to do this, I was
    hoping maybe I could accomplish something like this with a query of queries.
    However, I don't know how to specify that I want to use both a dbtype="query"
    and a datasource for the cfquery (or atleast when I do, it doesn't work).

    Essentially I wanna do something like:

    <cfquery datasource="datasource1" name="resultSet">
    (SELECT '#mnemonic#' AS clientID, exch, currency FROM cld WHERE class=1 AND
    clientType=#allLimits["cash"]#)
    </cfquery>

    <cfquery datasource="datasource2" dbtype="query">
    INSERT INTO someTable VALUES (SELECT * FROM resultSet)
    </cfquery>

    Thanks,
    aDog

    Arielladog Guest

  2. Similar Questions and Discussions

    1. Query on ODBC datasource
      How do I create an ODBC driver for an access database located on a remote server without using CFadmin
    2. Join a query datasource and oledb datasource?
      Using CF5 here. I have a query that I'm creating on the fly using the QueryNew() and QueryAddRow() functions. Then I run my query using...
    3. 2 queries to 1 query
      Hello, Can somebody help me to combine these two queries into one query. <cfquery datasource="#DATAS#" name="getMainNav"> SELECT * FROM...
    4. Query of Queries on query New type query
      In CF5 we have a page that creates a query, using queryNew and querySetCell and the like, we then used dbtype="query" and gave it's name so we could...
    5. Dynamic Excel Datasource - Insert -> missing semicolon
      When i try to access a dynamic ODBC resource to excel (with a insert statement) the odbc error : missing semicolon occurs. <CFQUERY name="insert"...
  3. #2

    Default Re: Query of queries: insert into another datasource

    I don't believe that you can do this. I think dbtype="query" and
    datasource="..." are mutually exclusive.

    Most DBMS provide the capability of querying two different databases, on the
    same server, in one SQL statement (or querying between linked tables or
    databases). What type of database are you using and are the databases on the
    same server?

    mxstu Guest

  4. #3

    Default Re: Query of queries: insert into another datasource

    Hey mxstu,

    The database server is Sybase, but regretfully, they're on different servers.
    It looks like I'll just settle to looping through and getting the results.

    Usually using a query of queries makes sense because it uses cached info
    rather than hitting hte dbserver again. In this case, there's not really an
    advantage, except it may be quicker than looping through and obviously it's
    easier for the developer.

    aDog

    Arielladog Guest

  5. #4

    Default Re: Query of queries: insert into another datasource

    Doesn't Sybase have the abilty to link to another server? If so, you could
    create a link to the source server on the destination server and then you
    should be able to run a query directly between the two. The idea is ...

    <cfquery datasource="server2Datasource" ....>
    INSERT INTO server2.someDB.owner.someTable (someColumn)
    SELECT someColumn
    FROM server1.someDB.owner.someTable
    WHERE ... some conditions....
    </cfquery>

    I'm not 100% certain, but I think sybase may have this capability.

    mxstu Guest

  6. #5

    Default Re: Query of queries: insert into another datasource

    Doesn't Sybase have the abilty to link to another server? If so, you could
    create a link to the source server on the destination server and then you
    should be able to run a query directly between the two. The idea is ...

    <cfquery datasource="server2Datasource" ....>
    INSERT INTO server2.someDB.owner.someTable (someColumn)
    SELECT someColumn
    FROM server1.someDB.owner.someTable
    WHERE ... some conditions....
    </cfquery>

    I'm not 100% certain, but I think sybase may have this capability.

    mxstu Guest

  7. #6

    Default Re: Query of queries: insert into another datasource

    Doesn't Sybase have the abilty to link to another server? If so, you could
    create a link to the source server on the destination server and then you
    should be able to run a query directly between the two. The idea is ...

    <cfquery datasource="server2Datasource" ....>
    INSERT INTO server2.someDB.owner.someTable (someColumn)
    SELECT someColumn
    FROM server1.someDB.owner.someTable
    WHERE ... some conditions....
    </cfquery>

    I'm not 100% certain, but I think sybase may have this capability.

    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139