Oracle - View source of builtin package - sql

How can I view the source of a builtin package in Oracle 19c?
I'm interested in the SYS.UTL_SMTP package.
I don't have access to the file system, only login to the database.

Have you tried googling it?
If you google search plsql unwrap the first link is an online tool that allows you to paste in wrapped code and will show you the unwrapped code.

Related

Viewing SQL for SQL Server Integration Services (SSIS) Transformations

I am new to Database and SSIS. Can anyone please let me know is there a way to look or view SQL code generated by SSIS transformations.
I know in BI reporting tools such as Business Objects, when we pull fields or columns into the reporting panel, we can view its corresponding SQL.
Similarly in SSIS, is there any option to view the SQL for SSIS Transformations.
Thanks in Advance
Raj
SSIS unlike other tools does not generate SQL per se, although you can include your own SQL inside tasks and components, but I guess you are not interested in the SQL that you write yourself but rather what SSIS is doing behind the scenes.
An SSIS package is essentially an XML-structured file with a collection of properties marking up the flow and process of its components. You can access to this xml file by right clicking on the package and selecting View Code:
The example above is an empty package so it's a very small XML file. In a complex package, this file can be very large as you will see all the tasks, components, parameters, variables, etc. as well as your own SQL code and C#/VB scripts if any.
When the project is built it generates a .ispac file which is no other thing that a zip file containing the package(s) in project plus a manifest, a content type and any other file required for the package to be deployed and executed.
You can see what is inside a .ispac by renaming to .zip and opening it. In this example I've built the above empty package and renamed the ispac to zip, then opened it :
In summary, unlike other tools that are purely SQL generators, in SSIS there is not much you can see about the generated code, all you can see is its structure as shown above.
Also, as mentioned by Marko Ivkovic in comments it might be possible to get some more info about what is happening at run time by using tools like SQL profiler.

PL/SQL Count pages from pdf blob

I have a situation in which I have a blob file whose type is .PDF and I need to count the pages in the PDF. Is there a way to do it without any external (3rd party) libraries? I know that there is PL/PDF tool but I need to do it only in PL/SQL. I am using Oracle 11g version, and the files is sitting in the table.
Any help will be appreciated, thanks.
I think you can go with Java in the Oracle database.
Check how to do it with Java only here or there.
Next steps would be to :
load the required JAR libraries in the Oracle database
create a Java Source in the database with the java code in it
create a PL/SQL function that will wrap the Java class (once the source is compiled).
Use this PL/SQL function to get the number of pages in your PDF through Java.
Those are the main lines but I think it's the best way if you want to stay with open source and free software.

release postgresql extension

I'm developing application that holds data in postgres. So i must prepare database before working with application, there must be created few tables. I'm creating this tables by running sql code but i think it's not convenient after i found this doc:
A useful extension to PostgreSQL typically includes multiple SQL
objects; for example, a new data type will require new functions, new
operators, and probably new index operator classes. It is helpful to
collect all these objects into a single package to simplify database
management
The main advantage of using an extension, rather than just running the
SQL script to load a bunch of "loose" objects into your database, is
that PostgreSQL will then understand that the objects of the extension
go together
I believe that i must use this approach
What i don't understand is that how can i share my extension. I thought that it works like maven, you create your extension with custom types, functions, tables and than you can pack it, name it (eg my-ext-0.1), give a version and release into some kind of a repository. After that you can connect to a database, run sql 'create extension my-ext-0.1' and have everything done :)
I thought that 'create extension' command will download extension and install it without downloading this by hands. I use maven, ivy and i expected similar behaviour from postgresql.
Documentation says that you need to place your extension files under some directory and only than run 'create extension' under some database.
How do you create your extensions and share them between different servers?
Postgres extensions do not work like this. They can have access to database internals and can run any code as database OS user. Therefore installing them is typically limited only to superusers, from a specific directory and only some of them are available on managed hosting servers.
I though that you can achieve something similar with installing your supplemental functions, types and tables in a special schema which is added to a search path. Upgrade would then be as simple as:
drop schema mylib cascade; -- don't do this!!!
create schema mylib;
\i mylib.sql
But unfortunately this would also remove all dependent objects from other schemas - columns using a custom type, triggers using a custom function etc. So it's not a solution for your problem.
I'd rather create my functions, types and all in my schema, using available extensions and "standard" languages.
Postgres will not download your extension (unless you create extension that will add this functionality to postgres). But your extension should be still created "usual" way.
to check your "directory for extension", run:
t=# create extension "where should I put control file";
ERROR: could not open extension control file "/usr/local/share/postgresql/extension/where should I put control file.control": No such file or directory
And repeating comment, before extending SQL, please check out plpgsql and existing commands.
When you get bored and make sure existing postgres functionality is too limited, install postgres-contrib package and check other extensions as best practices. And of course check out https://pgxn.org/

