× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Wed, Mar 14, 2018 at 1:35 PM, Alan Campin <alan0307d@xxxxxxxxx> wrote:

Create Variable is very slow. Hope you are not calling this much.

Why use an SQL procedure instead of using an SQL RPG service program?


I am calling a SQL procedure with input parms.

in the SQL procedure I want to create a new table from a select statement,
where the "where" clause of that select uses the input parms:

CREATE or replace PROCEDURE demoProc(
in inCompanyCode char(2)
)

Create table steve1 as (
select * from custmast
where companyCode = inCompanyCode )
with data ;

But I cannot do this. Cannot have substitution variables in a create table
as statement.

So instead, I create a table in qtemp, copy the variables into that table,
then join to the temporary table in the Select statement:

create table qtemp/parms ( key char(1), companyCode char(2)) ;
insert into qtemp/parms ( key, companyCode ) values( '1', inCompanyCode ) ;

Create table steve1 as (
select a.* from custmast a
join qtemp/parms b on b.key = '1'
where a.companyCode = b.CompanyCode )
with data ;

But this does not work because of SQL restrictions on inserting data into
tables in QTEMP and tables that are not journaled.

I want to replace this temporary table with a declared variable:

create variable qgpl.parm_companyCode char(2) default inCompanyCode ;
Create table steve1 as (
select a.* from custmast a
where a.companyCode = qgpl.parm_CompanyCode )
with data ;

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.