store query table output in variable - fitnesse

How can I store query output in a variable?
I have following query table:
|Query:SomeQueryClass|
|ObjId|ObjValue|
|someId|<IWantToStoreThisValue>|
I tried following:
|Query:SomeQueryClass|
|ObjId|ObjValue|
|someId|$value=|
However test fails and I have following output
|Query:SomeQueryClass|
|ObjId|ObjValue|
|someId|[realValue] expected [$value=]|

I found another way to solve this problem.
For example $object contains data I need to store in a variable
!|$object|
|getVariable1?|getVariable2?|
|$var1=|$var2=|
and data is stored in var1 and var2

Related

How do i read strings on separate lines

I'm trying to read strings on separate lines/space as title says.
I have a row on phpmyadmin which is:
I have a made a function to get the list value on Lua and the next step would be to read every name separately and thats what i can't figure it out.
Its possible to read every line separately and then add them to an array?
As for example
local names = {Noba, Detalle}
Solved:
local names = {}
for _, name in ipairs(getList():explode("\n"))
table.insert(names, name)
end

Robot framework get result

I trying to use the library SapGuiLibrary and want to get some values from SAP.
In my test case I have:
SapGuiLibrary.Get Row Count wnd[0]/shellcont[1]/shell
But how to I output the value to log or a file?
Assuming that the keyword returns the value, you can save it to a variable. You can then log the variable.
${result}= SapGuiLibrary.Get Row Count wnd[0]/shellcont[1]/shell
log to console ${result}

How to capture the Parameters being sent to a particular Stored Procedure?

In SQL Server 2008R2, do we have a query which can find the parameters being passed to a particular stored procedure?
I found it. Query will be
select PARAMETER_NAME,DATA_TYPE from information_schema.parameters where specific_name = 'StoredProcName'
Sql server doesn't keep the history of query execution. So there is not anyway to know parameters being passed to a particular stored procedure. If you want you can write a script in the procdure itself and keep all values in some tables. Or you can save query profile data in the trace file or in some table etc.

How to get all parameter names along with their values in stored procedure which is being executed

I'm using SQL Server 2012, is there any possible way to get all the parameters of a stored procedure along with the values passed to it?
I need these things to build a xml. I mean this should happen in the procedure which being executed and it should be common for all the procedures.
For example, let us suppose we have to procedures,
uspSave, #name='test' #age=20
uspDelete #id=2
now in uspSave procedure, I need to get #name, #age and the values 'test', 20
and in uspDelete, I should get #id with value 2.
For getting the column names, I tried this,
select parameter_name
from information_schema.PARAMETERS
where specific_name = OBJECT_NAME(##procid)
now is it possible to loop through the result of above query and can we get the values.
I think your best bet would be to use some code generation to generate the code block you require.
i.e.
Create your sproc without the code to XML-ify the parameters
Knock up a quick script (could be done in TSQL) to then construct the sproc-specific block of TSQL to convert the parameters into XML, using INFORMATION_SCHEMA.PARAMETERS
Copy that bit of auto-generated script into your sproc
The way you were thinking with dynamic sql wouldn't work because of the scope - the parameters would not be accessible within that dynamically generated SQL, you'd need to pass them in as args via sp_executesql, which puts you back in square 1.
e.g.
DECLARE #someval int = 7
EXECUTE('SELECT #someval') -- #someval is not in scope
So, if it will help save time, then code gen looks like your best bet.

COPY CSV file with an ID column

I have a rails application and I am trying to load data into it via PostgreSQL's COPY command. The file is CSV. The table maps to a Rails model and I need to retain the primary-key ID column so I can use model.for_each to play with the data--the table will have 5M+ rows.
My question is, how can I structure my CSV so that I can load data into the table and still allow the ID column to be there? It's a bummer because the only reason I need it is for the for_each method.
Regardless, I tried sending NULLs, as in:
NULL,col1,col2,col3,col4, etc.
But it doesn't work.
Thanks.
Passing in null for the primary key will never work no matter what options you have set for null string. You would be telling the backend to set the primary key to null which it will never allow no matter what the command to insert might be.
I really have no idea what you mean by retaining the primary key. That is something that is going be retained no matter what do. If you mean letting the DB pick the value for you and the primary key is a serial (auto-increment) then explicitly name all the columns but the primary key:
COPY country (colA, colB, colC) FROM '/usr1/proj/bray/sql/country_data'; -- leave out pkey
It also might be quicker to read the documentation on what null string options you would like to use instead of guessing possible values:
http://www.postgresql.org/docs/9.0/static/sql-copy.html
The default when using WITH CSV is an unquoted empty string, such as:
,col1,col2,col3,,col5
Which would create a record that looks like:
NULL,'col1','col2','col3',NULL,'col5'

Resources