How to create pdf Template with the dynamic values

I am stuck in this task from a month ago so my last option is to post my query on stack-overflow.
I have to find a PDF Creation tool where i can crate my PDF Template and also i can assign a data source like sql server or any thing else. by which the sql server dynamic data can replace the value of pdf template Tags.'
I have tried many tools like Foxit and bulzip . But any of the tool does not meets my requirement. I must say I have completely stuck in this Task.
So Please give me appropriate solution . Immediate response will be appreciated.
If you want to create pdf in client side, you can try jspdf
If you are using php for server side, you can try mpdf.
Have a look at wkhtmltopdf. It's a very simple console utility that creates PDF from HTML. So basically you need to generate HTML markup. You can use some scripting language (PHP, python, etc.) or templating engine, depending on what exactly you want and what tools you are familiar with.
Create HTML/CSS markup for your template.
Define places where you want to put dynamic data, mark it
somehow.
Create script that will query database for your data and then
Either use search&replace in your script to place real data, or
copy whole HTML as a template using some templating engine (for
instance, PHP is itself a template engine, so you can basically
place save template as PHP file where real data is placed where
needed).

How do I upload an Excel sheet to a SQL table in a Lightswitch web client?

I have a lightswitch project in visual studio 2013, using vb.net. I would like the user to be able to click a button and have lightswitch find an excel file, and upload that file to a sql table according to a pre-determined column mapping.
My preference was to use the Office Integration extension for visual studio, which I got working with VS 2013 by downloading it from this link: http://www.ge.tt/71iuRQv/v/0
However, the documentation and examples for office integration seem to be very heavy on getting an excel spreadsheet into a display in the lightswitch web client, rather than into the sql data table, which is where I need it. Here are the examples I've been following:
http://blogs.msdn.com/b/bethmassi/archive/2012/07/18/new-and-improved-office-integration-pack-extension-for-lightswitch.aspx
Alternatively, I have an existing stored procedure, and I can request that the server call this stored proc by sending a web API extension from the client to the server. I have this working already for other stored procs, according to examples from Beth Masi and Paul van Bladel. (Stackoverflow won't let me post the links...)
The undesirable part of this approach is that the stored proc is old, and messy.
I've searched and searched, but have yet to find anyone approach this problem for VS 2013 with lightswitch. Any useful advice?
I've used the method detailed by Matt Sampson to store word files and it works very well. Since it just stores the raw binary it should handle Excel files just as well.
If you're creating the table in LightSwitch, use the Binary Type. If you use SQL create scripts use varbinary(MAX).
You need to create a custom Silverlight dialog box to gain access to the OpenFileDialog object. Then open the file in as a FileStream.
Finally, you need to add a handler for the closed method of the control and then show the control to the user. Most likely done in a button. This needs to be done on the main dispatcher.
The code examples are in C# but I just used one of the many available translators out on the web and copy/pasted the VB.NET code.
Another option might be to consider shelling out to the DTSEXEC run-time to execute an SSIS package to perform the upload - especially if the target Excel spreadsheets have predefined layouts and content data types.
Even simpler, you might be able to use the SQL Server BULK INSERT command to get the job done - although that would require a SQL Client connection to your database.
HTH