How can I lock my stored procedure so that users cannot modify, but users can see it?
Like this: some stored procedure is locked for all users, and some is unlock.
Like this image
http://i.stack.imgur.com/G99qk.png
try this
CREATE PROCEDURE dbo.enc_sp
WITH ENCRYPTION
AS
--here is your query
based on
this answer
Related
This is my first posted question here so I hope the format is acceptable.
I am able to execute get_ddl() and DESC PROCEDURE for all of our stored procedures but some have a null body when using describe and are cut short when using the get_ddl(). If I connect with the user that is the owner of the SP it does show me the whole procedure. I have also granted all privileges on the procedures to my ETL user in the schema and I still can't see all the code.
This is the result of running get_ddl() on the SP, it is missing the sql command variable and everything after:
CREATE OR REPLACE PROCEDURE "SP_test"()
RETURNS VARCHAR(16777216)
LANGUAGE JAVASCRIPT
EXECUTE AS OWNER
AS '';
I am able to call the SP with a user that is not the owner and it works correctly. The account admin role was also not able to see the full procedure for all the SP's.
Can someone give me a hand?
Thanks,
James
This may be because Snowflake supports SP overloading. What you may be seeing is an early copy of the SP before it had the variables added. It may have been added accidentally without any contents. For example:
-- Someone creates the shell of an SP like this:
create or replace procedure foo()
returns string
language javascript
as
$$
$$;
-- Later someone adds one or more variables and a body
create or replace procedure foo(MY_VARIABLE string)
returns string
language javascript
as
$$
return "Hello world.";
$$;
-- Get the old signature, body is empty
select get_ddl('procedure', 'foo()');
describe procedure foo();
-- Get the newer signature, body has contents
select get_ddl('procedure', 'foo(string)');
describe procedure foo(string);
I've got this issue too, and after search I found its a permission problem.
in snowflake USAGE permission does not enable read procedure body, only the definition of name and parameters. so grant read permission to your user and you will see the content in GET_DDL() command, DESC procedure, SHOW procedure, etc.
you can see your permission using SHOW GRANT TO USER USER_NAME or SHOW GRANT TO ROLE ROLE_NAME.
I'm trying to know how to call stored procedures from iReport with an Informix DB Connection. If I do a simple select retrieves all the columns with no problem.
Now that I must work with some data which I retrieve from a Stored Procedure. To test how to do this I made a sample SP as this:
CREATE PROCEDURE sp_example() RETURNING VARCHAR(100), INTEGER;
RETURN 'some varchar', 100;
END PROCEDURE;
This compiles and I can execute it from my SQL editor. The problem comes when I want to retrieve the data from iReport, I'm just getting the first returning value ('some varchar') but not the second, as shown in the screenshot:
What am I missing here?
My Informix version is Informix Dynamic Server 2000 Version 9.21.TC4.
Iam trying to delete all records in my FDTable component using ,
mytable.Delete;
but no record is getting deleted.
can any one suggest me a way to delete all records in a FdTable.
EDIT
i modified it in this way,
for i := mytable.RecordCount - 1 downto 0 do
begin
mytable.Delete;
end;
mytable.Refresh;
but it is taking lot of time because there a lot rows in my fdtable.
Try
MyTable.EmptyDataSet;
There may be a bit more to do than that, but you don't say how you are populating MyTable in the first place.
Remove all the records in the underlying database table (the best way to do that will depend on the database) and call refresh just once.
If you must do it via TFdTable, use BeginBatch, do your deletes (without refresh), EndBatch and only then Refresh.
mytable.BeginBatch;
for i := mytable.RecordCount - 1 downto 0 do
begin
mytable.Delete;
end;
mytable.EndBatch;
mytable.Refresh;
I would suggest you use a stored procedure for the job and not SQL from your application. Stored procedures are simple to make and blazing fast because they operate directly on the server.
Just create a stored procedure for your table;
sp_deleteall
and do in it a single line of sql:
delete from mytable
From your application,drop a TFDStoredProc on the form, link it to your stored procedure on the server and just call on the procedure
`
sp_deleteall.ExecProc;
To know how many records were deleted just call, after the procedure execution :
ShowMessage(IntToStr(sp_deleteall.RowsAffected) + ' records were deleted.');
Try it ...
Try
as doing delete for all the rows would hamper the performance.
If that does not work then why don you create the dataset runtime and then free the object.
Form fastest to slowest. First two are commands you execute server side.
Close the table and do a SQL DDL command TRUNCATE TABLENAME; and then reopen. This requires exclusive access to the table.
Use a SQL DML command DELETE FROM TABLENAME;. This does not require exclusive access.
Use a loop client side. A lot slower and triggers a lot of events client side.
all you need to do for delete all records on a FDMemTable is
MyTable.Active := False;
I got this form;
I want to save al of those edits with 1 save button.
But the problem is that those fields all have a different datasource.
Is there somebody who can help me out?
Simple go over all data sources involved and use DataSource.DataSet.Post (assuming the DataSets are already in dsEdit/dsInsert mode).
Note: If your DBMS supports transactions, it would be wise to group all your posts in a single transaction, so that data/relations integrity will not be compromised e.g.:
MyConnObj.BeginTrans;
try
DataSource1.DataSet.Post;
DataSource2.DataSet.Post;
DataSource3.DataSet.Post;
MyConnObj.CommitTrans;
except
MyConnObj.RollbackTrans;
raise;
end;
I have a large CSV file containing a list of stores, in which one of the field is ZipCode.
I have a separate MongoDB database called ZipCodes, which stores the latitude and longitude for any given zip code.
In SQL Server, I would execute a stored procedure called InsertStore which would do a look up on the ZipCodes table to get corresponding latitude and longitude and insert the data into the Stores table.
Is there something similar to the concept of stored procedures in MongoDB for this?
Basically, for each insert I need to look up the latitude and longitude for that store and save that as well.
I am not too familiar with the concept of Map/Reduce, but would that be relevant here?
Thank you!
The closest thing to an equivalent of a stored procedure in mongodb is stored javascript. A good introduction to stored javascript is available in this article on Mike Dirolf's blog.
NOTE that according to the reference:
Do not store application logic in the database. There are performance
limitations to running JavaScript inside of MongoDB. Application code
also is typically most effective when it shares version control with
the application itself.
So there is not any equivalent for stored procedure in mongodb.
You could use Triggers and Functions on the cloud with MongoDB Stitch.