Inserting multi-language values to sql server from parameter - stored-procedures

Im trying to insert multi language to the database. But i needed to do it from StoredProcedure. The Value will be set in nvarchar of a parameter. But converting that to unicode with N is not working out for me.
Working Model:
declare #kk nvarchar(1000),#K nvarchar(100);
set #k = 'મારું નામ પિનલ છે';<br>
set #kk = N'મારું નામ પિનલ છે';<br>
print #kk;
To be fixed:
declare #kk nvarchar(1000),#K nvarchar(100);<br>
set #k = 'મારું નામ પિનલ છે';<br>
set #kk = N''+#k+'';<br>
print #kk;
Thanks in Advance

Related

How to insert into a table field with value from a display method dependent of string

as you might know, this is a nice way to dynamically set values to fields.
myTable.(fieldName2Id(myTable.TableId, fieldNameStr)) = "This value";
myTable.insert();
What I am wondering about is if there is any way to do it in a similar fashion with display methods, just dynamically get the values from them?
If i have the Display method name (i.e. itemName()) how can I do this...?
something like this to demonstrate how i think:
methodNameStr = "ItemName";
myTable.myField = mytable.(methodName2Id(myTable.TableId, methodNameStr));
myTable.insert();
Use DictTable.callObject(medhodName, buffer).
Common myTable;
DictTable dt;
//<SampleOnly>
str methodNameStr = "itemDescriptionOrName";
InventTable tmpTab;
select firstOnly tmpTab;
myTable = tmpTab;
//</SampleOnly>
dt = new DictTable(myTable.TableId);
dt.callObject(methodNameStr, myTable);
info(strFmt("%1", dt.callObject(methodNameStr, myTable)));

get out parameter value of stored procedure in classic asp

I am working with classic asp and using stored procedure. I have to get the value of stored procedure out parameter. This is my code
<% #LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<!-- METADATA TYPE="TypeLib" NAME="Microsoft ADO Type Library" UUID="{00000205-0000-0010-8000-00AA006D2EA4}" -->
<%
Dim value
Dim i
set con = Server.CreateObject("ADODB.Connection")
con.Open "Provider=SQLOLEDB;Server=aliba\SQLEXPRESS;Database=dummySP;Trusted_Connection=Yes;"
Set Comm = Server.CreateObject("ADODB.Command")
comm.ActiveConnection = con
comm.CommandText = "sp_dummy"
'comm.NamedParameters=true
comm.CommandType = adCmdStoredProc
comm.Parameters.Append comm.CreateParameter("#weight" , adVarchar,adParamInput, 50, "hello")
'comm.Parameters.Append comm.CreateParameter("PRODUCT", adVarchar, adParamInput,50, producttype )
'comm.Parameters.Append comm.CreateParameter("ACCOUNT", adVarchar, adParamInput,100, "" )
comm.Parameters.Append comm.CreateParameter("#pris", adVarchar, adParamOutput,50) 'output parameters
'i=comm.Execute
comm.Execute
value=comm.Parameters("#pris").Value
Response.Write("Value is")
Response.Write(value)
The value of pris is not showing on output.I have no idea what is wrong with this.
I followed this link (Calling SQL Stored Procedure with Output Parameter in VBScript) but does not get success
It is giving me following error
Value is
Response object error 'ASP 0185 : 8002000e'
Missing Default Property
/StoreProcedure.asp, line 0
A default property was not found for the object.
Here is my stored procedure
ALTER procedure [dbo].[sp_dummy]
#weight nvarchar(50),
#pris nvarchar(50)= null out
as
begin
select #pris = pris from sp_dummy_table where weight= #weight
end
I suggest that you close out your SP with a SELECT so you can get the value as from a Recordset.
SELECT OutPRIS=#pris
Then in your ASP code:
Set rsComm = comm.Execute
If Not rsComm.EOF Then
myPRIS = rsComm.Fields("OutPRIS").Value
Else
myPRIS = Null
End If
rsComm.Close
Set rsComm = Nothing
Hope this helps.

