7

Groovy Sql to execute instructions in a batch

 2 years ago
source link: https://www.codesd.com/item/groovy-sql-to-execute-instructions-in-a-batch.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Groovy Sql to execute instructions in a batch

advertisements

I am using Groovy Sql to fetch results. This is the output from my Linux box. Actually there are 2 statements involved sp_configure 'number of open partitions' and go see below

%isql -U abc -P abc -S support
1> sp_configure 'number of open partitions'
2> go
Parameter Name                 Default     Memory Used Config Value
     Run Value    Unit                 Type
------------------------------ ----------- ----------- ------------
     ------------ -------------------- ----------
number of open partitions              500        5201         5000
             5000 number               dynamic

(1 row affected)
(return status = 0)
1>

I am using groovy code

def sql = Sql.newInstance("jdbc:abc:sybase://harley:6011;DatabaseName=support;",dbuname,dbpassword,Driver)
sql.eachRow("sp_configure 'number of open partitions'"){ row ->
        /*println row.run_value*/
    }

Is there a way to execute statements in batch?

I am using Sybase


Just try this

sql.eachRow("sp_configure 'number of open partitions'"){ row ->
        println row.'Parameter Name'.trim    }

Related Articles

Groovy Sql.execute () with sql statement as string variable does not work

I am trying to execute a sql statement in groovy by passing the statement as a string variable rather than a string literal. The reason I am using a string variable is because I am reading the sql statement from a file. For example (assuming sql is a

Error Using Groovy.sql Out Parameter

I am trying to execute some stored procedures in groovy way. I am able to do it quite easily by using straight JDBC but this does not seem in the spirit of Grails. I am trying to call the stored procedure as- sql.query( "{call web_GetCityStateByZip(?

Groovy SQL Error - This ResultSet is closed

I am using Groovy's Sql object to perform queries on a postgres db. The queries are being executed as follows: List<Map> results = sql.rows("select * from my_table") List<Map> result2= sql.rows("select * from my_second_table&quo

Using groovy.sql.Sql.executeInsert () in a Java Program

EDIT Changing the question due to new information I'm using the Groovy SQL library in a Java program and having trouble when inserting rows in an Oracle database with the executeInsert() function. This is a fragment of my Java program: DataSet myds =

ORA-28040: No matching authentication protocol exception when using the groovy.sql package with oracle12c

I am trying to connect to oracle12c database using groovy.sql.Sql Sql sql = Sql.newInstance('jdbc:oracle:thin:@'+hostName:port/serviceName, dbUser, dbPassword, 'oracle.jdbc.driver.OracleDriver') and it returns java.sql.SQLException: ORA-28040: No mat

Grails transactions (not based on GORM, but using Groovy Sql)

My Grails application is not using GORM but instead uses my own SQL and DML code to read and write the database (The database is a huge normalized legacy one and this was the only viable option). So, I use the Groovy Sql Class (http://groovy.codehaus

Using the Groovy Sql object

I'm trying to do some basic queries using the groovy.sql.Sql object, and I'm getting a SQLException that I can't seem to diagnose or make go away. I've reduced it to the simplest case, and I'm still seeing the problem. My code: import groovy.sql.Sql

Store sql.eachRow () of groovy sql in a list

do you know how to store the result from sql.eachRow() of groovy sql to a list? for example def personList = [] ? example: sql.eachRow('select lastname from users where id='active') What I want is to store the result ie. lastnames to a list ie def pe

Exact sql query executed by Entity Framework

the question seems clear enough, but I'll add a case using (var context = new MyEntities()) { if(context.mytable.Any(row => row.myfield == 2)) { // do something here } } I am new to Entity Framework. I don't know how to check the exact sql query exec

Groovy SQL and the Array parameter

I have a stored procedure which accepts a parameter of type Array and I'd like to invoke it via groovy.sql.Sql.call(...) but I can't figure out how to instantiate a java.sql.Array instance to pass as a parameter. In normal JDBC, I can create a java.s

Sql backup executed in the table

I am trying to log down sql that execute. I have a function call LogGenerateReport(String Sql) that will do a insert process to save the data in a database. The Problem i face is about the SQl ''. For example: INSERT INTO TABLE(Sql) VALUE('SELECT * F

How do I delete the output of a sql query executed via a batch file

I am executing an sql script through a batch file sqlcmd /S<machine> /Usa /Paaa123 /i "<sql file>" > "results.txt" After the above gets executed the resultant file has "(8890 rows affected) " as a part of the r

How do I run a sql server 2008 command by a batch file?

i have to execute a sql command from a batch file. like :- "Select top 1 versionNumber from SchemaVersion order by Id desc" and Show its result on batch file , just when this batch file gets open. please can any one suggest me right solution to

Several SQL commands executed via & ldquo; ExecuteReader & rdquo; in a system, I can only handle SQL statements

I have to configure a system which provides me with an area to input SQL statements. It is important to notice that we cannot modify the system we are configuring. I believe the system was built in C# (.net for sure but C# is a guess). Any way, I'm t

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK