I also wrote a script that will take a csv file of table names and column
ids and set the sequences in your new postgres tables. Put the correct info
in the first two cfset tags. Enjoy!!!

Dave


 <cfset csvfile="full path to your file">
<cfset dsn="name of cf postgres datasource">

<cffile action="read" file="#csvfile#" variable="seqvals">
<!--- <cfdump var="#seqvals#">
<cfoutput>#seqvals#</cfoutput><br> --->
<cfloop list="#seqvals#" index="i" delimiters="#chr(10)##chr(13)#">
    <cfset seqtable=#ListGetAt(i,1,',')#>
    <cfset seqcol=#ListGetAt(i,2,',')#>
    <cfoutput>
    #seqtable#|#seqcol#<br>
    </cfoutput>
        <cfquery datasource="#dsn#" name="CheckEmpty">
        select #seqcol# from #seqtable#;
        </cfquery>
        <cfif CheckEmpty.Recordcount NEQ 0>
            <cfquery datasource="#dsn#" name="GetMax">
            select max(#seqcol#)+1 as thisnum from #seqtable#;
            </cfquery>
                
            <cfquery datasource="#dsn#" name="SetSeq">
            alter sequence #seqtable#_#seqcol#_seq restart
#GetMax.thisnum#;
            </cfquery>
        </cfif>
</cfloop>

-- 
C: Zanzeta, Inc.
N: Dave Livingston
T: Chief Information Officer
P: 469.688.4872
F: 214.292.8578
E: [EMAIL PROTECTED]
-- 



----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe: 
   http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe: 
   http://www.dfwcfug.org/form_MemberRegistration.cfm


Reply via email to