Lua Changing Table Keys

Anyone tell me why this doesn't work?
GET_TABLE {1=ID}
key = string.format("%q", GET_TABLE[1])
RETURN_TABLE[key] = "ss"
print(RETURN_TABLE[ID])
print(GET_TABLE[1])
First print result: nil. Second print result: ID
I want the first print result to be: ss
GET_TABLE {1=ID}
key = "ID"
RETURN_TABLE[key] = "ss"
print(RETURN_TABLE[ID])
print(GET_TABLE[1])
The above works fine so I assume its due to the string.format not working right?
The %q format token returns the input as an escaped and quoted Lua string. This means that given the input ID it will return "ID" (the double quotes being part of the string!) which is a different string. (Or, represented as Lua strings, the input is 'ID' and the return value is '"ID"'.)
You have therefore set the ID key while trying to retrieve the "ID" key (which presumably does not exist).
> x = 'ID'
> =x
ID
> =string.format('%q', x)
"ID"
> =#x
2
> =#string.format('%q', x)
4
Your code does not compile (you need [] around the index), and you should use the raw string of ID, not the "quoted" string:
GET_TABLE = {[1]=ID}
key = string.format("%s", GET_TABLE[1])
Note that I had to initialize ID and RETURN_TABLE objects to the following:
ID = 'ID'
RETURN_TABLE = {}
Stylistic note: you should only use all-caps names for constants, otherwise too many makes code hard to read

Create a numerical table from the values of a non numerical table

Backpack = {Potion = 'backpack',Stack = 'bag',Loot = 'derp', Gold = 'random'}
Backpack[1] ~= 'backpack' -- nope
As you guys can see, I cannot call Backpack[1] since its not a numeral table, how would I generate a table after the construction of Backpack, consisting only of it's values? for example:
Table_to_be_Constructed = {Value of Potion,Value of Stack,Value of Loot,Value of Gold} -- this is what i need
It seems simple but I couldn't find a way to do it.
I need it this way because i will run a numeric loop on Table_to_be_Constructed[i]
To iterate over all the key-value pairs in a table, use the pairs function:
local Table_to_be_Constructed = {}
for key, value in pairs(Backpack) do
table.insert(Table_to_be_Constructed, value)
end
Note: the iteration order is not defined. So, you might want to sort Table_to_be_Constructed afterwards.
By convention, the variable name _ is used to indicate a variable who's value won't be used. So, since you want only the values in the tables, you might write the loop this way instead:
for _, value in pairs(Backpack) do
For the updated question
Backpack has no order (The order in the constructor statement is not preserved.) If you want to add an order to its values when constructing Table_to_be_Constructed, you can do it directly like this:
local Table_to_be_Constructed = {
Backpack.Potion,
Backpack.Stack,
Backpack.Loot,
Backpack.Gold
}
Or indirectly like this:
local items = { 'Potion', 'Stack', 'Loot', 'Gold' }
local Table_to_be_Constructed = {}
for i=1, #items do
Table_to_be_Constructed[i] = Backpack[items[i]]
end

how to dynamically name element in a lua table

I have the following test code:
local luatable = {}
luatable.item1 = 'abc'
luatable.item2 = 'def'
I'd like to know how to change it so that I can dynamically assign the names becuase I don't know how many "items" I have. I'd like to do something like this:
(pseudo code)
n = #someothertable
local luatable = {}
for i = 1, n do
luatable.item..i = some value...
end
Is there a way to do this?
I'd like to do something like this: luatable.item..i = value
That would be
luatable['item'..i] = value
Because table.name is a special case shorthand for the more general indexing syntax table['name'].
However, you should be aware that Lua table indexes can be of any type, including numbers, so in your situation you most likely just want:
luatable[i] = value
Yes, and the correct code is
for i = 1, n do
luatable["item"..i] = some value...
end
Recall that luatable.item1 is just sugar for luatable["item1"].

Resources